[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220801150647.70207-1-l4stpr0gr4m@gmail.com>
Date: Tue, 2 Aug 2022 00:06:47 +0900
From: Kangmin Park <l4stpr0gr4m@...il.com>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: Kees Cook <keescook@...omium.org>, Oleg Nesterov <oleg@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH] signal: Remove duplicate code in do_tkill
do_tkill() prepares kernel_siginfo with the same logic as the
prepare_kill_siginfo() except to set si_code.
So, add si_code parameter to the prepare_kill_siginfo(), and call
the function in do_tkill() to remove the duplicate code.
Signed-off-by: Kangmin Park <l4stpr0gr4m@...il.com>
---
kernel/signal.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index 6f86fda5e432..a71f4d69dd54 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3752,12 +3752,12 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait_time32, compat_sigset_t __user *, uthese,
#endif
#endif
-static inline void prepare_kill_siginfo(int sig, struct kernel_siginfo *info)
+static inline void prepare_kill_siginfo(int sig, int si_code, struct kernel_siginfo *info)
{
clear_siginfo(info);
info->si_signo = sig;
info->si_errno = 0;
- info->si_code = SI_USER;
+ info->si_code = si_code;
info->si_pid = task_tgid_vnr(current);
info->si_uid = from_kuid_munged(current_user_ns(), current_uid());
}
@@ -3771,7 +3771,7 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
{
struct kernel_siginfo info;
- prepare_kill_siginfo(sig, &info);
+ prepare_kill_siginfo(sig, SI_USER, &info);
return kill_something_info(sig, &info, pid);
}
@@ -3884,7 +3884,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig,
(kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL))
goto err;
} else {
- prepare_kill_siginfo(sig, &kinfo);
+ prepare_kill_siginfo(sig, SI_USER, &kinfo);
}
ret = kill_pid_info(sig, &kinfo, pid);
@@ -3928,12 +3928,7 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig)
{
struct kernel_siginfo info;
- clear_siginfo(&info);
- info.si_signo = sig;
- info.si_errno = 0;
- info.si_code = SI_TKILL;
- info.si_pid = task_tgid_vnr(current);
- info.si_uid = from_kuid_munged(current_user_ns(), current_uid());
+ prepare_kill_siginfo(sig, SI_TKILL, &info);
return do_send_specific(tgid, pid, sig, &info);
}
--
2.26.3
Powered by blists - more mailing lists