* [PATCH] signal: strict valid signal check
@ 2022-01-07 4:45 Hongchen Zhang
2022-01-07 6:47 ` Eric W. Biederman
2022-01-07 14:14 ` kernel test robot
0 siblings, 2 replies; 4+ messages in thread
From: Hongchen Zhang @ 2022-01-07 4:45 UTC (permalink / raw)
To: Marco Elver, Andrew Morton, Eric W. Biederman,
Peter Zijlstra (Intel),
Thomas Gleixner, Al Viro, Ye Guojin, linux-kernel
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.
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;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] signal: strict valid signal check
2022-01-07 4:45 [PATCH] signal: strict valid signal check Hongchen Zhang
@ 2022-01-07 6:47 ` Eric W. Biederman
2022-01-07 14:14 ` kernel test robot
1 sibling, 0 replies; 4+ messages in thread
From: Eric W. Biederman @ 2022-01-07 6:47 UTC (permalink / raw)
To: Hongchen Zhang
Cc: Marco Elver, Andrew Morton, Peter Zijlstra (Intel),
Thomas Gleixner, Al Viro, Ye Guojin, linux-kernel
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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] signal: strict valid signal check
2022-01-07 4:45 [PATCH] signal: strict valid signal check Hongchen Zhang
@ 2022-01-07 14:14 ` kernel test robot
2022-01-07 14:14 ` kernel test robot
1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-01-07 14:14 UTC (permalink / raw)
To: Hongchen Zhang, Marco Elver, Andrew Morton, Eric W. Biederman,
Peter Zijlstra (Intel),
Thomas Gleixner, Al Viro, Ye Guojin, linux-kernel
Cc: llvm, kbuild-all, Linux Memory Management List
Hi Hongchen,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linux/master]
[also build test ERROR on linus/master hnaz-mm/master v5.16-rc8 next-20220106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Hongchen-Zhang/signal-strict-valid-signal-check/20220107-124756
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 136057256686de39cc3a07c2e39ef6bc43003ff6
config: hexagon-randconfig-r041-20220107 (https://download.01.org/0day-ci/archive/20220107/202201072220.gCthUkw6-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d6ab2033eb509bf064e07f58074e58562098dfcc
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hongchen-Zhang/signal-strict-valid-signal-check/20220107-124756
git checkout d6ab2033eb509bf064e07f58074e58562098dfcc
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tty/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/tty/tty_io.c:71:
>> include/linux/signal.h:277:16: error: implicit declaration of function 'min' [-Werror,-Wimplicit-function-declaration]
return sig <= min(_NSIG, 127) ? 1 : 0;
^
1 error generated.
vim +/min +277 include/linux/signal.h
269
270 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
271 static inline int valid_signal(unsigned long sig)
272 {
273 /* max usable signal number is limited by both _NSIG and task's
274 * exit_code, and the max available signal number encoded in
275 * task's exit_code is 127.
276 */
> 277 return sig <= min(_NSIG, 127) ? 1 : 0;
278 }
279
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] signal: strict valid signal check
@ 2022-01-07 14:14 ` kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-01-07 14:14 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 2591 bytes --]
Hi Hongchen,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linux/master]
[also build test ERROR on linus/master hnaz-mm/master v5.16-rc8 next-20220106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Hongchen-Zhang/signal-strict-valid-signal-check/20220107-124756
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 136057256686de39cc3a07c2e39ef6bc43003ff6
config: hexagon-randconfig-r041-20220107 (https://download.01.org/0day-ci/archive/20220107/202201072220.gCthUkw6-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d6ab2033eb509bf064e07f58074e58562098dfcc
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hongchen-Zhang/signal-strict-valid-signal-check/20220107-124756
git checkout d6ab2033eb509bf064e07f58074e58562098dfcc
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tty/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/tty/tty_io.c:71:
>> include/linux/signal.h:277:16: error: implicit declaration of function 'min' [-Werror,-Wimplicit-function-declaration]
return sig <= min(_NSIG, 127) ? 1 : 0;
^
1 error generated.
vim +/min +277 include/linux/signal.h
269
270 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
271 static inline int valid_signal(unsigned long sig)
272 {
273 /* max usable signal number is limited by both _NSIG and task's
274 * exit_code, and the max available signal number encoded in
275 * task's exit_code is 127.
276 */
> 277 return sig <= min(_NSIG, 127) ? 1 : 0;
278 }
279
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-07 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 4:45 [PATCH] signal: strict valid signal check Hongchen Zhang
2022-01-07 6:47 ` Eric W. Biederman
2022-01-07 14:14 ` kernel test robot
2022-01-07 14:14 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.