From patchwork Tue Nov 12 20:25:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13872922 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4003821A6ED for ; Tue, 12 Nov 2024 20:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443177; cv=none; b=OMgXgVGc3DBR5t7Hj6bD0HHOXiglFjUwk3C/Uf3Q13MWNvjzXO/WOEz9zXiI30ml6RjZTwdfb3RjP63ZkFZI/if+vRmBoClFcWN6cwadmIRXUAqnNCwIaUpmifyuhfJk4ezo7EniNCSgw6H9Jla0H9m8QYi3Y2JYbzIIiRfypTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443177; c=relaxed/simple; bh=d2624VP+ywx7aipu3azEcZrx5rNuDSsnLqE/FtB7nYU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UHgvo4h76FprFAdloUyU7YsxMYbMQb2fVo5CqYI4IRu3Ad3RUsQc9DtLLb62sSfci1321eNgYQtXxzHi7pTcWmnObeGsEPofxXGDNQqgbBiQgF/YteuKSFWeSMPDlAKk2tnch6StzC0oz+cF0bkLgGBaQQzne2LwWP9iV4ZEX+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=f7A0grTP; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="f7A0grTP" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=dD3C7cqJbiEbgx0ZXFHOgSog1NfLueNrI1Gl4rNE99s=; b=f7A0grTPGGMMkClxq89mJAzyET F5R1qT04IG42vGu3Icc2sWtZd/fUj4nWdtduawjBsj97RLPGXtcD8/aqy3mLWDGdcYYMuqIf/csbA u5Z4hhgKty7ud7nQsWm9+lFxcbZxFFqdAJjIDp8cJSEpLcmSzuvs54yGf9jdLtuPXpEJ4SBeApGIq E6VNtMpznC5fVNNu+taV76IwWrUtQDfwu9SsrAINjXTdePvx4kthwdijGRVyXfqdRlRsnQUev5DEM h1naDAyYjyxut+V5WJe4RqAP3iokrWr8z+9nPT48bTTtsDXSEr5SLOBJCseDSoUc+hM85GbKsSgHu K8kNSllA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1tAxSn-0000000EEsp-1zOB; Tue, 12 Nov 2024 20:26:13 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, Christian Brauner , Jan Kara , Jens Axboe Subject: [PATCH 1/5] io_statx_prep(): use getname_uflags() Date: Tue, 12 Nov 2024 20:25:48 +0000 Message-ID: <20241112202552.3393751-1-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112202118.GA3387508@ZenIV> References: <20241112202118.GA3387508@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro the only thing in flags getname_flags() ever cares about is LOOKUP_EMPTY; anything else is none of its damn business. Signed-off-by: Al Viro Reviewed-by: Christian Brauner Reviewed-by: Jens Axboe --- io_uring/statx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/io_uring/statx.c b/io_uring/statx.c index f7f9b202eec0..6bc4651700a2 100644 --- a/io_uring/statx.c +++ b/io_uring/statx.c @@ -36,8 +36,7 @@ int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) sx->buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2)); sx->flags = READ_ONCE(sqe->statx_flags); - sx->filename = getname_flags(path, - getname_statx_lookup_flags(sx->flags)); + sx->filename = getname_uflags(path, sx->flags); if (IS_ERR(sx->filename)) { int ret = PTR_ERR(sx->filename); From patchwork Tue Nov 12 20:25:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13872923 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AE33219E4F for ; Tue, 12 Nov 2024 20:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443183; cv=none; b=HijNIWtqFFeSlimKDhYBBJI7+20rylUGy+7Ev3dwLgnw49mD+yV/L8LVFenDJa+q5bA778k8zUY6hcDV9YIlkGedMKACiP5OY3K6LOzYuPAyRBds8sMScB9c8M3Ri6Mbjeq+67VwoS0s7ClP8EUYm4cZp8m3uUeRRTgozlUp+XE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443183; c=relaxed/simple; bh=dz8hAZBYlkxwUWyevfCzkusNjX0GA2HGTCKjG2qP4S0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FUpEn2UpbrrK26sCIle14L20UQROt4sKVSUrOz4jEJ6GDUQeSl4KN1rdWJfIwWvzQZeRuV+2zOLQ/yx1N8GI73cFkvRuvche+iQRP6LeM1s6zRicx+CRpfCRxTjnq+CJoMAJSCTOua8kHDKyWsAzjboxD4X9NHUTP/d2kcJWAuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=jL3gxqG8; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="jL3gxqG8" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=SntDeM1eadCkveab5L1XV2HQp4EhBxldUQDc9BWkONE=; b=jL3gxqG8j00+W5pML5YeTlJ9VO dp2N/BfIPKZhiiuUF0qyD8AOIvSuwe+8j2jNY5ene3zpEbzSkcCTPfJ2PKY63RK1saxdEBVoJ+Dsw rtcvcgAdsLhEgTTexOuijdmA7PfMGF0cIgwO7FnrnBl36P/VYrm/RK+PFxZ7vURdMn+xQ5nS6Vyja agvFyGScTvMiR8+CmDWDFDsFU+UBYKI1P2RpLbdljPHVVdwqMu2B441kC0h52/3nN+GsWjdl6kjjO w69kN2Kf9XSk17MV091+vXAYZE0hUyGCqJ4FBalbOYlpDCo/l+vvDHWejbsPdfkta4ba3uODX9cya coxwB1vA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1tAxSt-0000000EEtE-2f1p; Tue, 12 Nov 2024 20:26:19 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, Christian Brauner , Jan Kara , Jens Axboe Subject: [PATCH 2/5] kill getname_statx_lookup_flags() Date: Tue, 12 Nov 2024 20:25:49 +0000 Message-ID: <20241112202552.3393751-2-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112202552.3393751-1-viro@zeniv.linux.org.uk> References: <20241112202118.GA3387508@ZenIV> <20241112202552.3393751-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro LOOKUP_EMPTY is ignored by the only remaining user, and without that 'getname_' prefix makes no sense. Remove LOOKUP_EMPTY part, rename to statx_lookup_flags() and make static. It most likely is _not_ statx() specific, either, but that's the next step. Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/internal.h | 1 - fs/stat.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index 8c1b7acbbe8f..8cf42b327e5e 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -246,7 +246,6 @@ int open_namespace(struct ns_common *ns); * fs/stat.c: */ -int getname_statx_lookup_flags(int flags); int do_statx(int dfd, struct filename *filename, unsigned int flags, unsigned int mask, struct statx __user *buffer); int do_statx_fd(int fd, unsigned int flags, unsigned int mask, diff --git a/fs/stat.c b/fs/stat.c index b74831dc7ae6..4e8698fa932f 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -231,7 +231,7 @@ int vfs_fstat(int fd, struct kstat *stat) return error; } -int getname_statx_lookup_flags(int flags) +static int statx_lookup_flags(int flags) { int lookup_flags = 0; @@ -239,8 +239,6 @@ int getname_statx_lookup_flags(int flags) lookup_flags |= LOOKUP_FOLLOW; if (!(flags & AT_NO_AUTOMOUNT)) lookup_flags |= LOOKUP_AUTOMOUNT; - if (flags & AT_EMPTY_PATH) - lookup_flags |= LOOKUP_EMPTY; return lookup_flags; } @@ -301,7 +299,7 @@ static int vfs_statx(int dfd, struct filename *filename, int flags, struct kstat *stat, u32 request_mask) { struct path path; - unsigned int lookup_flags = getname_statx_lookup_flags(flags); + unsigned int lookup_flags = statx_lookup_flags(flags); int error; if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH | From patchwork Tue Nov 12 20:25:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13872924 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 042AC21A71D for ; Tue, 12 Nov 2024 20:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443185; cv=none; b=rzVdb2cE+6c4qbyw3el+EGB02Lu5axxZPKY8KGYfO+lpv8w5WoWsYWW8xI9X2lJp3PvpmKEi2WG765iYPR6m6IVz/a1SDVUkYolbD+V7lY3yQEegph24/Be7gVKa65hSA/rmA1ANEy6n6ze7Cj8GY+hj0TuJ+lMFoptCpP61xSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443185; c=relaxed/simple; bh=eBbQowgmRYyaltJfP56R/5mfIiOkNSnubfd9QTAwXBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jIgzm1D47OO6tXf4+NvSQidxVV7Uk5mUZRfqnr+tG8O9hTOdPq5M7X+L2M2MkXB2F2EeNqum2Qc3rdgSfJahFf5Yu1MVZxc8+ZncYF60/cKKPwghuMgNc5EKRvrasHcUDKNa/0jCrrVsBa/JIV/F4JJ3B4iMKGVxa2b6zIfeKIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=PwgjgN9O; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="PwgjgN9O" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=05Pweewsc9NU6cGHmikuv5sL6IdmphdVakYUsTgcS2k=; b=PwgjgN9OlqIzeO+iDlGrMqBB5w IL4BJdhMTG8wFNp6QIJySw8vyNvz8xgPh6XPKHCUVFWrZ4GWf350AeUEaAjV65GMA5KG8BM1ZJ0hd bL+f5lWpcj6LNVu3Lp87PyICyaqVjVzxKIk7mj9cF+WtuumfZa03Sq9E0+bGBudG2q/8v1DmBW2DX dNubX8KxuyR8O+/Rl3JMg86QOkvpQ2Wib536Mi7VFfBjxT1fqGaNMdlNiSnvlGVm26tqP4ZB8cI5X BLpbqiaZt3K4BdSxWnAzOG9KLuh/H1azbrW93CY+ZAI9RkV3pbQCHewe9Im29ukKZVHFjElm33Sa4 8xnAVw2w==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1tAxSw-0000000EEtb-2Ipi; Tue, 12 Nov 2024 20:26:22 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, Christian Brauner , Jan Kara , Jens Axboe Subject: [PATCH 3/5] fs/stat.c: switch to CLASS(fd_raw) Date: Tue, 12 Nov 2024 20:25:50 +0000 Message-ID: <20241112202552.3393751-3-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112202552.3393751-1-viro@zeniv.linux.org.uk> References: <20241112202118.GA3387508@ZenIV> <20241112202552.3393751-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro ... and use fd_empty() consistently Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/stat.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index 4e8698fa932f..855b995ad09b 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -220,15 +220,10 @@ EXPORT_SYMBOL(vfs_getattr); */ int vfs_fstat(int fd, struct kstat *stat) { - struct fd f; - int error; - - f = fdget_raw(fd); - if (!fd_file(f)) + CLASS(fd_raw, f)(fd); + if (fd_empty(f)) return -EBADF; - error = vfs_getattr(&fd_file(f)->f_path, stat, STATX_BASIC_STATS, 0); - fdput(f); - return error; + return vfs_getattr(&fd_file(f)->f_path, stat, STATX_BASIC_STATS, 0); } static int statx_lookup_flags(int flags) @@ -275,7 +270,7 @@ static int vfs_statx_fd(int fd, int flags, struct kstat *stat, u32 request_mask) { CLASS(fd_raw, f)(fd); - if (!fd_file(f)) + if (fd_empty(f)) return -EBADF; return vfs_statx_path(&fd_file(f)->f_path, flags, stat, request_mask); } From patchwork Tue Nov 12 20:25:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13872925 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B617221A4A9; Tue, 12 Nov 2024 20:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443196; cv=none; b=aNmzJWNDeiLYqhs/P8vxbcyVteRzOLiHibnT9fChlbKzLXXWRJ9eOy6ffJ0Ih/My+ezZy6j7DcrssIX6EG5yxJq4ccJH3pmhEW9y2TV9KS10hfOytzMudHxvh2rVXfsgDEicSuISs5Hr/0XwL/QiQKcSCuX18DCHkFy+OLHlPhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443196; c=relaxed/simple; bh=yN8UFcXaces+SH3gJU5MuevjL80ci2Ah0DAyvN5wrqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mqtAqTl7HdRNqxnRLQ81RCNMvteLgHWs5UZHOiIUdAW2ATByCnD7YbuOf16GymKIdoSY0etEJc7/Hv7lZlW/E2Hhn6KRQq7Ei+N48VjwzXlefGJY/52KlWu3p7t5lPtccuznVL6kRc3ntObtKvALqTQRGhXkWUPRiIh6yLCtYWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=nXxeNzPv; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="nXxeNzPv" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=dV3THfNVcbtW9+RhYLYYdBzDJtxPB+mxTPlyaLvJx18=; b=nXxeNzPvY0akJqJnu4DHVJLkcI hN3IKeMtojQL0X0xwhOHofmHTw6IA66B8K1dQM4VmZ3h9yLZwPxDI4ps6b94zV1dz+a3h1vq0U9jx ijeygOdQwnClPYE+KfLbWk0pgC75N9AK0uvy09MBz0OCJB7m4KoM+xKP3AzODLnSHDfiEZ3IHOAFH ZMyI7Z8YtM+GBAtH2md1A7FhkhlgMs33JWR3VkSsNJw5reMC2j30TYFHFekp415//Ovw416nOJKyN oa3a3zZZde9ndvg4Ei1raQuCXce2M0ZUiYJWWkjnCKKF4KDMJnbdLkRsYEe0bMMtF3kkBiBqb9obl YbKtIP+g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1tAxT6-0000000EEu9-1twz; Tue, 12 Nov 2024 20:26:32 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, Christian Brauner , Jan Kara , Jens Axboe , Stefan Berger , Tyler Hicks , ecryptfs@vger.kernel.org, Miklos Szeredi , Amir Goldstein , linux-unionfs@vger.kernel.org Subject: [PATCH 4/5] fs: Simplify getattr interface function checking AT_GETATTR_NOSEC flag Date: Tue, 12 Nov 2024 20:25:51 +0000 Message-ID: <20241112202552.3393751-4-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112202552.3393751-1-viro@zeniv.linux.org.uk> References: <20241112202118.GA3387508@ZenIV> <20241112202552.3393751-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro From: Stefan Berger Commit 8a924db2d7b5 ("fs: Pass AT_GETATTR_NOSEC flag to getattr interface function")' introduced the AT_GETATTR_NOSEC flag to ensure that the call paths only call vfs_getattr_nosec if it is set instead of vfs_getattr. Now, simplify the getattr interface functions of filesystems where the flag AT_GETATTR_NOSEC is checked. There is only a single caller of inode_operations getattr function and it is located in fs/stat.c in vfs_getattr_nosec. The caller there is the only one from which the AT_GETATTR_NOSEC flag is passed from. Two filesystems are checking this flag in .getattr and the flag is always passed to them unconditionally from only vfs_getattr_nosec: - ecryptfs: Simplify by always calling vfs_getattr_nosec in ecryptfs_getattr. From there the flag is passed to no other function and this function is not called otherwise. - overlayfs: Simplify by always calling vfs_getattr_nosec in ovl_getattr. From there the flag is passed to no other function and this function is not called otherwise. The query_flags in vfs_getattr_nosec will mask-out AT_GETATTR_NOSEC from any caller using AT_STATX_SYNC_TYPE as mask so that the flag is not important inside this function. Also, since no filesystem is checking the flag anymore, remove the flag entirely now, including the BUG_ON check that never triggered. The net change of the changes here combined with the original commit is that ecryptfs and overlayfs do not call vfs_getattr but only vfs_getattr_nosec. Fixes: 8a924db2d7b5 ("fs: Pass AT_GETATTR_NOSEC flag to getattr interface function") Reported-by: Al Viro Closes: https://lore.kernel.org/linux-fsdevel/20241101011724.GN1350452@ZenIV/T/#u Cc: Tyler Hicks Cc: ecryptfs@vger.kernel.org Cc: Miklos Szeredi Cc: Amir Goldstein Cc: linux-unionfs@vger.kernel.org Cc: Christian Brauner Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Stefan Berger Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/ecryptfs/inode.c | 12 ++---------- fs/overlayfs/inode.c | 10 +++++----- fs/overlayfs/overlayfs.h | 8 -------- fs/stat.c | 5 +---- include/uapi/linux/fcntl.h | 4 ---- 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 5ed1e4cf6c0b..644e973d5a77 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -1008,14 +1008,6 @@ static int ecryptfs_getattr_link(struct mnt_idmap *idmap, return rc; } -static int ecryptfs_do_getattr(const struct path *path, struct kstat *stat, - u32 request_mask, unsigned int flags) -{ - if (flags & AT_GETATTR_NOSEC) - return vfs_getattr_nosec(path, stat, request_mask, flags); - return vfs_getattr(path, stat, request_mask, flags); -} - static int ecryptfs_getattr(struct mnt_idmap *idmap, const struct path *path, struct kstat *stat, u32 request_mask, unsigned int flags) @@ -1024,8 +1016,8 @@ static int ecryptfs_getattr(struct mnt_idmap *idmap, struct kstat lower_stat; int rc; - rc = ecryptfs_do_getattr(ecryptfs_dentry_to_lower_path(dentry), - &lower_stat, request_mask, flags); + rc = vfs_getattr_nosec(ecryptfs_dentry_to_lower_path(dentry), + &lower_stat, request_mask, flags); if (!rc) { fsstack_copy_attr_all(d_inode(dentry), ecryptfs_inode_to_lower(d_inode(dentry))); diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 35fd3e3e1778..8b31f44c12cd 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -170,7 +170,7 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, type = ovl_path_real(dentry, &realpath); old_cred = ovl_override_creds(dentry->d_sb); - err = ovl_do_getattr(&realpath, stat, request_mask, flags); + err = vfs_getattr_nosec(&realpath, stat, request_mask, flags); if (err) goto out; @@ -195,8 +195,8 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, (!is_dir ? STATX_NLINK : 0); ovl_path_lower(dentry, &realpath); - err = ovl_do_getattr(&realpath, &lowerstat, lowermask, - flags); + err = vfs_getattr_nosec(&realpath, &lowerstat, lowermask, + flags); if (err) goto out; @@ -248,8 +248,8 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, ovl_path_lowerdata(dentry, &realpath); if (realpath.dentry) { - err = ovl_do_getattr(&realpath, &lowerdatastat, - lowermask, flags); + err = vfs_getattr_nosec(&realpath, &lowerdatastat, + lowermask, flags); if (err) goto out; } else { diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 0bfe35da4b7b..910dbbb2bb7b 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -412,14 +412,6 @@ static inline bool ovl_open_flags_need_copy_up(int flags) return ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC)); } -static inline int ovl_do_getattr(const struct path *path, struct kstat *stat, - u32 request_mask, unsigned int flags) -{ - if (flags & AT_GETATTR_NOSEC) - return vfs_getattr_nosec(path, stat, request_mask, flags); - return vfs_getattr(path, stat, request_mask, flags); -} - /* util.c */ int ovl_get_write_access(struct dentry *dentry); void ovl_put_write_access(struct dentry *dentry); diff --git a/fs/stat.c b/fs/stat.c index 855b995ad09b..011d2160b7af 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -165,7 +165,7 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, if (inode->i_op->getattr) return inode->i_op->getattr(idmap, path, stat, request_mask, - query_flags | AT_GETATTR_NOSEC); + query_flags); generic_fillattr(idmap, request_mask, inode, stat); return 0; @@ -198,9 +198,6 @@ int vfs_getattr(const struct path *path, struct kstat *stat, { int retval; - if (WARN_ON_ONCE(query_flags & AT_GETATTR_NOSEC)) - return -EPERM; - retval = security_inode_getattr(path); if (retval) return retval; diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index 87e2dec79fea..a40833bf2855 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -154,8 +154,4 @@ usable with open_by_handle_at(2). */ #define AT_HANDLE_MNT_ID_UNIQUE 0x001 /* Return the u64 unique mount ID. */ -#if defined(__KERNEL__) -#define AT_GETATTR_NOSEC 0x80000000 -#endif - #endif /* _UAPI_LINUX_FCNTL_H */ From patchwork Tue Nov 12 20:25:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13872926 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1043B21B44A for ; Tue, 12 Nov 2024 20:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443200; cv=none; b=sZ8ElDpT29lho107GVytytzsIUtqpgcc6F/NerOBpae6sffmUpi1XNuOQ+2akwrxeKDfIN4cMK3Cy5moVuRYWv2KHmTr172AxrmL0rLeYG+H5M+pHX1iGA8eMQMN93vm66IxFFraq1iaJeCShGSPmoscCbRPJfDW0wAECl2H8k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731443200; c=relaxed/simple; bh=GQXLcBOEw2jJECfb1qXu1BWYALW1j5mQH7CNElj6mUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ITD/lbeHAc6zri8w+5O6fbTXQqtOqhgMokhXlXy2jlXLbbQllAgz/eCRZiQCrMRWK8XmiW7tLt4Gooj/MMsSmv2PwWM9DUQL8JC8NDthdLWmZQW4iRf5qz1O1HqoGB5IrlpOZGF4Mlb+VOSpqZHkzfHIlNNWUxuBpI8L66Wqahk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=E7+8jNkp; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="E7+8jNkp" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=e4KgWI985IxAuGWwpcXk8SKPdzusVHJXdHLzTuAKkK0=; b=E7+8jNkp7nwOYeBuC+/CuhDHyF 4S80HJDDnDUs3BVrhLdDDyYNEDdJJTuCkCMyjy/DYURxMEAIBeqLFEmsL+YYiEpBbxwNFly/HotkN OECRahUY+s+h1GDDcXJkPt8o4BJBg/wqzpUORUraVmsMTN/jJmtAGaPKhdWPHblqlUWAG4fP6vnzz FBV7aYEHlJZC7PP1Uv9Nx/FtesF2AA6tVEjy/6du98XjzGytECAXITV42utGg5KOYTv3EqpZdGkIC feqUHFZUGEp7PVLnFPlUv1CXfJvwPxCLARMB5236fZ89+kJmVbqR3WydK+hGasVTJfX7lpb6QEfC2 kUFVsm2Q==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1tAxTB-0000000EEuO-243V; Tue, 12 Nov 2024 20:26:37 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, Christian Brauner , Jan Kara , Jens Axboe Subject: [PATCH 5/5] libfs: kill empty_dir_getattr() Date: Tue, 12 Nov 2024 20:25:52 +0000 Message-ID: <20241112202552.3393751-5-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112202552.3393751-1-viro@zeniv.linux.org.uk> References: <20241112202118.GA3387508@ZenIV> <20241112202552.3393751-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro It's used only to initialize ->getattr in one inode_operations instance (empty_dir_inode_operations) and its behaviour had always been equivalent to what we get with NULL ->getattr. Just remove that initializer, along with empty_dir_getattr() itself. While we are at it, the same instance has ->permission initialized to generic_permission, which is what NULL ->permission ends up doing. Again, no point keeping it. Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/libfs.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 46966fd8bcf9..12f5185f3fa9 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1711,15 +1711,6 @@ static struct dentry *empty_dir_lookup(struct inode *dir, struct dentry *dentry, return ERR_PTR(-ENOENT); } -static int empty_dir_getattr(struct mnt_idmap *idmap, - const struct path *path, struct kstat *stat, - u32 request_mask, unsigned int query_flags) -{ - struct inode *inode = d_inode(path->dentry); - generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat); - return 0; -} - static int empty_dir_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr) { @@ -1733,9 +1724,7 @@ static ssize_t empty_dir_listxattr(struct dentry *dentry, char *list, size_t siz static const struct inode_operations empty_dir_inode_operations = { .lookup = empty_dir_lookup, - .permission = generic_permission, .setattr = empty_dir_setattr, - .getattr = empty_dir_getattr, .listxattr = empty_dir_listxattr, };