Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp405088yba; Thu, 18 Apr 2019 03:22:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/8agMevMAC6pdH0VNxLWRoczy4nJOy8Q21TXYt4Fo21zESwdwEQkIjgmNbxZ3LDrIXy1H X-Received: by 2002:a62:ed16:: with SMTP id u22mr95441183pfh.47.1555582952110; Thu, 18 Apr 2019 03:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555582952; cv=none; d=google.com; s=arc-20160816; b=OeRDOVMJdPZW8Ac5Ls3bLETVLIfuNLufrnFWjlSd+iFPKW+cxSWgQZmXMXT2ncpJQc F8zrqtIOzSKFjHw8XbEQM8AQiRfslXLDlqzxpRRYjm1TCndX7eh+tZG9xg6fjvyZwIRm KXbJrewRWCM9g45JmcW8faQtEPldYTEmJS1+ZxiKze+kYxYYO9cvydYbJHUVR5aZAf6T u1a3REGi+t4hxX2Fcz/S0uMtNX2jdLNyWMFLMcxG4SWqfBq93izSvC5O6KJJXkGEW/FF pIu/vYfsctXRvWlSTSCXfGwDM8uoi89UQn0de80x+Lnip1OEtVCENCWeHnrYKOxfMARa LA4Q== 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=NoYfP/4JagMnvf0EArCfUuEkvYpv8x1mNHllZQwkRk4=; b=H5jpQ/cbDAYOT26SQx9FLVDjJQE4+DT++859yoER7sp864Jf6nloyBk+OsbKztwBMe PIjWG290E1xISCMmtsnTMeUPB3XP3RpwudiakPTETy+WZvzT0ecDXzA8GZz5mOfZyZV7 RK7ZAZoymaAOxTioFLfTfhp/fZh+Oi6jO4anUYsfHxX/cJerLhBJnepIxysmPKuGsLnC ISJlBUzSX8mOhrcH0gjZpJo5hZtXHBkdQquXhpIb/GEvMKh5dyjzVWI1whZIH//tWNRP X37lj76xYhkAktiX2ay2NHCaV9lBPza0I+n2Dh84KMwX+wVxpD1opjyCdeRVJsNs+AnM Lqlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=eCcTDjdQ; 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 32si1552617pgz.259.2019.04.18.03.22.16; Thu, 18 Apr 2019 03:22:32 -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=eCcTDjdQ; 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 S2388684AbfDRKTq (ORCPT + 99 others); Thu, 18 Apr 2019 06:19:46 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:34834 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388583AbfDRKT0 (ORCPT ); Thu, 18 Apr 2019 06:19:26 -0400 Received: by mail-ed1-f68.google.com with SMTP id y67so1363640ede.2 for ; Thu, 18 Apr 2019 03:19:24 -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=NoYfP/4JagMnvf0EArCfUuEkvYpv8x1mNHllZQwkRk4=; b=eCcTDjdQXg5fEhjTi8A4isM8PV6Y0S5ES1TXDDvNVfs506By59TG3tJEmhDAFISrha /ob8MkHkuSP0nI2xLuMoKc5dJMbCwkeNQ5x/t7MEGd9uOed/1GPOxERTjgBkjzbo9p+y 9mM1vO0a6RPtLxJc/UQXWpi05KsaLGhO+X7SdzBf0w8joKhP1WIgQdNNux09YVmPtPJ1 PuPRP6RlEf1tEuAgLMGgowauKz/YjTitCVvpzkBUVygDcUtqHiPD2dvsH4IClo1fErwB BYL6yURDCFsGdbGKSuxovEpcqPkjdqsRg1Y/ZwSgRSN37Uo3dCJ4aM/00rp/DJZgPvoy 3Kvg== 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=NoYfP/4JagMnvf0EArCfUuEkvYpv8x1mNHllZQwkRk4=; b=SuohsJKj9QcmAyqYXxliUsokYc99oOUHnXXi9p952tq75mmfXv3ZU8IirwqcoiOIGY B7qZqCLBAD1AeUrOTjc+DRnv9yx4I+TlqX/+liRY4TYsVoj+BYqhzjywZtNpmrMFuDEk PUEjs2iccmGzZPgNJWAKimLM9w5uKb8g1/scYEjwCV+nb21ti/XGz8CcBUQdOrKN+vpd vkYEk0ountJqranRJjWkd7lCLExGHRRke8aUZ6S22bUXvxCY5BkMVHFxosXZvt1grz0l ihKHlCCes1xYr7cfTaNWehuTup+26cYXfX+HqwCVFDiOvPa9ZMjxFoW9UIRL30PKmGMR JvGw== X-Gm-Message-State: APjAAAWIZ48N3mP1Qyg3Ajtbsk7tLZa5MldNtdlJ1tTNfUcXHn3v/7IR PCNV0yqBHmuOFjZ5c6HZqwOBdw== X-Received: by 2002:a50:fc13:: with SMTP id i19mr16678184edr.35.1555582764293; Thu, 18 Apr 2019 03:19:24 -0700 (PDT) Received: from localhost.localdomain ([212.91.227.56]) by smtp.gmail.com with ESMTPSA id 31sm400479edf.18.2019.04.18.03.19.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 03:19:23 -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 , Jann Horn Subject: [PATCH v2 3/5] signal: use fdget() since we don't allow O_PATH Date: Thu, 18 Apr 2019 12:18:39 +0200 Message-Id: <20190418101841.4476-4-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 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 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: Andy Lutomirsky Cc: Andrew Morton Cc: Oleg Nesterov Cc: Aleksa Sarai Cc: Linus Torvalds Cc: Al Viro --- /* changelog */ v1: patch not present v2: - Oleg Nesterov : - split out from following patch since the s/fdget_raw()/fdget()/ replacement is a fix unrelated to the theme of the following patch --- kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/signal.c b/kernel/signal.c index f98448cf2def..227ba170298e 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3581,7 +3581,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; -- 2.21.0