linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: warn about direct use of send_sig_info and force_sig_info
@ 2021-05-06 13:28 Marco Elver
  2021-05-06 15:02 ` Dwaipayan Ray
  0 siblings, 1 reply; 8+ messages in thread
From: Marco Elver @ 2021-05-06 13:28 UTC (permalink / raw)
  To: elver, Eric W . Biederman
  Cc: linux-kernel, apw, joe, dwaipayanray1, lukas.bulwahn

Setting up siginfo and using send_sig_info() and force_sig_info()
directly is discouraged. Instead, new code wanting to generate signals
should use the appropriate helper specific to the signal.

Eric mentioned that he'd like to make these static at some point, but
until that can happen, let's try to avoid introducing new users of them.

Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Marco Elver <elver@google.com>
---
Eric,

While siginfo doesn't need changing often, when it does, it's quite the
adventure. We now have the various static asserts. The other thing is
usage of {send,force}_sig_info.

I think the best option right now is to teach checkpatch.pl about it
until they become static.

Fyi, I noticed one such new user here:
https://lkml.kernel.org/r/20210421024826.13529-1-wangjunqiang@iscas.ac.cn

Thanks,
-- Marco
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ccb412a74725..3a86aafc3bcd 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7153,6 +7153,12 @@ sub process {
 			     "Where possible, use lockdep_assert_held instead of assertions based on spin_is_locked\n" . $herecurr);
 		}
 
+# check for direct use of send_sig_info(), force_sig_info()
+		if ($line =~ /\b((force|send)_sig_info)\(/) {
+			WARN("USE_SIGINFO_HELPER",
+			     "Where possible, avoid using '$1' directly and use a signal-specific helper setting required siginfo fields (see include/linux/sched/signal.h).\n" . $herecurr);
+		}
+
 # check for deprecated apis
 		if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
 			my $deprecated_api = $1;
-- 
2.31.1.607.g51e8a6a459-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-07 11:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 13:28 [PATCH] checkpatch: warn about direct use of send_sig_info and force_sig_info Marco Elver
2021-05-06 15:02 ` Dwaipayan Ray
2021-05-06 15:22   ` [PATCH v2] " Marco Elver
2021-05-06 21:41     ` Joe Perches
2021-05-07 11:47       ` Marco Elver
2021-05-06 16:02   ` [PATCH] " Lukas Bulwahn
2021-05-06 16:11     ` Marco Elver
2021-05-06 17:51       ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).