Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp403529yba; Thu, 18 Apr 2019 03:20:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaq7aTcY8+YUGbcJHDKSYEkwQ3SyljV7NHKBfaAYxC+9UYQItSrCwV+lbO1gxEMcnI4Us7 X-Received: by 2002:a17:902:e48f:: with SMTP id cj15mr94038087plb.256.1555582841814; Thu, 18 Apr 2019 03:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555582841; cv=none; d=google.com; s=arc-20160816; b=sA4XcxZPEvpeU8IgElqvX9JVNTYbT5KYHD8ZVh8BNIMPpYxX2Ryz3gswU5g9mf4Fg4 x05qbk1tL7Jd9cpVrnHElEK7SgxD4N0n+j84m/Y6asPKpFFZTX0+f1fmH9n0YVvpCLum wrpgOF8xsHnfKm4LiODxZrwTFAbHHDwEHfQZEEsGaDjM5Cbmsc9nW6HOfcypZaTCMgxf yCq5D0cYAK5O3UvEwt8gsUvx5qO+h9Gl/jL/0w2LJIWSS8TKfb34y4sKCLiLDj/TJFbm RRRuxyLI1wWxgMsx8MerwJUOXjq6Xjittoudz2raCZl6bSqf+FL/hAaCrgKBYzrhZ6Dj QfsA== 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=4NPruNiTZOmEOtPyLgn5BfelJiHp0PqiRMUV1YAkDEE=; b=HzXXTeDeH0XOpuGSKYk7EjDWoe6C+aqLnO+OqjDhQjRCTYIQHwUs7Kjgn3LqjZGzlE eUd+LzBJxc9qe/mJfP56yHGbR2TPTZOdcwUASA77LhM+0jl+QThBzUey+fHjDk1kxn26 7hE4R7HFeT6ehLljc/Vwyz/yrB5hXN7h2eLZ2lWkyDGVDsYpyWRjw0pmowZUKcSK6VBl N3gHc5de8a71cg+7S2KZB2H7dZN73JSA5LUjQzEGaUk5dqoCDPJ1RLv9DuUzznnbC50w 6ykztSrdpUcbvDwOiF2t7iwQNpydS8UHCHx+GXma+GymsDl0oGxf9u4uxje4Q+A/bDMs Amdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=JHdcxAbH; 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 b41si1809579pla.241.2019.04.18.03.20.27; Thu, 18 Apr 2019 03:20:41 -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=JHdcxAbH; 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 S2388671AbfDRKTd (ORCPT + 99 others); Thu, 18 Apr 2019 06:19:33 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33640 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388595AbfDRKT1 (ORCPT ); Thu, 18 Apr 2019 06:19:27 -0400 Received: by mail-ed1-f66.google.com with SMTP id d55so1371764ede.0 for ; Thu, 18 Apr 2019 03:19:26 -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=4NPruNiTZOmEOtPyLgn5BfelJiHp0PqiRMUV1YAkDEE=; b=JHdcxAbHEQN7dxqQgORwHTlZmuwikiwWK3bp9KTnyNFHyhipSuPKMZ3EnK+ACadXyt UYsWxPpdrOEq139v0LnDpxld6jfyXdqPaFmuPD2fNo5kK14KxUziq1eJdbULdGVgCN9k spJ/y0ouBAKv8y4pekrQu3TE8sZjRdsSIm8vW0htoXk2o8EAzRwvaZkz0Nhc3aNKvlEz 5FcRJaA2wda+P4LjWGhfFBu6tXQ1cDcN1NlajLE5Ul91eXOkWNAFy37YVabJXEYeaQp6 Y7PJ7W0f4H9dkYRQXrHUxuYHtt97T7fXLliSiUOzbFSyg9+WhFfZ6MCAew5U17m+93Mc 2yOA== 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=4NPruNiTZOmEOtPyLgn5BfelJiHp0PqiRMUV1YAkDEE=; b=dZgQimjjRo4K4FALufufrjitT5HSJUsL3Nj2d4DLh+J+AIjSHfZadonK59GzlxcWik bCsjFaMte1IaDyTvnkw+5EHIMaLpPZXoEOlhn2sareC9Uue9O1aDrNXUWPl1c9kLJQqS qmf2Vnsc7EkqHg/Qbk1+Ol9CVdiPzJEtuUyMHY3M7fRxHpZAezHyaIgsmQBBj0efwoa8 tsmtD30520jwlL0NMYVHrtoXr3XjgcahQMW6NZKbxGxSW3DlEP5auJCDfbIvG4dlZSO4 Z6luIlWVVZ8wylmOjR8bKpVzGbz851EaZyEWBeC2zBDyoLZZKj+ihDVvjCBDUyeoZM2f MDmg== X-Gm-Message-State: APjAAAXVs2mw+BqCW9Qk0ZAa7foZV5YGMDgBRfRgKslKOxtJM8L60het eICXx8wm/oJV3nc0nZhOOWdXNQ== X-Received: by 2002:aa7:dd8d:: with SMTP id g13mr3525527edv.290.1555582765730; Thu, 18 Apr 2019 03:19:25 -0700 (PDT) Received: from localhost.localdomain ([212.91.227.56]) by smtp.gmail.com with ESMTPSA id 31sm400479edf.18.2019.04.18.03.19.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 03:19:24 -0700 (PDT) From: Christian Brauner To: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, jannh@google.com, dhowells@redhat.com, oleg@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, cyphar@cyphar.com, joel@joelfernandes.org, dancol@google.com, Christian Brauner Subject: [PATCH v2 4/5] signal: support CLONE_PIDFD with pidfd_send_signal Date: Thu, 18 Apr 2019 12:18:40 +0200 Message-Id: <20190418101841.4476-5-christian@brauner.io> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418101841.4476-1-christian@brauner.io> References: <20190418101841.4476-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 --- /* changelog */ v1: patch unchanged v2: - Oleg Nesterov : - split s/fdget_raw()/fdget()/ into separate patch as it has nothing to do with supporting CLONE_PIDFD --- kernel/signal.c | 12 +++++++++--- kernel/sys_ni.c | 3 --- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 227ba170298e..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 @@ -3586,7 +3593,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, 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