[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1641530757-3835-1-git-send-email-zhanghongchen@loongson.cn>
Date: Fri, 7 Jan 2022 12:45:57 +0800
From: Hongchen Zhang <zhanghongchen@...ngson.cn>
To: Marco Elver <elver@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Al Viro <viro@...iv.linux.org.uk>,
Ye Guojin <ye.guojin@....com.cn>, linux-kernel@...r.kernel.org
Subject: [PATCH] signal: strict valid signal check
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@...ngson.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
Powered by blists - more mailing lists