From: Christian Brauner Date: Thu, 18 Apr 2019 10:18:39 +0000 (+0200) Subject: UPSTREAM: signal: use fdget() since we don't allow O_PATH X-Git-Tag: MMI-RSBS31.Q1-48-36-26~63 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5d5021dadfe768b776c00b85ffbc9ae5fe41f670;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git UPSTREAM: signal: use fdget() since we don't allow O_PATH As stated in the original commit for pidfd_send_signal() we don't allow to signal processes through O_PATH file descriptors since it is semantically equivalent to a write on the pidfd. We already correctly error out right now and return EBADF if an O_PATH fd is passed. This is because we use file->f_op to detect whether a pidfd is passed and O_PATH fds have their file->f_op set to empty_fops in do_dentry_open() and thus fail the test. Thus, there is no regression. It's just semantically correct to use fdget() and return an error right from there instead of taking a reference and returning an error later. Signed-off-by: Christian Brauner Acked-by: Oleg Nesterov Cc: Arnd Bergmann Cc: "Eric W. Biederman" Cc: Kees Cook Cc: Thomas Gleixner Cc: Jann Horn Cc: David Howells Cc: "Michael Kerrisk (man-pages)" Cc: Perry Lutomirsky Cc: Andrew Morton Cc: Oleg Nesterov Cc: Aleksa Sarai Cc: Al Viro Signed-off-by: Linus Torvalds (cherry picked from commit 738a7832d21e3d911fcddab98ce260b79010b461) Mot-CRs-fixed: (CR) Bug: 135608568 Test: test program using syscall(__NR_pidfd_send_signal,..) to send SIGKILL Change-Id: IMontanaeaadf9da371fb2d9caae4df49627760de7229 Signed-off-by: Suren Baghdasaryan Reviewed-on: https://gerrit.mot.com/1505849 Tested-by: Jira Key SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Reviewed-by: Wang Wang Reviewed-by: Yonghui Jia Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1796157 Reviewed-by: Xiangpo Zhao --- diff --git a/kernel/signal.c b/kernel/signal.c index ee153e138b60..3476b296fdb2 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3116,7 +3116,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, if (flags) return -EINVAL; - f = fdget_raw(pidfd); + f = fdget(pidfd); if (!f.file) return -EBADF;