Skip to contentSkip to conversation

libfrog: fix incorrect FS_IOC_FSSETXATTR argument to ioctl()

PATCH In review Andrey Albershteyn 4 participants 5 messages Dec 5, 2025 – Dec 9, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libfrog: fix incorrect FS_IOC_FSSETXATTR argument to ioctl()

From: Arkadiusz Miśkiewicz <[email protected]>

xfsprogs 6.17.0 has broken project quota due to incorrect argument passed to FS_IOC_FSSETXATTR ioctl(). Instead of passing struct fsxattr, struct file_attr was passed.

# LC_ALL=C /usr/sbin/xfs_quota -x -c "project -s -p /home/xxx 389701" /home Setting up project 389701 (path /home/xxx)...
xfs_quota: cannot set project on /home/xxx: Invalid argument Processed 1 (/etc/projects and cmdline) paths for project 389701 with recursion depth infinite (-1).

ioctl(5, FS_IOC_FSSETXATTR, {fsx_xflags=FS_XFLAG_PROJINHERIT|FS_XFLAG_HASATTR, fsx_extsize=0, fsx_projid=0, fsx_cowextsize=389701}) = -1 EINVAL (Invalid argument)

There seems to be a double mistake which hides the original ioctl() argument bug on old kernel with xfsprogs built against it. The size of fa_xflags was also wrong in xfsprogs's linux.h header. This way when xfsprogs is compiled on newer kernel but used with older kernel this bug uncovers.

---
 include/linux.h     | 2 +-
 libfrog/file_attr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux.h +1 -1
index cea468d2b9..3ea9016272 100644
@@ -214,7 +214,7 @@
  * fsxattr
  */
 struct file_attr {
-	__u32	fa_xflags;
+	__u64	fa_xflags;
 	__u32	fa_extsize;
 	__u32	fa_nextents;
 	__u32	fa_projid;
libfrog/file_attr.c +1 -1
index c2cbcb4e14..6801c54588 100644
@@ -114,7 +114,7 @@
 
 	file_attr_to_fsxattr(fa, &fsxa);
 
-	error = ioctl(fd, FS_IOC_FSSETXATTR, fa);
+	error = ioctl(fd, FS_IOC_FSSETXATTR, &fsxa);
 	close(fd);
 
 	return error;
#1 lore raw

ops, git didn't use From:

adding [email protected]

Quoted 52 lines · Andrey Albershteyn

From: Arkadiusz Miśkiewicz <[email protected]>

xfsprogs 6.17.0 has broken project quota due to incorrect argument passed to FS_IOC_FSSETXATTR ioctl(). Instead of passing struct fsxattr, struct file_attr was passed.

# LC_ALL=C /usr/sbin/xfs_quota -x -c "project -s -p /home/xxx 389701" /home Setting up project 389701 (path /home/xxx)...
xfs_quota: cannot set project on /home/xxx: Invalid argument Processed 1 (/etc/projects and cmdline) paths for project 389701 with recursion depth infinite (-1).

ioctl(5, FS_IOC_FSSETXATTR, {fsx_xflags=FS_XFLAG_PROJINHERIT|FS_XFLAG_HASATTR, fsx_extsize=0, fsx_projid=0, fsx_cowextsize=389701}) = -1 EINVAL (Invalid argument)

There seems to be a double mistake which hides the original ioctl() argument bug on old kernel with xfsprogs built against it. The size of fa_xflags was also wrong in xfsprogs's linux.h header. This way when xfsprogs is compiled on newer kernel but used with older kernel this bug uncovers.

---
 include/linux.h     | 2 +-
 libfrog/file_attr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux.h +1 -1
index cea468d2b9..3ea9016272 100644
@@ -214,7 +214,7 @@
  * fsxattr
  */
 struct file_attr {
-	__u32	fa_xflags;
+	__u64	fa_xflags;
 	__u32	fa_extsize;
 	__u32	fa_nextents;
 	__u32	fa_projid;
libfrog/file_attr.c +1 -1
index c2cbcb4e14..6801c54588 100644
@@ -114,7 +114,7 @@
 
 	file_attr_to_fsxattr(fa, &fsxa);
 
-	error = ioctl(fd, FS_IOC_FSSETXATTR, fa);
+	error = ioctl(fd, FS_IOC_FSSETXATTR, &fsxa);
 	close(fd);
 
 	return error;
Signature · 1 line
- Andrey
Reviewed-by on v1 1/1
#3 lore raw
In reply to Andrey Albershteyn
Quoted 31 lines · Andrey Albershteyn

From: Arkadiusz Miśkiewicz <[email protected]>

xfsprogs 6.17.0 has broken project quota due to incorrect argument passed to FS_IOC_FSSETXATTR ioctl(). Instead of passing struct fsxattr, struct file_attr was passed.

# LC_ALL=C /usr/sbin/xfs_quota -x -c "project -s -p /home/xxx 389701" /home Setting up project 389701 (path /home/xxx)...
xfs_quota: cannot set project on /home/xxx: Invalid argument Processed 1 (/etc/projects and cmdline) paths for project 389701 with recursion depth infinite (-1).

ioctl(5, FS_IOC_FSSETXATTR, {fsx_xflags=FS_XFLAG_PROJINHERIT|FS_XFLAG_HASATTR, fsx_extsize=0, fsx_projid=0, fsx_cowextsize=389701}) = -1 EINVAL (Invalid argument)

There seems to be a double mistake which hides the original ioctl() argument bug on old kernel with xfsprogs built against it. The size of fa_xflags was also wrong in xfsprogs's linux.h header. This way when xfsprogs is compiled on newer kernel but used with older kernel this bug uncovers.

---
 include/linux.h     | 2 +-
 libfrog/file_attr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux.h +0 -0
index cea468d2b9..3ea9016272 100644

include/linux.h line 217

Quoted 5 lines
include/linux.h +1 -1
@@ -214,7 +214,7 @@
  * fsxattr
  */
 struct file_attr {
-	__u32	fa_xflags;
+	__u64	fa_xflags;

Ouch, that's bad! Thanks for fixing that...

--D

Quoted 18 lines
include/linux.h +0 -0
 	__u32	fa_extsize;
 	__u32	fa_nextents;
 	__u32	fa_projid;
libfrog/file_attr.c +1 -1
index c2cbcb4e14..6801c54588 100644
@@ -114,7 +114,7 @@
 
 	file_attr_to_fsxattr(fa, &fsxa);
 
-	error = ioctl(fd, FS_IOC_FSSETXATTR, fa);
+	error = ioctl(fd, FS_IOC_FSSETXATTR, &fsxa);
 	close(fd);
 
 	return error;
#4 lore raw
In reply to Andrey Albershteyn
Quoted 14 lines · Andrey Albershteyn

From: Arkadiusz Miśkiewicz <[email protected]>

xfsprogs 6.17.0 has broken project quota due to incorrect argument passed to FS_IOC_FSSETXATTR ioctl(). Instead of passing struct fsxattr, struct file_attr was passed.

# LC_ALL=C /usr/sbin/xfs_quota -x -c "project -s -p /home/xxx 389701" /home Setting up project 389701 (path /home/xxx)...
xfs_quota: cannot set project on /home/xxx: Invalid argument Processed 1 (/etc/projects and cmdline) paths for project 389701 with recursion depth infinite (-1).

ioctl(5, FS_IOC_FSSETXATTR, {fsx_xflags=FS_XFLAG_PROJINHERIT|FS_XFLAG_HASATTR, fsx_extsize=0, fsx_projid=0, fsx_cowextsize=389701}) = -1 EINVAL (Invalid argument)

Quoted 7 lines

There seems to be a double mistake which hides the original ioctl() argument bug on old kernel with xfsprogs built against it. The size of fa_xflags was also wrong in xfsprogs's linux.h header. This way when xfsprogs is compiled on newer kernel but used with older kernel this bug uncovers.

Tested here briefly - works.

Quoted 33 lines
---
  include/linux.h     | 2 +-
  libfrog/file_attr.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
include/linux.h +1 -1
index cea468d2b9..3ea9016272 100644
@@ -214,7 +214,7 @@
   * fsxattr
   */
  struct file_attr {
-	__u32	fa_xflags;
+	__u64	fa_xflags;
  	__u32	fa_extsize;
  	__u32	fa_nextents;
  	__u32	fa_projid;
libfrog/file_attr.c +1 -1
index c2cbcb4e14..6801c54588 100644
@@ -114,7 +114,7 @@
 
  	file_attr_to_fsxattr(fa, &fsxa);
 
-	error = ioctl(fd, FS_IOC_FSSETXATTR, fa);
+	error = ioctl(fd, FS_IOC_FSSETXATTR, &fsxa);
  	close(fd);
 
  	return error;
Signature · 1 line
Arkadiusz Miśkiewicz, arekm / ( maven.pl | pld-linux.org )