Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z2KD9MPG7DiS7bsM@voyager>
Date: Wed, 18 Dec 2024 09:12:36 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Cc: lihua.zhao.cn@...driver.com
Subject: Re: [PATCH v2] signal: check sigpause() input parameter

Am Wed, Dec 18, 2024 at 10:49:52AM +0800 schrieb lihua.zhao.cn@...driver.com:
> From: Lihua Zhao <lihua.zhao.cn@...driver.com>
>
> ---
>  src/signal/sigpause.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/signal/sigpause.c b/src/signal/sigpause.c
> index 363d2fec..8bd05f58 100644
> --- a/src/signal/sigpause.c
> +++ b/src/signal/sigpause.c
> @@ -1,8 +1,13 @@
>  #include <signal.h>
> +#include <errno.h>
>
>  int sigpause(int sig)
>  {
>  	sigset_t mask;
> +	if (sig < 1 || sig >= _NSIG) {
> +		errno = EINVAL;
> +		return -1;
> +	}
>  	sigprocmask(0, 0, &mask);
>  	sigdelset(&mask, sig);
>  	return sigsuspend(&mask);
> --
> 2.34.1

I looked around at the competition to figure out what the concensus
seems to be on input checking. POSIX no longer specifies the function,
so that is basically all that can be done at this point.

dietlibc doesn't have this function. Neither ctags nor a fulltext search
could find it in there.

glibc and bionic both have input checking but move it into sigdelset()
(they fail the function if sigprocmask() or sigdelset() fail). musl
already has input checking in sigdelset() if that fails, so maybe a
better change would be to just use those functions instead.

int sigpause(int sig)
{
    sigset_t mask;
    if (sigprocmask(0, 0, &mask) || sigdelset(&mask, sig)) return -1;
    return sigsuspend(&mask);
}

Ciao,
Markus

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.