From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 546162BE026; Wed, 22 Apr 2026 23:38:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776901104; cv=none; b=fIAYGfjGQA21/RPJ1h5GjciAq/MOuenwNG2lEA+EsmzKnukCzZq7hG1VwFtX8TJdgt+kE9WKtPRoTr0nj1mRo2KhgKg0g8pMhZkK/uHmZX6GMDvFgvh9OSdsB+/tV9zxajmRWl1aTnl8H0D4V7JN70qiRb6HUSbQbVCtRr5Vhvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776901104; c=relaxed/simple; bh=cA0ZR5J/e3BV4LxJ7qZBjOuZwp2IQKJzAscafkI55UU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iUArHdIYHab4ipN0JXC30b9hEJ5+9VicoFMxtL1sPP2smJuZpXVeO15gmTk6/3Z3NyTe4McsHuBUGfCKlYfPOdLRLbeGwzo/Rjlbs/z38pxdIyLKnQKiFdezb3dO60bg7zvfv1Jmrv7Vsh5Chyq6nrfXy0UzJHTi9uNbxDKUyhA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ezVtpBVv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ezVtpBVv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E08E0C19425; Wed, 22 Apr 2026 23:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776901104; bh=cA0ZR5J/e3BV4LxJ7qZBjOuZwp2IQKJzAscafkI55UU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ezVtpBVv1QMF6X9CFXadmDeGdwQ+lK71l5/X2+S0Y2NUH1w14TuTXFtm/J/iaIcGu EF5cAl6y2Vhv2hCcnNmgTxoIo1dwdxhPtlWq9cNpo4IM7RZ2+h76UMiOie6HmtapIl 3HKX1mi1BY4P8U98ZIxqrv59ejKNYkgTyRrlkaaWeC8M9hf5SVq1yqT4N6R3WlgVa8 1paua8ccPeMwKAurOHnqmV/AyxV0VYYPv23r0lnFDZt5eaLdWsIOFVXsa14SrCwQZ0 MiM3BzfGaTinld59+KmN1n63TEaa1cSBjrbe1rwlsaABMnGhsmWaRILzz9nOn98xNq hFG3JN3FV+7SQ== Date: Wed, 22 Apr 2026 16:38:23 -0700 From: "Darrick J. Wong" To: Chuck Lever Cc: Al Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-api@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, hirofumi@mail.parknet.co.jp, linkinjeon@kernel.org, sj1557.seo@samsung.com, yuezhang.mo@sony.com, almaz.alexandrovich@paragon-software.com, slava@dubeyko.com, glaubitz@physik.fu-berlin.de, frank.li@vivo.com, tytso@mit.edu, adilger.kernel@dilger.ca, cem@kernel.org, sfrench@samba.org, pc@manguebit.org, ronniesahlberg@gmail.com, sprasad@microsoft.com, trondmy@kernel.org, anna@kernel.org, jaegeuk@kernel.org, chao@kernel.org, hansg@kernel.org, senozhatsky@chromium.org, Chuck Lever Subject: Re: [PATCH v9 01/17] fs: Move file_kattr initialization to callers Message-ID: <20260422233823.GA3778109@frogsfrogsfrogs> References: <20260422-case-sensitivity-v9-0-be023cc070e2@oracle.com> <20260422-case-sensitivity-v9-1-be023cc070e2@oracle.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260422-case-sensitivity-v9-1-be023cc070e2@oracle.com> On Wed, Apr 22, 2026 at 07:29:55PM -0400, Chuck Lever wrote: > From: Chuck Lever > > fileattr_fill_xflags() and fileattr_fill_flags() memset the > entire file_kattr struct before populating select fields, so > callers cannot pre-set fields in fa->fsx_xflags without having > their values clobbered. Darrick Wong noted that a function > named "fill_xflags" touching more than xflags forces callers > to know implementation details beyond its apparent scope. > > Drop the memset from both fill functions and initialize at the > entry points instead: ioctl_setflags(), ioctl_fssetxattr(), > the file_setattr() syscall, and xfs_ioc_fsgetxattra() now > declare fa with an aggregate initializer. ioctl_getflags(), > ioctl_fsgetxattr(), and the file_getattr() syscall already > aggregate-initialize fa to pass flags_valid/fsx_valid hints > into vfs_fileattr_get(). > > Subsequent patches rely on this so that ->fileattr_get() > handlers can set case-sensitivity flags (FS_XFLAG_CASEFOLD, > FS_XFLAG_CASENONPRESERVING) in fa->fsx_xflags before the fill > functions run. > > Suggested-by: Darrick J. Wong > Reviewed-by: Jan Kara > Signed-off-by: Chuck Lever Heh, I never did review this one so Reviewed-by: "Darrick J. Wong" --D > --- > fs/file_attr.c | 12 ++++-------- > fs/xfs/xfs_ioctl.c | 2 +- > 2 files changed, 5 insertions(+), 9 deletions(-) > > diff --git a/fs/file_attr.c b/fs/file_attr.c > index da983e105d70..f429da66a317 100644 > --- a/fs/file_attr.c > +++ b/fs/file_attr.c > @@ -15,12 +15,10 @@ > * @fa: fileattr pointer > * @xflags: FS_XFLAG_* flags > * > - * Set ->fsx_xflags, ->fsx_valid and ->flags (translated xflags). All > - * other fields are zeroed. > + * Set ->fsx_xflags, ->fsx_valid and ->flags (translated xflags). > */ > void fileattr_fill_xflags(struct file_kattr *fa, u32 xflags) > { > - memset(fa, 0, sizeof(*fa)); > fa->fsx_valid = true; > fa->fsx_xflags = xflags; > if (fa->fsx_xflags & FS_XFLAG_IMMUTABLE) > @@ -48,11 +46,9 @@ EXPORT_SYMBOL(fileattr_fill_xflags); > * @flags: FS_*_FL flags > * > * Set ->flags, ->flags_valid and ->fsx_xflags (translated flags). > - * All other fields are zeroed. > */ > void fileattr_fill_flags(struct file_kattr *fa, u32 flags) > { > - memset(fa, 0, sizeof(*fa)); > fa->flags_valid = true; > fa->flags = flags; > if (fa->flags & FS_SYNC_FL) > @@ -325,7 +321,7 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp) > { > struct mnt_idmap *idmap = file_mnt_idmap(file); > struct dentry *dentry = file->f_path.dentry; > - struct file_kattr fa; > + struct file_kattr fa = {}; > unsigned int flags; > int err; > > @@ -357,7 +353,7 @@ int ioctl_fssetxattr(struct file *file, void __user *argp) > { > struct mnt_idmap *idmap = file_mnt_idmap(file); > struct dentry *dentry = file->f_path.dentry; > - struct file_kattr fa; > + struct file_kattr fa = {}; > int err; > > err = copy_fsxattr_from_user(&fa, argp); > @@ -431,7 +427,7 @@ SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename, > struct path filepath __free(path_put) = {}; > unsigned int lookup_flags = 0; > struct file_attr fattr; > - struct file_kattr fa; > + struct file_kattr fa = {}; > int error; > > BUILD_BUG_ON(sizeof(struct file_attr) < FILE_ATTR_SIZE_VER0); > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > index 46e234863644..ed9b4846c05f 100644 > --- a/fs/xfs/xfs_ioctl.c > +++ b/fs/xfs/xfs_ioctl.c > @@ -517,7 +517,7 @@ xfs_ioc_fsgetxattra( > xfs_inode_t *ip, > void __user *arg) > { > - struct file_kattr fa; > + struct file_kattr fa = {}; > > xfs_ilock(ip, XFS_ILOCK_SHARED); > xfs_fill_fsxattr(ip, XFS_ATTR_FORK, &fa); > > -- > 2.53.0 > >