lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260217214741.1928576-2-cel@kernel.org>
Date: Tue, 17 Feb 2026 16:47:25 -0500
From: Chuck Lever <cel@...nel.org>
To: Al Viro <viro@...iv.linux.org.uk>,
	Christian Brauner <brauner@...nel.org>,
	Jan Kara <jack@...e.cz>
Cc: linux-fsdevel@...r.kernel.org,
	linux-ext4@...r.kernel.org,
	linux-xfs@...r.kernel.org,
	linux-cifs@...r.kernel.org,
	linux-nfs@...r.kernel.org,
	linux-api@...r.kernel.org,
	linux-f2fs-devel@...ts.sourceforge.net,
	hirofumi@...l.parknet.co.jp,
	linkinjeon@...nel.org,
	sj1557.seo@...sung.com,
	yuezhang.mo@...y.com,
	almaz.alexandrovich@...agon-software.com,
	slava@...eyko.com,
	glaubitz@...sik.fu-berlin.de,
	frank.li@...o.com,
	tytso@....edu,
	adilger.kernel@...ger.ca,
	cem@...nel.org,
	sfrench@...ba.org,
	pc@...guebit.org,
	ronniesahlberg@...il.com,
	sprasad@...rosoft.com,
	trondmy@...nel.org,
	anna@...nel.org,
	jaegeuk@...nel.org,
	chao@...nel.org,
	hansg@...nel.org,
	senozhatsky@...omium.org,
	Chuck Lever <chuck.lever@...cle.com>,
	"Darrick J. Wong" <djwong@...nel.org>
Subject: [PATCH v8 01/17] fs: Move file_kattr initialization to callers

From: Chuck Lever <chuck.lever@...cle.com>

fileattr_fill_xflags() and fileattr_fill_flags() zero the entire
file_kattr struct before populating select fields. This behavior
prevents callers from setting flags in fa->fsx_xflags before
calling these helpers; the zeroing clears any pre-set values.

As Darrick Wong observed, when a function named "fill_xflags"
modifies more than just xflags, filesystems must understand
implementation details beyond the function's apparent scope. When
initialization occurs at entry points, helper functions need not
duplicate that zeroing.

Move struct file_kattr zero-initialization from the fill functions
to their callers. Entry points such as ioctl_setflags(),
ioctl_fssetxattr(), and the file_getattr/file_setattr syscalls
now perform aggregate initialization directly. The fill functions
retain their field-setting logic but no longer clear the struct.

This change enables subsequent patches where filesystem
->fileattr_get() handlers can set case-sensitivity flags
(FS_XFLAG_CASEFOLD, FS_XFLAG_CASENONPRESERVING) in fa->fsx_xflags
before calling the fill functions.

Suggested-by: Darrick J. Wong <djwong@...nel.org>
Signed-off-by: Chuck Lever <chuck.lever@...cle.com>
---
 fs/file_attr.c     | 14 +++++---------
 fs/xfs/xfs_ioctl.c |  2 +-
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/fs/file_attr.c b/fs/file_attr.c
index 6d2a298a786d..42aa511111a0 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);
@@ -378,7 +374,7 @@ SYSCALL_DEFINE5(file_getattr, 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);
@@ -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 4eeda4d4e3ab..369555275140 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -498,7 +498,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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ