mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [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; 3+ 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	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-07 14:15 UTC | newest]

Thread overview: 3+ 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

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