Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1546965yba; Sun, 14 Apr 2019 13:16:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyxxp8JYpLXxCAy0n1hkpxurwMrbWxjm4BWdwo/dVxkquaZbensCEKJLPAPHHyQ1++MSmX X-Received: by 2002:a17:902:298b:: with SMTP id h11mr48883718plb.258.1555272970514; Sun, 14 Apr 2019 13:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555272970; cv=none; d=google.com; s=arc-20160816; b=B31Z9tQOJmgE2GkPCIMBoZv2QvOdkb/YMGpzmeLPMh4hoWjFq34BGLsWXI76nlr9Lw hHuXVsWJOCJ401Nj+UYVWKP/QtJUEy9VEg4f7sx75rbdx5IMfRuT0UMmUbvhwBkMXyv4 IZlHg9eYgs3SzF1jCWwsroXIOu2zkPeGKQZ5Q0zYZ9HMkAE1ExleiXfE/zIc+MlVTnqB 2AFx4dnrvGfYRkHIVgQed48mW7tAoP1CXX9YRR5v+dIJcouZX/HU/rUgJls4fJaRRmiW UEWBiuDNVxa9d3HX0Wn0HTYuKrq4gPZnheWK2sDTUe41LRTOTFY3YwSea1RUHKSEXpFH C5bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GKb4yFbXfLa/OJu4W+klncoNvbQ/la4YBpWHSraXapU=; b=SZg//Vp1UYRdOoH40B46oMCEiPB0C0stIYip1H1zzlIGu3872tiOhknXDodQuqvlAk 5aLTRfoxvJDONFGcPdaCr5GYLkMw1TSGGpesBp+k1FnXD5D9XTQHxPMpu05yCifqlbmG wUFe9dtXqgIonDiwZV4yTlWkasplZ+UbmQM/WZQqny0jFfrxXE4CBBN7de/i3rd5NiDX wtc4Y0EDyy/wBn7yLA9Ury3hxZcR2yhGoDmkeM9uXtkwF+5WAgw3VtMhG0XHN7I/m+QE 51IO/osa69qvC7BhgCSOQny2YcMKjt4GHtRyA6iDPOumoyv9zSCdSyXUhIGAnKGBKxTq UQ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b="Vj/jiFcq"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si43118764pgb.435.2019.04.14.13.15.53; Sun, 14 Apr 2019 13:16:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b="Vj/jiFcq"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727189AbfDNUPT (ORCPT + 99 others); Sun, 14 Apr 2019 16:15:19 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45008 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727178AbfDNUPS (ORCPT ); Sun, 14 Apr 2019 16:15:18 -0400 Received: by mail-ed1-f66.google.com with SMTP id i13so2136052edf.11 for ; Sun, 14 Apr 2019 13:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GKb4yFbXfLa/OJu4W+klncoNvbQ/la4YBpWHSraXapU=; b=Vj/jiFcqlYZA5zr7Ul6mvdSXRcj2EOIzUzXdXbfq4fXZCtVsiR/FJU/Vfd3XqMYVkf 2ttQY1B0v9peEZYVX2HHoWJFBg+YiAmatRe1MUnTus0IvtgEePeSxmR6esSqGJsRzd4R UBoWLyGVIyrldrGUgV8vsCozVMnfo5V0gu5L/R84mwD9JbLqDy7nR3NARHXaB+a/PdXz MAzAzq+/1JlB5pbVYfVc0VSRO/2v2Km4+ptBMFQ0JBXuWRlXUJVixeoKK/QO7x51O3WW ixjNwaCA6T8uMo4fh+ayXcuv5KAlvHYokSsKNrP/KWQk/RZ3+RFmtFJb2noFXfUxXEjw iqIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GKb4yFbXfLa/OJu4W+klncoNvbQ/la4YBpWHSraXapU=; b=nBLDJ39K+XojLzRO90XH9M4xzs9Qpzq4IgohiOpZ7XzuDMYgPC8XfMJSNIMI8h2O/D I1v9fO3o7X32lVWhy+LPMnlE9OF77nAFX4PhycQYIyXGcwKGSkrgm9zwaW2dkjNx7AyC A15pSN82OeDnCm0eQ9a/J5C0O+iewr0pNPxEITaEn+S46a6XrIvu4w2qdtbN5SzSP0/a SNGQaPQzqN796vetkgbmbN4/nxhWtWBXR6TMcZMSbAGr0OxJ4tqmpEpzYLD3VqMjTOVX SpPFZyIEYeNonIOnWizr7mDbqOQq8Wi1OmGOUsibHbM5L3PEdACkiWAwyW9EiuEamRIR f+Yw== X-Gm-Message-State: APjAAAVwBclQdL5r0kSQ4VLdtwR3WGs/4uR0thYlck//cE3c2NsfDxvj DJr69FlNa1v3g80SjNqwgVoFag== X-Received: by 2002:a17:906:374a:: with SMTP id e10mr28185988ejc.182.1555272916613; Sun, 14 Apr 2019 13:15:16 -0700 (PDT) Received: from localhost.localdomain ([212.91.227.56]) by smtp.gmail.com with ESMTPSA id n21sm3383068edq.14.2019.04.14.13.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Apr 2019 13:15:16 -0700 (PDT) From: Christian Brauner To: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, jannh@google.com, dhowells@redhat.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Cc: serge@hallyn.com, luto@kernel.org, arnd@arndb.de, ebiederm@xmission.com, keescook@chromium.org, tglx@linutronix.de, mtk.manpages@gmail.com, akpm@linux-foundation.org, oleg@redhat.com, cyphar@cyphar.com, joel@joelfernandes.org, dancol@google.com, Christian Brauner Subject: [PATCH 3/4] signal: support CLONE_PIDFD with pidfd_send_signal Date: Sun, 14 Apr 2019 22:14:35 +0200 Message-Id: <20190414201436.19502-4-christian@brauner.io> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190414201436.19502-1-christian@brauner.io> References: <20190414201436.19502-1-christian@brauner.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let pidfd_send_signal() use pidfds retrieved via CLONE_PIDFD. With this patch pidfd_send_signal() becomes independent of procfs. This fullfils the request made when we merged the pidfd_send_signal() patchset. The pidfd_send_signal() syscall is now always available allowing for it to be used by users without procfs mounted or even users without procfs support compiled into the kernel. Signed-off-by: Christian Brauner Signed-off-by: Jann Horn Cc: Arnd Bergmann Cc: "Eric W. Biederman" Cc: Kees Cook Cc: Thomas Gleixner Cc: David Howells Cc: "Michael Kerrisk (man-pages)" Cc: Andy Lutomirsky Cc: Andrew Morton Cc: Oleg Nesterov Cc: Aleksa Sarai Cc: Linus Torvalds Cc: Al Viro --- kernel/signal.c | 14 ++++++++++---- kernel/sys_ni.c | 3 --- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index f98448cf2def..cd83cc376767 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3513,7 +3513,6 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) return kill_something_info(sig, &info, pid); } -#ifdef CONFIG_PROC_FS /* * Verify that the signaler and signalee either are in the same pid namespace * or that the signaler's pid namespace is an ancestor of the signalee's pid @@ -3550,6 +3549,14 @@ static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo, siginfo_t *info) return copy_siginfo_from_user(kinfo, info); } +static struct pid *pidfd_to_pid(const struct file *file) +{ + if (file->f_op == &pidfd_fops) + return file->private_data; + + return tgid_pidfd_to_pid(file); +} + /** * sys_pidfd_send_signal - send a signal to a process through a task file * descriptor @@ -3581,12 +3588,12 @@ 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; /* Is this a pidfd? */ - pid = tgid_pidfd_to_pid(f.file); + pid = pidfd_to_pid(f.file); if (IS_ERR(pid)) { ret = PTR_ERR(pid); goto err; @@ -3620,7 +3627,6 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, fdput(f); return ret; } -#endif /* CONFIG_PROC_FS */ static int do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info) diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index d21f4befaea4..4d9ae5ea6caf 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -167,9 +167,6 @@ COND_SYSCALL(syslog); /* kernel/sched/core.c */ -/* kernel/signal.c */ -COND_SYSCALL(pidfd_send_signal); - /* kernel/sys.c */ COND_SYSCALL(setregid); COND_SYSCALL(setgid); -- 2.21.0