From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Hongchen Zhang <zhanghongchen@loongson.cn>
Cc: Marco Elver <elver@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Al Viro <viro@zeniv.linux.org.uk>,
Ye Guojin <ye.guojin@zte.com.cn>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] signal: strict valid signal check
Date: Fri, 07 Jan 2022 00:47:18 -0600 [thread overview]
Message-ID: <878rvsyrd5.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <1641530757-3835-1-git-send-email-zhanghongchen@loongson.cn> (Hongchen Zhang's message of "Fri, 7 Jan 2022 12:45:57 +0800")
Hongchen Zhang <zhanghongchen@loongson.cn> writes:
> The max usable signal number is limited by both _NSIG and task's
> exit_code, and the max valid signal number encoded in task's
> exit_code is 127. On the other hand _NSIG is normally power of 2,
> so limit the rule in valid_signal to check a valid signal number.
A quick look reveals this only affects mips.
If you have copied that silliness from mips for your new architecture
I would advise against it. That just seems to make sigset_t twice
as big as it needs to be for no good reason.
What seems reasonable is to fix mips to only support 127 signals (with
the same sigset_t size) and to add "BUILD_BUG_ON(_NSIG <= 127);" along
with your comment somewhere in kernel/signal.c
Eric
> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
> ---
> include/linux/signal.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/signal.h b/include/linux/signal.h
> index a6db6f2..9f1972e 100644
> --- a/include/linux/signal.h
> +++ b/include/linux/signal.h
> @@ -270,7 +270,11 @@ static inline void init_sigpending(struct sigpending *sig)
> /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
> static inline int valid_signal(unsigned long sig)
> {
> - return sig <= _NSIG ? 1 : 0;
> + /* max usable signal number is limited by both _NSIG and task's
> + * exit_code, and the max available signal number encoded in
> + * task's exit_code is 127.
> + */
> + return sig <= min(_NSIG, 127) ? 1 : 0;
> }
>
> struct timespec;
next prev parent reply other threads:[~2022-01-07 6:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-07 4:45 Hongchen Zhang
2022-01-07 6:47 ` Eric W. Biederman [this message]
2022-01-07 14:14 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878rvsyrd5.fsf@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=ye.guojin@zte.com.cn \
--cc=zhanghongchen@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome