From nobody Sun Feb 8 20:32:55 2026 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 21227359F96; Thu, 8 Jan 2026 07:40:46 +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=1767858049; cv=none; b=UlRHAVtz4JuZ8o5b/pZMYeM2gIroEVZRx05W2qSXNuw8qZg487BBKcm8Dcf/s0A5ken9o+PyffRBnlgEfR6CYTro89XdnA3RqbynDXQhSkBz81lpOT13dVstH4hVzgHdQndkvXuf0AQgCy5YzyMzNJgmM6j6XoeIPLsg2dJ6dQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858049; c=relaxed/simple; bh=m1gxaMVXLjla2krU+WSjoFNajSj/ZCwInzng15QuCN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cEvhNNudE0gEgf6be2KE6C6ZhehUeEyJ3IYcpo3xF1pdh5anCFODbxMGGSAFca1Jk2mXJVJITnz5NK/lncOmHkGY0Lpod8bMR3iX9rCNanpGQCnI2lzYVFWLN10yLlZjhZRRazjdiP1TCMWCIV4njytDpklyRqGIUlZRQF4z2Js= 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=auFntF8a; 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="auFntF8a" 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=sWF5Li2L10U6Q8O1FpOAg34mTLEVdj1sSni5eFWX330=; b=auFntF8a7ddM/R8lWEl01W7TUT i4lDiob9gjuRI68lxzVSGL4J53fSYpbh8Hs/n3Sjc0+vn1JKtugZs0spaqkQq6fA+fI5OjJw9eAAT yy6KtWz83Bnc/BB+KGIM+4AWfEJgyngiGrRZB8eweWjECjtl90Wv8BLBrlyGxNLyoz9sM0Sjd5EEA 9684B5SCV0EhifjGkW3rs0msne2UD19qt8wp4bSHWQbUbUNa3g/7MxH8xHDK6L232mFvc4v2x2ENo 8kWpms3ju8PrTdj93BiXGgcrSmq5/hFg0rcN+mhy4e/8K7utoRm7KIqudjKkXHlH2ApUhH0s0CvKe OO19Mzyg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkeg-00000001pFS-0zAt; Thu, 08 Jan 2026 07:42:02 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/8] non-consuming variant of do_renameat2() Date: Thu, 8 Jan 2026 07:41:54 +0000 Message-ID: <20260108074201.435280-2-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" filename_renameat2() replaces do_renameat2(); unlike the latter, it does not drop filename references - these days it can be just as easily arranged in the caller. Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- Documentation/filesystems/porting.rst | 8 ++++++++ fs/internal.h | 2 +- fs/namei.c | 21 +++++++++++---------- io_uring/fs.c | 7 ++++--- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 3397937ed838..577f7f952a51 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1334,3 +1334,11 @@ end_creating() and the parent will be unlocked preci= sely when necessary. =20 kill_litter_super() is gone; convert to DCACHE_PERSISTENT use (as all in-tree filesystems have done). + +--- + +**mandatory** + +do_renameat2() is gone; filename_renameat2() replaces it. The difference +is that the former used to consume filename references; the latter does +not. diff --git a/fs/internal.h b/fs/internal.h index 4c4d2733c47a..5047cfbb8c93 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -57,7 +57,7 @@ extern int filename_lookup(int dfd, struct filename *name= , unsigned flags, int do_rmdir(int dfd, struct filename *name); int do_unlinkat(int dfd, struct filename *name); int may_linkat(struct mnt_idmap *idmap, const struct path *link); -int do_renameat2(int olddfd, struct filename *oldname, int newdfd, +int filename_renameat2(int olddfd, struct filename *oldname, int newdfd, struct filename *newname, unsigned int flags); int do_mkdirat(int dfd, struct filename *name, umode_t mode); int do_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int = dev); diff --git a/fs/namei.c b/fs/namei.c index 7418a4e725da..c54beaf193e0 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -5980,11 +5980,9 @@ int vfs_rename(struct renamedata *rd) } EXPORT_SYMBOL(vfs_rename); =20 -int do_renameat2(int olddfd, struct filename *__from, int newdfd, - struct filename *__to, unsigned int flags) +int filename_renameat2(int olddfd, struct filename *from, + int newdfd, struct filename *to, unsigned int flags) { - CLASS(filename_consume, from)(__from); - CLASS(filename_consume, to)(__to); struct renamedata rd; struct path old_path, new_path; struct qstr old_last, new_last; @@ -6088,21 +6086,24 @@ int do_renameat2(int olddfd, struct filename *__fro= m, int newdfd, SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname, unsigned int, flags) { - return do_renameat2(olddfd, getname(oldname), newdfd, getname(newname), - flags); + CLASS(filename, old)(oldname); + CLASS(filename, new)(newname); + return filename_renameat2(olddfd, old, newdfd, new, flags); } =20 SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname) { - return do_renameat2(olddfd, getname(oldname), newdfd, getname(newname), - 0); + CLASS(filename, old)(oldname); + CLASS(filename, new)(newname); + return filename_renameat2(olddfd, old, newdfd, new, 0); } =20 SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *,= newname) { - return do_renameat2(AT_FDCWD, getname(oldname), AT_FDCWD, - getname(newname), 0); + CLASS(filename, old)(oldname); + CLASS(filename, new)(newname); + return filename_renameat2(AT_FDCWD, old, AT_FDCWD, new, 0); } =20 int readlink_copy(char __user *buffer, int buflen, const char *link, int l= inklen) diff --git a/io_uring/fs.c b/io_uring/fs.c index c04c6282210a..e5829d112c9e 100644 --- a/io_uring/fs.c +++ b/io_uring/fs.c @@ -82,13 +82,14 @@ int io_renameat_prep(struct io_kiocb *req, const struct= io_uring_sqe *sqe) int io_renameat(struct io_kiocb *req, unsigned int issue_flags) { struct io_rename *ren =3D io_kiocb_to_cmd(req, struct io_rename); + CLASS(filename_complete_delayed, old)(&ren->oldpath); + CLASS(filename_complete_delayed, new)(&ren->newpath); int ret; =20 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); =20 - ret =3D do_renameat2(ren->old_dfd, complete_getname(&ren->oldpath), - ren->new_dfd, complete_getname(&ren->newpath), - ren->flags); + ret =3D filename_renameat2(ren->old_dfd, old, + ren->new_dfd, new, ren->flags); =20 req->flags &=3D ~REQ_F_NEED_CLEANUP; io_req_set_res(req, ret, 0); --=20 2.47.3 From nobody Sun Feb 8 20:32:55 2026 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 64D333596ED; Thu, 8 Jan 2026 07:40:47 +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=1767858052; cv=none; b=cRHBCsb37H7oAdTH+m9vl9xi/JiG+Z/4z9y9mEg8kGiiqZKuZxATWuMRb+NRM7SwPvK2UfqzKTOHvluGr3sPNZTvcHtVbi8HidfE/3jhYl6SQCS/xa669AlBkvKCh3WHuxqmneZCWjn6wNQNXL9C52MIi6tNME8wa28RwPj59Qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858052; c=relaxed/simple; bh=jkwPdqDCuCzpLz2Phw84lK5ontai7k34YK7XKohnrjw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VDTQbvqag9d0Fc35Vb3H1JGUSaVENsaNVXWJfqqR3m81eIyJLVIyzxbU8Uvu/aYIdSbz8aXpHPJQdcM80k3qANwCAi+6w6CSTCa6alvoTdqTM95fDZPJf0dUOJfL0HEj/106PjceTorG2xxcX0BIjZhi0NCc9qYxO2b8C0b37f0= 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=qT5ZFckx; 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="qT5ZFckx" 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=f/pcKaypqceFHEPfKK+Ibfi/4eqr2qKDeXT4i6nPJGc=; b=qT5ZFckxz+D5UD9knFKpfSmoi6 Uc/4tmOuR70gjIkmEJ6hUQiYihBrN6c2WXTwjks72w3M+VULritw11RQGvXB7pYQyJptel/1ym6dH rrAMP6LnIpoDpbn3RckoNleMnHYYf76OO1hcYoJ1Hu7JL6FdolIMt6VVaB9rbk2wlNadptrad+4S1 sf0JP6xYNlSf6Hh7poDlrkRNywCokngP6hVBlVTMNnUnPuVH4AQJ8GoOweUtmx41SdASiweWuqSmE dCLLBOFY+l0qnKsenEsEYZA7noQOx9piYFsQs+Jia2+nH8vvxTcd8UeKXjGj+TSp4aUvzBMpU+Rnh qTyM1Rxg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkeg-00000001pFm-2YYu; Thu, 08 Jan 2026 07:42:02 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/8] non-consuming variant of do_linkat() Date: Thu, 8 Jan 2026 07:41:55 +0000 Message-ID: <20260108074201.435280-3-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" similar to previous commit; replacement is filename_linkat() Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- Documentation/filesystems/porting.rst | 6 +++--- fs/init.c | 5 +++-- fs/internal.h | 2 +- fs/namei.c | 17 +++++++++-------- io_uring/fs.c | 5 +++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 577f7f952a51..8ecbc41d6d82 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1339,6 +1339,6 @@ in-tree filesystems have done). =20 **mandatory** =20 -do_renameat2() is gone; filename_renameat2() replaces it. The difference -is that the former used to consume filename references; the latter does -not. +do_{link,renameat2}() are gone; filename_{link,renameat2}() replaces those. +The difference is that the former used to consume filename references; +the latter do not. diff --git a/fs/init.c b/fs/init.c index da6500d2ee98..f46e54552931 100644 --- a/fs/init.c +++ b/fs/init.c @@ -145,8 +145,9 @@ int __init init_mknod(const char *filename, umode_t mod= e, unsigned int dev) =20 int __init init_link(const char *oldname, const char *newname) { - return do_linkat(AT_FDCWD, getname_kernel(oldname), - AT_FDCWD, getname_kernel(newname), 0); + CLASS(filename_kernel, old)(oldname); + CLASS(filename_kernel, new)(newname); + return filename_linkat(AT_FDCWD, old, AT_FDCWD, new, 0); } =20 int __init init_symlink(const char *oldname, const char *newname) diff --git a/fs/internal.h b/fs/internal.h index 5047cfbb8c93..c9b70c2716d1 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -62,7 +62,7 @@ int filename_renameat2(int olddfd, struct filename *oldna= me, int newdfd, int do_mkdirat(int dfd, struct filename *name, umode_t mode); int do_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int = dev); int do_symlinkat(struct filename *from, int newdfd, struct filename *to); -int do_linkat(int olddfd, struct filename *old, int newdfd, +int filename_linkat(int olddfd, struct filename *old, int newdfd, struct filename *new, int flags); int vfs_tmpfile(struct mnt_idmap *idmap, const struct path *parentpath, diff --git a/fs/namei.c b/fs/namei.c index c54beaf193e0..1f003ac9470e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -5685,12 +5685,10 @@ EXPORT_SYMBOL(vfs_link); * We don't follow them on the oldname either to be compatible * with linux 2.0, and to avoid hard-linking to directories * and other special files. --ADM - */ -int do_linkat(int olddfd, struct filename *__old, int newdfd, - struct filename *__new, int flags) +*/ +int filename_linkat(int olddfd, struct filename *old, + int newdfd, struct filename *new, int flags) { - CLASS(filename_consume, old)(__old); - CLASS(filename_consume, new)(__new); struct mnt_idmap *idmap; struct dentry *new_dentry; struct path old_path, new_path; @@ -5756,13 +5754,16 @@ int do_linkat(int olddfd, struct filename *__old, i= nt newdfd, SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname, int, flags) { - return do_linkat(olddfd, getname_uflags(oldname, flags), - newdfd, getname(newname), flags); + CLASS(filename_uflags, old)(oldname, flags); + CLASS(filename, new)(newname); + return filename_linkat(olddfd, old, newdfd, new, flags); } =20 SYSCALL_DEFINE2(link, const char __user *, oldname, const char __user *, n= ewname) { - return do_linkat(AT_FDCWD, getname(oldname), AT_FDCWD, getname(newname), = 0); + CLASS(filename, old)(oldname); + CLASS(filename, new)(newname); + return filename_linkat(AT_FDCWD, old, AT_FDCWD, new, 0); } =20 /** diff --git a/io_uring/fs.c b/io_uring/fs.c index e5829d112c9e..e39cd1ca1942 100644 --- a/io_uring/fs.c +++ b/io_uring/fs.c @@ -280,12 +280,13 @@ int io_linkat_prep(struct io_kiocb *req, const struct= io_uring_sqe *sqe) int io_linkat(struct io_kiocb *req, unsigned int issue_flags) { struct io_link *lnk =3D io_kiocb_to_cmd(req, struct io_link); + CLASS(filename_complete_delayed, old)(&lnk->oldpath); + CLASS(filename_complete_delayed, new)(&lnk->newpath); int ret; =20 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); =20 - ret =3D do_linkat(lnk->old_dfd, complete_getname(&lnk->oldpath), - lnk->new_dfd, complete_getname(&lnk->newpath), lnk->flags); + ret =3D filename_linkat(lnk->old_dfd, old, lnk->new_dfd, new, lnk->flags); =20 req->flags &=3D ~REQ_F_NEED_CLEANUP; io_req_set_res(req, ret, 0); --=20 2.47.3 From nobody Sun Feb 8 20:32:55 2026 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 BCA08358D2A; Thu, 8 Jan 2026 07:40:47 +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=1767858050; cv=none; b=L3KjV1jh2wQyEsFpR+gD3LQrjZO5yfLyUJPu//XM2Vvo6yP6p0KtGf3d8tywufyBqdtburRemprDJEuEZjQXLpPAWybkMEnYRWmpSV/sUEtT08R8kId8m2msSI42LITfB7JTFGHCSIcAZD6FCYjg3v8Szjc3ceNx4MjtL9TZlgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858050; c=relaxed/simple; bh=leubmykB72bFyFYFv1vCavUwDsqB4Ig52/6Yn54CKFU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NDVV+71bnXsLR4JIIaNNdkKpfqgNC7hjBoNpqhVY6u5UWToiQm37+MwyNuoWNkI5AjdTI3DaGCYxFJvhVYQzrL5562v1nZV/dDNBMPotYl0UZHRb3iOlL3OKqUaXgwr/eijxLraCeWNJLTwj5MOYemNLwO3Pai+8qFEj+a9XLpE= 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=mTLiShWx; 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="mTLiShWx" 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=EJN4KixNtyjOJLNsHsMCjr0MU8HqNHsUlayBGko7Et0=; b=mTLiShWxgiIEG5cNXbyZdzNw3U lOBGxLeYN1122PVFu7NUcCLpJF1iKBXhMobUMIOA2ZVO9eTNXFnShgROTJ/ljWPVZbyi1gXYd+Cqf lAVI22s3jasCXxDvZD7o8FEG2IBxjWxe4GdjJTs9QX7dg9d9kJWOQR2Smt0sRy3lJ+JaNC3znbvvB 6yJNRg/gA8r54arVIepQSbS0oXunlDZEXA0zUs2b+U/zIGjNqpj0t/+EwczPYcx3kx9YixDA3AMoi mHVNs/2Oc7o/9hggaWupi5Rd8HhqFvI/D6VMrA5xbn+oO5RdqT75wUMEAKCTdASXA8mkDE6lfc//C WtcBhhSQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkeg-00000001pFx-38c6; Thu, 08 Jan 2026 07:42:02 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/8] non-consuming variant of do_symlinkat() Date: Thu, 8 Jan 2026 07:41:56 +0000 Message-ID: <20260108074201.435280-4-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" similar to previous commit; replacement is filename_symlinkat() Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- Documentation/filesystems/porting.rst | 6 +++--- fs/init.c | 5 +++-- fs/internal.h | 2 +- fs/namei.c | 12 +++++++----- io_uring/fs.c | 5 +++-- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 8ecbc41d6d82..c44c351bc297 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1339,6 +1339,6 @@ in-tree filesystems have done). =20 **mandatory** =20 -do_{link,renameat2}() are gone; filename_{link,renameat2}() replaces those. -The difference is that the former used to consume filename references; -the latter do not. +do_{link,symlink,renameat2}() are gone; filename_...() counterparts +replace those. The difference is that the former used to consume +filename references; the latter do not. diff --git a/fs/init.c b/fs/init.c index f46e54552931..a54ef750ffe3 100644 --- a/fs/init.c +++ b/fs/init.c @@ -152,8 +152,9 @@ int __init init_link(const char *oldname, const char *n= ewname) =20 int __init init_symlink(const char *oldname, const char *newname) { - return do_symlinkat(getname_kernel(oldname), AT_FDCWD, - getname_kernel(newname)); + CLASS(filename_kernel, old)(oldname); + CLASS(filename_kernel, new)(newname); + return filename_symlinkat(old, AT_FDCWD, new); } =20 int __init init_unlink(const char *pathname) diff --git a/fs/internal.h b/fs/internal.h index c9b70c2716d1..4a63b89c02d7 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -61,7 +61,7 @@ int filename_renameat2(int olddfd, struct filename *oldna= me, int newdfd, struct filename *newname, unsigned int flags); int do_mkdirat(int dfd, struct filename *name, umode_t mode); int do_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int = dev); -int do_symlinkat(struct filename *from, int newdfd, struct filename *to); +int filename_symlinkat(struct filename *from, int newdfd, struct filename = *to); int filename_linkat(int olddfd, struct filename *old, int newdfd, struct filename *new, int flags); int vfs_tmpfile(struct mnt_idmap *idmap, diff --git a/fs/namei.c b/fs/namei.c index 1f003ac9470e..338e2934c520 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -5541,10 +5541,8 @@ int vfs_symlink(struct mnt_idmap *idmap, struct inod= e *dir, } EXPORT_SYMBOL(vfs_symlink); =20 -int do_symlinkat(struct filename *__from, int newdfd, struct filename *__t= o) +int filename_symlinkat(struct filename *from, int newdfd, struct filename = *to) { - CLASS(filename_consume, from)(__from); - CLASS(filename_consume, to)(__to); int error; struct dentry *dentry; struct path path; @@ -5578,12 +5576,16 @@ int do_symlinkat(struct filename *__from, int newdf= d, struct filename *__to) SYSCALL_DEFINE3(symlinkat, const char __user *, oldname, int, newdfd, const char __user *, newname) { - return do_symlinkat(getname(oldname), newdfd, getname(newname)); + CLASS(filename, old)(oldname); + CLASS(filename, new)(newname); + return filename_symlinkat(old, newdfd, new); } =20 SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *= , newname) { - return do_symlinkat(getname(oldname), AT_FDCWD, getname(newname)); + CLASS(filename, old)(oldname); + CLASS(filename, new)(newname); + return filename_symlinkat(old, AT_FDCWD, new); } =20 /** diff --git a/io_uring/fs.c b/io_uring/fs.c index e39cd1ca1942..cd4d88d37795 100644 --- a/io_uring/fs.c +++ b/io_uring/fs.c @@ -233,12 +233,13 @@ int io_symlinkat_prep(struct io_kiocb *req, const str= uct io_uring_sqe *sqe) int io_symlinkat(struct io_kiocb *req, unsigned int issue_flags) { struct io_link *sl =3D io_kiocb_to_cmd(req, struct io_link); + CLASS(filename_complete_delayed, old)(&sl->oldpath); + CLASS(filename_complete_delayed, new)(&sl->newpath); int ret; =20 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); =20 - ret =3D do_symlinkat(complete_getname(&sl->oldpath), sl->new_dfd, - complete_getname(&sl->newpath)); + ret =3D filename_symlinkat(old, sl->new_dfd, new); =20 req->flags &=3D ~REQ_F_NEED_CLEANUP; io_req_set_res(req, ret, 0); --=20 2.47.3 From nobody Sun Feb 8 20:32:55 2026 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 A1338359FAD; Thu, 8 Jan 2026 07:40:48 +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=1767858052; cv=none; b=ogYHuADXN3umqSvlmI2OnjsYBgEKujtjcgmIDLiXF8VETVBuJgK5HcELEFvMtlB+Ny6lWSLev8++vA6A3mt5hhC/NelJ2EmibnrhDY6iuYKT0y4CW24p2zG+oVOX3H6oLPHr6jRIgPAPoIMg8Eb5smnJdWIWS2PYu/VW/9soOb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858052; c=relaxed/simple; bh=fcxK99omi71ZX5/vGICEMfV9f5uRJvbTSEl8O7XJD4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tYW2dap28tSUJWpJiBhx/vNIzoinGzYzBtp97CRfcU5S6y25qiGoT5SeduatDL8Pk3Qbyo9iEcQXepm0kRMioZqTnRikif6FiFcTkiXwuAcmG1DFA80ZAc5Q73OQZ1mbzrfwuJBwuEgc0+h5Y3E6CXm93KFKMylGFbthbirHLwo= 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=YtuuawKP; 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="YtuuawKP" 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=pgDVY/Wqivs0D0jtpgR/Ursc2PaFW0/C2mD54qOQgy4=; b=YtuuawKPFgpAj1ZU4OttR1lMI4 VUe73VDlm/5uNoCsmedkoSrGYbHq7+H7DVf/i0F648z/qfWeaQw4GC1HpCCNjw2bIr7dcYesnSCoG UR1u0k/HmWAf7Q0Z8yevsik2e51Mwo5H0dfZI/6BzksYohLMcHrFQhZv/hGk3QjTLhWFNhLPSFeO5 HIgauzH8URBiaLRXGzeRuj/5NCcmSEI9h4AaLSy0tGUSCtrCWlbaWWBmNlAgMnGH1/CRhm8ixEkMb 0zXMZWQkjWdwEp2Rn4GcdevIsFXwOMCKnJzrfiVZpbPm0sv//usm32cecKYyASgu+vyuDRzoJ7cY7 qfOnc+sw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkeh-00000001pGJ-0MiZ; Thu, 08 Jan 2026 07:42:03 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/8] non-consuming variant of do_mkdirat() Date: Thu, 8 Jan 2026 07:41:57 +0000 Message-ID: <20260108074201.435280-5-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" similar to previous commit; replacement is filename_mkdirat() Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- Documentation/filesystems/porting.rst | 2 +- fs/init.c | 3 ++- fs/internal.h | 2 +- fs/namei.c | 9 +++++---- io_uring/fs.c | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index c44c351bc297..ace0607fe39c 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1339,6 +1339,6 @@ in-tree filesystems have done). =20 **mandatory** =20 -do_{link,symlink,renameat2}() are gone; filename_...() counterparts +do_{mkdir,link,symlink,renameat2}() are gone; filename_...() counterparts replace those. The difference is that the former used to consume filename references; the latter do not. diff --git a/fs/init.c b/fs/init.c index a54ef750ffe3..9a550ba4802f 100644 --- a/fs/init.c +++ b/fs/init.c @@ -164,7 +164,8 @@ int __init init_unlink(const char *pathname) =20 int __init init_mkdir(const char *pathname, umode_t mode) { - return do_mkdirat(AT_FDCWD, getname_kernel(pathname), mode); + CLASS(filename_kernel, name)(pathname); + return filename_mkdirat(AT_FDCWD, name, mode); } =20 int __init init_rmdir(const char *pathname) diff --git a/fs/internal.h b/fs/internal.h index 4a63b89c02d7..03638008d84a 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -59,7 +59,7 @@ int do_unlinkat(int dfd, struct filename *name); int may_linkat(struct mnt_idmap *idmap, const struct path *link); int filename_renameat2(int olddfd, struct filename *oldname, int newdfd, struct filename *newname, unsigned int flags); -int do_mkdirat(int dfd, struct filename *name, umode_t mode); +int filename_mkdirat(int dfd, struct filename *name, umode_t mode); int do_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int = dev); int filename_symlinkat(struct filename *from, int newdfd, struct filename = *to); int filename_linkat(int olddfd, struct filename *old, int newdfd, diff --git a/fs/namei.c b/fs/namei.c index 338e2934c520..e3252d4abce4 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -5171,9 +5171,8 @@ struct dentry *vfs_mkdir(struct mnt_idmap *idmap, str= uct inode *dir, } EXPORT_SYMBOL(vfs_mkdir); =20 -int do_mkdirat(int dfd, struct filename *__name, umode_t mode) +int filename_mkdirat(int dfd, struct filename *name, umode_t mode) { - CLASS(filename_consume, name)(__name); struct dentry *dentry; struct path path; int error; @@ -5208,12 +5207,14 @@ int do_mkdirat(int dfd, struct filename *__name, um= ode_t mode) =20 SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t,= mode) { - return do_mkdirat(dfd, getname(pathname), mode); + CLASS(filename, name)(pathname); + return filename_mkdirat(dfd, name, mode); } =20 SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode) { - return do_mkdirat(AT_FDCWD, getname(pathname), mode); + CLASS(filename, name)(pathname); + return filename_mkdirat(AT_FDCWD, name, mode); } =20 /** diff --git a/io_uring/fs.c b/io_uring/fs.c index cd4d88d37795..40541b539e0d 100644 --- a/io_uring/fs.c +++ b/io_uring/fs.c @@ -182,11 +182,12 @@ int io_mkdirat_prep(struct io_kiocb *req, const struc= t io_uring_sqe *sqe) int io_mkdirat(struct io_kiocb *req, unsigned int issue_flags) { struct io_mkdir *mkd =3D io_kiocb_to_cmd(req, struct io_mkdir); + CLASS(filename_complete_delayed, name)(&mkd->filename); int ret; =20 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); =20 - ret =3D do_mkdirat(mkd->dfd, complete_getname(&mkd->filename), mkd->mode); + ret =3D filename_mkdirat(mkd->dfd, name, mkd->mode); =20 req->flags &=3D ~REQ_F_NEED_CLEANUP; io_req_set_res(req, ret, 0); --=20 2.47.3 From nobody Sun Feb 8 20:32:55 2026 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 A17A0359FAF; Thu, 8 Jan 2026 07:40:48 +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=1767858051; cv=none; b=VEs3pferbl/unzqMJiERtxZzLPnqak20XV5rWM9ZIETNbK8BXYgSH9SiZ2vBtqzn/gG/gbcLr/FQmjlDsU01kkvlAi4Dx6pfGFWaP25uG98qevuNXJGtL6Y3nFFrBTx9mCWu3zaCpRsZjKB2m44jggZ+YmvGQxFFyZDjc4Get0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858051; c=relaxed/simple; bh=QKH/VHjmimuM2elpWlBC6NTasYCowfM7G0/nY8QEgfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PePKmalABcMoGBMmpnhGBXmMaXVGw7mKnZb5yawitgCJBacr9xkE2MtLLg7euASK1xWimvAzlOeE9mJCaUwx+2cSgrGkN1z+KWuzQaTns+3++OW6JeGflCkkEtKRic5h4+pkZowmJp+FseMtyyRComl6nEu3vxGdMKq4Nm3PDhc= 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=UMUIKYQU; 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="UMUIKYQU" 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=/xK9ccOp9W934T9AOt1ksaAZDsego1UZsXXZaN3Rosk=; b=UMUIKYQU5CmVXwKeaogQCx7jwD k5bhcmjj0LxDLwMXUh1jHcH+IZ9oIeRs2VGSWlYqExPuH2hRl0w9FLDZN/seAbvZrE7g92Dqt2b7+ Dh/PPsud7usKwBN0JwjD/bS/NwjLSvoEBk4DBXbkZ8WYCIELMnlfUfXmNVwsPP79gGulgQE9ryhAn WooHz3KLhczjoqBQwYk1NZfbN0i+tzSPDcNfGdkkOIA/vAiw1odVv0HmrScBdtiBCSoVSxtSZnRLI H+rVy56VJBFqyhiRPHsCKTSINw3hD+/GS/DLqMlQpoGiTA3HXDml7IhJr0S3uPoq4QgDd52gRC4yG GvblqNQw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkeh-00000001pGj-1lf7; Thu, 08 Jan 2026 07:42:03 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/8] non-consuming variant of do_mknodat() Date: Thu, 8 Jan 2026 07:41:58 +0000 Message-ID: <20260108074201.435280-6-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" similar to previous commit; replacement is filename_mknodat() Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- Documentation/filesystems/porting.rst | 6 +++--- fs/init.c | 3 ++- fs/internal.h | 2 +- fs/namei.c | 11 ++++++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index ace0607fe39c..7e68a148dd1e 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1339,6 +1339,6 @@ in-tree filesystems have done). =20 **mandatory** =20 -do_{mkdir,link,symlink,renameat2}() are gone; filename_...() counterparts -replace those. The difference is that the former used to consume -filename references; the latter do not. +do_{mkdir,mknod,link,symlink,renameat2}() are gone; filename_...() +counterparts replace those. The difference is that the former used +to consume filename references; the latter do not. diff --git a/fs/init.c b/fs/init.c index 9a550ba4802f..543444c1d79e 100644 --- a/fs/init.c +++ b/fs/init.c @@ -140,7 +140,8 @@ int __init init_stat(const char *filename, struct kstat= *stat, int flags) =20 int __init init_mknod(const char *filename, umode_t mode, unsigned int dev) { - return do_mknodat(AT_FDCWD, getname_kernel(filename), mode, dev); + CLASS(filename_kernel, name)(filename); + return filename_mknodat(AT_FDCWD, name, mode, dev); } =20 int __init init_link(const char *oldname, const char *newname) diff --git a/fs/internal.h b/fs/internal.h index 03638008d84a..02b5dec13ff3 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -60,7 +60,7 @@ int may_linkat(struct mnt_idmap *idmap, const struct path= *link); int filename_renameat2(int olddfd, struct filename *oldname, int newdfd, struct filename *newname, unsigned int flags); int filename_mkdirat(int dfd, struct filename *name, umode_t mode); -int do_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int = dev); +int filename_mknodat(int dfd, struct filename *name, umode_t mode, unsigne= d int dev); int filename_symlinkat(struct filename *from, int newdfd, struct filename = *to); int filename_linkat(int olddfd, struct filename *old, int newdfd, struct filename *new, int flags); diff --git a/fs/namei.c b/fs/namei.c index e3252d4abce4..1aa19dde50e4 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -5038,10 +5038,9 @@ static int may_mknod(umode_t mode) } } =20 -int do_mknodat(int dfd, struct filename *__name, umode_t mode, - unsigned int dev) +int filename_mknodat(int dfd, struct filename *name, umode_t mode, + unsigned int dev) { - CLASS(filename_consume, name)(__name); struct delegated_inode di =3D { }; struct mnt_idmap *idmap; struct dentry *dentry; @@ -5095,12 +5094,14 @@ int do_mknodat(int dfd, struct filename *__name, um= ode_t mode, SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t,= mode, unsigned int, dev) { - return do_mknodat(dfd, getname(filename), mode, dev); + CLASS(filename, name)(filename); + return filename_mknodat(dfd, name, mode, dev); } =20 SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsig= ned, dev) { - return do_mknodat(AT_FDCWD, getname(filename), mode, dev); + CLASS(filename, name)(filename); + return filename_mknodat(AT_FDCWD, name, mode, dev); } =20 /** --=20 2.47.3 From nobody Sun Feb 8 20:32:55 2026 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 A1DDA359FB0; Thu, 8 Jan 2026 07:40:48 +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=1767858052; cv=none; b=E79hXzWdTNZIUzXKQ646n6amDCX304BzcQZV/0v7rzeD99vzsmeLxID4wAObCNfWi5vnhFyKHVgGSLpQw9gNJOgO4okU462cVm5ISx+Vo117Z5iaaZcRUoqjLRJjTOHUjilcb66wMpLkvQy0YBhTVMoxQrh5Bd+h+xPSrhV6tmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858052; c=relaxed/simple; bh=RLE6cYBOmecz8ThObxPKrJavV5HxVpo51hQfHRxANaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PwQiY2KDvEAqZ0RMAemx7ldZapEA93BlIYaQit7ECQABT21K2QaecjYMd4amBNu74jjCl96QXyAHDHqjbvyvcQIDGy7QvjTlc6GKjS55jLE71vKuHpP5aoteQ6jIvpLtGy3lWDw88wxsn6Yu2nwy+j3EoxEG8GgazIxB7wIXlBs= 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=cHZoLiSk; 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="cHZoLiSk" 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=QEG7CrTkV6vj/sLksys6/DKX0L1lzK+giJ8dBT8N0WU=; b=cHZoLiSk5pn0XEsY8oWl5/zxJe jvxCf9faPZnY/B0kUQuLnl2slrzQ+qmYoUs1/4Q+bo9jxIV71VbdWxOlWxYNGL/L+vpU/1uwBjiRe WJDEIvZAAs4k17DAxzEe6GJ36ieBaVBB7ZgFaWVQyDJq/C5RGEP2I13rpHjWWxQsu6/okgbqVjaXL auS1rOfaGvA3H6P/VrKkb7iq43A7+1fdCWal6Wd3SHc8kux6ahzQ0/kxf+ovT4hZ08hO7nhssj0J6 gUZz1hmO9gGD5T/xiaipmZoIXws2JRkrf6IkkBUcfBSuqTtlp/k7R9p+X1UVx49h6zj+ImdPrvVHk gAcckIaQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkeh-00000001pGv-2DNO; Thu, 08 Jan 2026 07:42:03 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/8] non-consuming variants of do_{unlinkat,rmdir}() Date: Thu, 8 Jan 2026 07:41:59 +0000 Message-ID: <20260108074201.435280-7-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" similar to previous commit; replacements are filename_{unlinkat,rmdir}() Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- Documentation/filesystems/porting.rst | 6 +++--- fs/coredump.c | 3 ++- fs/init.c | 6 ++++-- fs/internal.h | 4 ++-- fs/namei.c | 17 +++++++++-------- io_uring/fs.c | 5 +++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 7e68a148dd1e..2b4dddfe6c66 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1339,6 +1339,6 @@ in-tree filesystems have done). =20 **mandatory** =20 -do_{mkdir,mknod,link,symlink,renameat2}() are gone; filename_...() -counterparts replace those. The difference is that the former used -to consume filename references; the latter do not. +do_{mkdir,mknod,link,symlink,renameat2,rmdir,unlink}() are gone; filename_= ...() +counterparts replace those. The difference is that the former used to con= sume +filename references; the latter do not. diff --git a/fs/coredump.c b/fs/coredump.c index 8feb9c1cf83d..d9597610a6ca 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -895,11 +895,12 @@ static bool coredump_file(struct core_name *cn, struc= t coredump_params *cprm, * privs and don't want to unlink another user's coredump. */ if (!coredump_force_suid_safe(cprm)) { + CLASS(filename_kernel, name)(cn->corename); /* * If it doesn't exist, that's fine. If there's some * other problem, we'll catch it at the filp_open(). */ - do_unlinkat(AT_FDCWD, getname_kernel(cn->corename)); + filename_unlinkat(AT_FDCWD, name); } =20 /* diff --git a/fs/init.c b/fs/init.c index 543444c1d79e..ea528b020cd1 100644 --- a/fs/init.c +++ b/fs/init.c @@ -160,7 +160,8 @@ int __init init_symlink(const char *oldname, const char= *newname) =20 int __init init_unlink(const char *pathname) { - return do_unlinkat(AT_FDCWD, getname_kernel(pathname)); + CLASS(filename_kernel, name)(pathname); + return filename_unlinkat(AT_FDCWD, name); } =20 int __init init_mkdir(const char *pathname, umode_t mode) @@ -171,7 +172,8 @@ int __init init_mkdir(const char *pathname, umode_t mod= e) =20 int __init init_rmdir(const char *pathname) { - return do_rmdir(AT_FDCWD, getname_kernel(pathname)); + CLASS(filename_kernel, name)(pathname); + return filename_rmdir(AT_FDCWD, name); } =20 int __init init_utimes(char *filename, struct timespec64 *ts) diff --git a/fs/internal.h b/fs/internal.h index 02b5dec13ff3..4821f8b8fdda 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -54,8 +54,8 @@ extern int finish_clean_context(struct fs_context *fc); */ extern int filename_lookup(int dfd, struct filename *name, unsigned flags, struct path *path, const struct path *root); -int do_rmdir(int dfd, struct filename *name); -int do_unlinkat(int dfd, struct filename *name); +int filename_rmdir(int dfd, struct filename *name); +int filename_unlinkat(int dfd, struct filename *name); int may_linkat(struct mnt_idmap *idmap, const struct path *link); int filename_renameat2(int olddfd, struct filename *oldname, int newdfd, struct filename *newname, unsigned int flags); diff --git a/fs/namei.c b/fs/namei.c index 1aa19dde50e4..42b33bb0f892 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -5278,9 +5278,8 @@ int vfs_rmdir(struct mnt_idmap *idmap, struct inode *= dir, } EXPORT_SYMBOL(vfs_rmdir); =20 -int do_rmdir(int dfd, struct filename *__name) +int filename_rmdir(int dfd, struct filename *name) { - CLASS(filename_consume, name)(__name); int error; struct dentry *dentry; struct path path; @@ -5338,7 +5337,8 @@ int do_rmdir(int dfd, struct filename *__name) =20 SYSCALL_DEFINE1(rmdir, const char __user *, pathname) { - return do_rmdir(AT_FDCWD, getname(pathname)); + CLASS(filename, name)(pathname); + return filename_rmdir(AT_FDCWD, name); } =20 /** @@ -5420,9 +5420,8 @@ EXPORT_SYMBOL(vfs_unlink); * writeout happening, and we don't want to prevent access to the directory * while waiting on the I/O. */ -int do_unlinkat(int dfd, struct filename *__name) +int filename_unlinkat(int dfd, struct filename *name) { - CLASS(filename_consume, name)(__name); int error; struct dentry *dentry; struct path path; @@ -5489,14 +5488,16 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __us= er *, pathname, int, flag) if ((flag & ~AT_REMOVEDIR) !=3D 0) return -EINVAL; =20 + CLASS(filename, name)(pathname); if (flag & AT_REMOVEDIR) - return do_rmdir(dfd, getname(pathname)); - return do_unlinkat(dfd, getname(pathname)); + return filename_rmdir(dfd, name); + return filename_unlinkat(dfd, name); } =20 SYSCALL_DEFINE1(unlink, const char __user *, pathname) { - return do_unlinkat(AT_FDCWD, getname(pathname)); + CLASS(filename, name)(pathname); + return filename_unlinkat(AT_FDCWD, name); } =20 /** diff --git a/io_uring/fs.c b/io_uring/fs.c index 40541b539e0d..d0580c754bf8 100644 --- a/io_uring/fs.c +++ b/io_uring/fs.c @@ -134,14 +134,15 @@ int io_unlinkat_prep(struct io_kiocb *req, const stru= ct io_uring_sqe *sqe) int io_unlinkat(struct io_kiocb *req, unsigned int issue_flags) { struct io_unlink *un =3D io_kiocb_to_cmd(req, struct io_unlink); + CLASS(filename_complete_delayed, name)(&un->filename); int ret; =20 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); =20 if (un->flags & AT_REMOVEDIR) - ret =3D do_rmdir(un->dfd, complete_getname(&un->filename)); + ret =3D filename_rmdir(un->dfd, name); else - ret =3D do_unlinkat(un->dfd, complete_getname(&un->filename)); + ret =3D filename_unlinkat(un->dfd, name); =20 req->flags &=3D ~REQ_F_NEED_CLEANUP; io_req_set_res(req, ret, 0); --=20 2.47.3 From nobody Sun Feb 8 20:32:55 2026 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 A08E9359FA9; Thu, 8 Jan 2026 07:40:48 +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=1767858052; cv=none; b=QweKkijBrO5tdS2efXA+Cp9lTmvhaVLbXBTtarhOiLIMDxpHSvcZFsTjtCVsOfwL0Ezdy8mpB+NquXjT5JIYsdZ1J6mQC0SiOfMFX/1UrguB1SQr+IyGxHvznzrVsRZjY+STwb4N6PvxjzV5h59Ros5eeQ87O6+aAxprNwTB4fU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858052; c=relaxed/simple; bh=7LPhhj5IsozaA6yrMzSUNTnp+kwn2SaqLUWClhf7DUk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AAqwQHSGtz/ZWFb8oP4oK4G5NMRyKtKHHVUKT9vRSffgk0kfLyY0FdWDB1BfVL+nGE18JZvyYLsBibQgBPJZVuiJd4e22kMemwOcA1XmTihMNCyu2QD/Bd5sA4CbY3jaBQxrRm7jTUNBWrNeQtPzguekyww0Gav2aDffmGZ8khA= 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=msEkBD12; 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="msEkBD12" 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=zD3kiYRGctHzh4A2P9AGiCndO4lLbN2+6+4Iwm7Yc98=; b=msEkBD12l/06upOy/bTdMDK+Ar kYxqJP/FR41rW6cMY/XMOv6RP+EYz/0FZ9RRtzRygiwbcQto/t9z6XuNm8I0NMGkrK2hcCaIK8A4+ /OvbvNw+yPOAaIVAIV97U4mN3k+b582nVoOxdtHQYoq/7CAmIpD9QYN5tLoFoIwLfvf7P7YdxcAPQ 8FTjQdrvJrFWM14LwQNNgYN4a8aNCXOkk3dsoqoe2i/tUYwTs2mbPDVzqxdQOEQWtDXygLJo8WCZg g5EZCJeOsE9SL7djNPqqFneck9eYQqJRPCMwOa6ZZ5sBG4K2GvtdcVNvDoNmvXKu9bjpVoGQBqQaZ SKaYWiMg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkeh-00000001pHF-3Ddb; Thu, 08 Jan 2026 07:42:03 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 7/8] execve: fold {compat_,}do_execve{,at}() into their sole callers Date: Thu, 8 Jan 2026 07:42:00 +0000 Message-ID: <20260108074201.435280-8-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" All of them are wrappers for do_execveat_common() and each has exactly one caller. The only difference is in the way they are constructing argv/envp arguments for do_execveat_common() and that's easy to do with less boilerplate. Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/exec.c | 80 +++++++++++++------------------------------------------ 1 file changed, 19 insertions(+), 61 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 902561a878ff..4e192d7b7e71 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1893,59 +1893,6 @@ int kernel_execve(const char *kernel_filename, return bprm_execve(bprm); } =20 -static int do_execve(struct filename *filename, - const char __user *const __user *__argv, - const char __user *const __user *__envp) -{ - struct user_arg_ptr argv =3D { .ptr.native =3D __argv }; - struct user_arg_ptr envp =3D { .ptr.native =3D __envp }; - return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); -} - -static int do_execveat(int fd, struct filename *filename, - const char __user *const __user *__argv, - const char __user *const __user *__envp, - int flags) -{ - struct user_arg_ptr argv =3D { .ptr.native =3D __argv }; - struct user_arg_ptr envp =3D { .ptr.native =3D __envp }; - - return do_execveat_common(fd, filename, argv, envp, flags); -} - -#ifdef CONFIG_COMPAT -static int compat_do_execve(struct filename *filename, - const compat_uptr_t __user *__argv, - const compat_uptr_t __user *__envp) -{ - struct user_arg_ptr argv =3D { - .is_compat =3D true, - .ptr.compat =3D __argv, - }; - struct user_arg_ptr envp =3D { - .is_compat =3D true, - .ptr.compat =3D __envp, - }; - return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); -} - -static int compat_do_execveat(int fd, struct filename *filename, - const compat_uptr_t __user *__argv, - const compat_uptr_t __user *__envp, - int flags) -{ - struct user_arg_ptr argv =3D { - .is_compat =3D true, - .ptr.compat =3D __argv, - }; - struct user_arg_ptr envp =3D { - .is_compat =3D true, - .ptr.compat =3D __envp, - }; - return do_execveat_common(fd, filename, argv, envp, flags); -} -#endif - void set_binfmt(struct linux_binfmt *new) { struct mm_struct *mm =3D current->mm; @@ -1970,12 +1917,18 @@ void set_dumpable(struct mm_struct *mm, int value) __mm_flags_set_mask_dumpable(mm, value); } =20 +static inline struct user_arg_ptr native_arg(const char __user *const __us= er *p) +{ + return (struct user_arg_ptr){.ptr.native =3D p}; +} + SYSCALL_DEFINE3(execve, const char __user *, filename, const char __user *const __user *, argv, const char __user *const __user *, envp) { - return do_execve(getname(filename), argv, envp); + return do_execveat_common(AT_FDCWD, getname(filename), + native_arg(argv), native_arg(envp), 0); } =20 SYSCALL_DEFINE5(execveat, @@ -1984,17 +1937,23 @@ SYSCALL_DEFINE5(execveat, const char __user *const __user *, envp, int, flags) { - return do_execveat(fd, - getname_uflags(filename, flags), - argv, envp, flags); + return do_execveat_common(fd, getname_uflags(filename, flags), + native_arg(argv), native_arg(envp), flags); } =20 #ifdef CONFIG_COMPAT + +static inline struct user_arg_ptr compat_arg(const compat_uptr_t __user *p) +{ + return (struct user_arg_ptr){.is_compat =3D true, .ptr.compat =3D p}; +} + COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename, const compat_uptr_t __user *, argv, const compat_uptr_t __user *, envp) { - return compat_do_execve(getname(filename), argv, envp); + return do_execveat_common(AT_FDCWD, getname(filename), + compat_arg(argv), compat_arg(envp), 0); } =20 COMPAT_SYSCALL_DEFINE5(execveat, int, fd, @@ -2003,9 +1962,8 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd, const compat_uptr_t __user *, envp, int, flags) { - return compat_do_execveat(fd, - getname_uflags(filename, flags), - argv, envp, flags); + return do_execveat_common(fd, getname_uflags(filename, flags), + compat_arg(argv), compat_arg(envp), flags); } #endif =20 --=20 2.47.3 From nobody Sun Feb 8 20:32:55 2026 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 A0CB0359FAC; Thu, 8 Jan 2026 07:40:48 +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=1767858052; cv=none; b=vBy7W6dPq7mmueHZyvzoOHkMp/LNP1+Ow32g2PBDUsNQXFt+ndbRAEAcGSmvqd4wiefO8XFuXGOME1tyrqDKwhCIEzjcwuUCIWfal7a59FwqXr9LJ0Nn7+Ee5xDI0uj3q2avqxiFLZfhEPgjlgTKiXowhxCTPsGUBEMKtO5SyyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767858052; c=relaxed/simple; bh=YYYAsBcchiEX6jTu4koZi5Dx1eLSczpR7tymQfKyC4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JBZi5mN8dpPbocpnQ3KjUCNGu53Yqt+6qCok+suyG2zFpK8FjficwRS30jYlLH4FbMlbZZAkA5FpepkvygYQNX9aqrYex/JXGzt/4XUAF11Th629+SmwnCpLw+/uns1obJGYXexBZfLJl67kNq/ZuOfNX2qx78IkTfzedId2qrQ= 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=BRhrk4U3; 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="BRhrk4U3" 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=JcA9xF/qUKyoDRsfXihT0Yhg31Gwyc+UC3U5oSPw9as=; b=BRhrk4U37T4C/59dzw/BVHex+o w9rNf0hgGN3RR2j6SvisFi6w3CQXU9UWdTOX2j7LiTbfql1x7/S8ysn99zohIyN5tMEQHCNYEytTM IWXE3TPrzxIIcBU/60YYCdOyzxfpx99ILJL8l89BQcytSp1qyshbYj19e94BsSS3t3OLeoS3FGCcn ktDjjoJe8yWH3w+3rJasA0HNMriAVZ/usO5BWTcgpZSihFRffZXdsmQCvdxzExm/N38XkkPgrJONX 68skXOMFSqrPMUOV+azBfLFDJfLPugNjxm/7KUZabcF6NLklV8VmyPjySxKiWADnZejAt3MT03Prd fRyGKuOg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1vdkei-00000001pHZ-0AhU; Thu, 08 Jan 2026 07:42:04 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, brauner@kernel.org, jack@suse.cz, mjguzik@gmail.com, paul@paul-moore.com, axboe@kernel.dk, audit@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 8/8] do_execveat_common(): don't consume filename reference Date: Thu, 8 Jan 2026 07:42:01 +0000 Message-ID: <20260108074201.435280-9-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108074201.435280-1-viro@zeniv.linux.org.uk> References: <20260108074201.435280-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" ... and convert its callers to CLASS(filename...) Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/exec.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 4e192d7b7e71..3405c754da80 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1775,12 +1775,11 @@ static int bprm_execve(struct linux_binprm *bprm) return retval; } =20 -static int do_execveat_common(int fd, struct filename *__filename, +static int do_execveat_common(int fd, struct filename *filename, struct user_arg_ptr argv, struct user_arg_ptr envp, int flags) { - CLASS(filename_consume, filename)(__filename); int retval; =20 /* @@ -1927,7 +1926,8 @@ SYSCALL_DEFINE3(execve, const char __user *const __user *, argv, const char __user *const __user *, envp) { - return do_execveat_common(AT_FDCWD, getname(filename), + CLASS(filename, name)(filename); + return do_execveat_common(AT_FDCWD, name, native_arg(argv), native_arg(envp), 0); } =20 @@ -1937,7 +1937,8 @@ SYSCALL_DEFINE5(execveat, const char __user *const __user *, envp, int, flags) { - return do_execveat_common(fd, getname_uflags(filename, flags), + CLASS(filename_uflags, name)(filename, flags); + return do_execveat_common(fd, name, native_arg(argv), native_arg(envp), flags); } =20 @@ -1952,7 +1953,8 @@ COMPAT_SYSCALL_DEFINE3(execve, const char __user *, f= ilename, const compat_uptr_t __user *, argv, const compat_uptr_t __user *, envp) { - return do_execveat_common(AT_FDCWD, getname(filename), + CLASS(filename, name)(filename); + return do_execveat_common(AT_FDCWD, name, compat_arg(argv), compat_arg(envp), 0); } =20 @@ -1962,7 +1964,8 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd, const compat_uptr_t __user *, envp, int, flags) { - return do_execveat_common(fd, getname_uflags(filename, flags), + CLASS(filename_uflags, name)(filename, flags); + return do_execveat_common(fd, name, compat_arg(argv), compat_arg(envp), flags); } #endif --=20 2.47.3