From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 3844722320 for ; Tue, 24 Dec 2024 10:41:19 +0100 (CET) Received: (qmail 16262 invoked by uid 550); 24 Dec 2024 09:41:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com x-ms-reactions: disallow Received: (qmail 16205 invoked from network); 24 Dec 2024 09:41:14 -0000 Date: Tue, 24 Dec 2024 04:41:04 -0500 From: Rich Felker To: yan.li.cn@windriver.com Cc: musl@lists.openwall.com Message-ID: <20241224094104.GD10433@brightrain.aerifal.cx> References: <20241224020301.1673274-1-yan.li.cn@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241224020301.1673274-1-yan.li.cn@windriver.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] add check for pthread_attr_setschedparam(). On Tue, Dec 24, 2024 at 10:03:01AM +0800, yan.li.cn@windriver.com wrote: > From: Yan Li > > --- > src/thread/pthread_attr_setschedparam.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > mode change 100644 => 100755 src/thread/pthread_attr_setschedparam.c > > diff --git a/src/thread/pthread_attr_setschedparam.c b/src/thread/pthread_attr_setschedparam.c > old mode 100644 > new mode 100755 > index d4c1204f..4e28415e > --- a/src/thread/pthread_attr_setschedparam.c > +++ b/src/thread/pthread_attr_setschedparam.c > @@ -2,6 +2,13 @@ > > int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param) > { > - a->_a_prio = param->sched_priority; > - return 0; > + int min = sched_get_priority_min (a->_a_policy); > + int max = sched_get_priority_max (a->_a_policy); > + > + if (min < 0 || max < 0 || param->sched_priority < min || param->sched_priority > max){ > + return EINVAL; > + } > + > + a->_a_prio = param->sched_priority; > + return 0; > } > -- > 2.34.1 I don't see a good motivation for this change. The error conditions are MAY FAIL, not SHALL FAIL, and checking for them incurs two useless syscalls on every call to a function that's otherwise syscall-free. Rich