lkml.org 
[lkml]   [2022]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] signal: strict valid signal check
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;

\
 
 \ /
  Last update: 2022-01-07 07:48    [W:2.230 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site