signal: Remove duplicate code in do_tkill
PATCH 1/1 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 <[email protected]>
--- kernel/signal.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
kernel/signal.c +5 -10
@@ -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); }
Signature · 1 line
2.26.3