Skip to contentSkip to conversation

package/attr: don't rely on kernel headers for struct xattr_args

PATCH Superseded yegorslists--- via buildroot 1 participant 2 messages Aug 31 – Oct 22

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/attr: don't rely on kernel headers for struct xattr_args

From: Yegor Yefremov <[email protected]>

struct xattr_args was added to <linux/xattr.h> in Linux 6.13, but the getxattrat() and setxattrat() syscall numbers can be defined independently of the kernel headers: musl libc, for example, defines them in <bits/syscall.h> for all kernel header versions. Building against kernel headers older than 6.13 with such a libc fails:

libmisc/xattrat.c:35:16: error: variable 'uargs' has initializer but incomplete type

     35 |         struct xattr_args uargs = {

Stop including <linux/xattr.h> and use our own definition of this fixed part of the kernel ABI instead, so that the build no longer depends on the kernel headers version. The struct layout is identical to the kernel definition (size 16, members at offsets 0, 8 and 12) on 32-bit and 64-bit architectures.

Upstream: https://lists.nongnu.org/archive/html/acl-devel/2026-08/msg00000.html

Fixes:
https://autobuild.buildroot.org/results/10926ccaf3d3212d8816f5156ae2405b469195aa

---
Changes v1 -> v2:
- add the upstream patch URL

 ...ly-on-kernel-headers-for-struct-xatt.patch | 85 +++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch
package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch new file +85 -0
new file mode 100644
index 0000000000..9ab7a99891
@@ -0,0 +1,85 @@
+From 9755020b815066732677d6107d40af12a58d1a0d Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Fri, 28 Aug 2026 23:43:48 +0200
+Subject: [PATCH] libmisc: don't rely on kernel headers for struct xattr_args
+
+struct xattr_args was added to <linux/xattr.h> in Linux 6.13, but the
+getxattrat() and setxattrat() syscall numbers can be defined
+independently of the kernel headers: musl libc, for example, defines
+them in <bits/syscall.h> for all kernel header versions.  Building
+against kernel headers older than 6.13 with such a libc fails:
+
+  libmisc/xattrat.c:35:16: error: variable 'uargs' has initializer but
+  incomplete type
+     35 |         struct xattr_args uargs = {
+
+Stop including <linux/xattr.h> and use our own definition of this fixed
+part of the kernel ABI instead, so that the build no longer depends on
+the kernel headers version.  The struct layout is identical to the
+kernel definition (size 16, members at offsets 0, 8 and 12) on 32-bit
+and 64-bit architectures.
+
+Upstream: https://lists.nongnu.org/archive/html/acl-devel/2026-08/msg00000.html
+
+Assisted-by: Claude:claude-opus-5
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ libmisc/xattrat.c | 23 ++++++++++++++++++-----
+ 1 file changed, 18 insertions(+), 5 deletions(-)
+
+diff --git a/libmisc/xattrat.c b/libmisc/xattrat.c
+index 5f6212c..c07c04d 100644
+--- a/libmisc/xattrat.c
++++ b/libmisc/xattrat.c
+@@ -18,7 +18,7 @@
+ */
+ 
+ #include "config.h"
+-#include <linux/xattr.h>
++#include <stdint.h>
+ #include <sys/syscall.h>
+ #include <unistd.h>
+ #include <errno.h>
+@@ -27,13 +27,26 @@
+ 
+ #pragma GCC diagnostic ignored "-Wunused-parameter"
+ 
++/*
++ * struct xattr_args was added to <linux/xattr.h> in Linux 6.13, but the
++ * syscall numbers can be defined independently of the kernel headers (musl
++ * libc defines them in <bits/syscall.h>, for example), so we cannot rely on
++ * the kernel headers to define the struct.  Use our own definition of this
++ * fixed part of the kernel ABI instead.
++ */
++struct attr_xattr_args {
++	uint64_t value __attribute__((aligned(8)));
++	uint32_t size;
++	uint32_t flags;
++};
++
+ ssize_t
+ getxattrat(int dirfd, const char *path, int at_flags, const char *name,
+ 	   void *value, size_t size)
+ {
+ #ifdef __NR_getxattrat
+-	struct xattr_args uargs = {
+-		.value = (unsigned long)value,
++	struct attr_xattr_args uargs = {
++		.value = (uintptr_t)value,
+ 		.size = size,
+ 	};
+ 
+@@ -50,8 +63,8 @@ setxattrat(int dirfd, const char *path, int at_flags, const char *name,
+ 	   const void *value, size_t size, int flags)
+ {
+ #ifdef __NR_setxattrat
+-	struct xattr_args uargs = {
+-		.value = (unsigned long)value,
++	struct attr_xattr_args uargs = {
++		.value = (uintptr_t)value,
+ 		.size = size,
+ 		.flags = flags,
+ 	};
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v3 1/1 package/attr: don't rely on kernel headers for struct xattr_args

struct xattr_args was added to <linux/xattr.h> in Linux 6.13, but the getxattrat() and setxattrat() syscall numbers can be defined independently of the kernel headers: musl libc, for example, defines them in <bits/syscall.h> for all kernel header versions. Building against kernel headers older than 6.13 with such a libc fails:

libmisc/xattrat.c:35:16: error: variable 'uargs' has initializer but incomplete type

     35 |         struct xattr_args uargs = {

Stop including <linux/xattr.h> and use our own definition of this fixed part of the kernel ABI instead, so that the build no longer depends on the kernel headers version. The struct layout is identical to the kernel definition (size 16, members at offsets 0, 8 and 12) on 32-bit and 64-bit architectures.

Upstream: https://lists.nongnu.org/archive/html/acl-devel/2026-08/msg00000.html

This issue has been present since commit c804ebff5502 ("package/attr:
security bump version to 2.6.0"), as libmisc/xattrat.c and its getxattrat()/setxattrat() wrappers were introduced in attr 2.6.0. It therefore affects 2026.08 and later. The maintenance branches up to 2026.05.x, including the 2026.02.x LTS, still use attr 2.5.2 and are not affected.

Fixes:
https://autobuild.buildroot.org/results/10926ccaf3d3212d8816f5156ae2405b469195aa

Fixes c804ebff5502eac6e7d84129bfb2becc400898c6 ("package/attr: security bump version to 2.6.0")
Assisted-by Claude:claude-opus-5-5

---
Changes v2 -> v3:
- describe since when the issue has been present and add a Fixes:
tag for the culprit commit

Changes v1 -> v2:
- add upstream URL

 ...ly-on-kernel-headers-for-struct-xatt.patch | 85 +++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch
package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch new file +85 -0
new file mode 100644
index 0000000000..9ab7a99891
@@ -0,0 +1,85 @@
+From 9755020b815066732677d6107d40af12a58d1a0d Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Fri, 28 Aug 2026 23:43:48 +0200
+Subject: [PATCH] libmisc: don't rely on kernel headers for struct xattr_args
+
+struct xattr_args was added to <linux/xattr.h> in Linux 6.13, but the
+getxattrat() and setxattrat() syscall numbers can be defined
+independently of the kernel headers: musl libc, for example, defines
+them in <bits/syscall.h> for all kernel header versions.  Building
+against kernel headers older than 6.13 with such a libc fails:
+
+  libmisc/xattrat.c:35:16: error: variable 'uargs' has initializer but
+  incomplete type
+     35 |         struct xattr_args uargs = {
+
+Stop including <linux/xattr.h> and use our own definition of this fixed
+part of the kernel ABI instead, so that the build no longer depends on
+the kernel headers version.  The struct layout is identical to the
+kernel definition (size 16, members at offsets 0, 8 and 12) on 32-bit
+and 64-bit architectures.
+
+Upstream: https://lists.nongnu.org/archive/html/acl-devel/2026-08/msg00000.html
+
+Assisted-by: Claude:claude-opus-5
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ libmisc/xattrat.c | 23 ++++++++++++++++++-----
+ 1 file changed, 18 insertions(+), 5 deletions(-)
+
+diff --git a/libmisc/xattrat.c b/libmisc/xattrat.c
+index 5f6212c..c07c04d 100644
+--- a/libmisc/xattrat.c
++++ b/libmisc/xattrat.c
+@@ -18,7 +18,7 @@
+ */
+ 
+ #include "config.h"
+-#include <linux/xattr.h>
++#include <stdint.h>
+ #include <sys/syscall.h>
+ #include <unistd.h>
+ #include <errno.h>
+@@ -27,13 +27,26 @@
+ 
+ #pragma GCC diagnostic ignored "-Wunused-parameter"
+ 
++/*
++ * struct xattr_args was added to <linux/xattr.h> in Linux 6.13, but the
++ * syscall numbers can be defined independently of the kernel headers (musl
++ * libc defines them in <bits/syscall.h>, for example), so we cannot rely on
++ * the kernel headers to define the struct.  Use our own definition of this
++ * fixed part of the kernel ABI instead.
++ */
++struct attr_xattr_args {
++	uint64_t value __attribute__((aligned(8)));
++	uint32_t size;
++	uint32_t flags;
++};
++
+ ssize_t
+ getxattrat(int dirfd, const char *path, int at_flags, const char *name,
+ 	   void *value, size_t size)
+ {
+ #ifdef __NR_getxattrat
+-	struct xattr_args uargs = {
+-		.value = (unsigned long)value,
++	struct attr_xattr_args uargs = {
++		.value = (uintptr_t)value,
+ 		.size = size,
+ 	};
+ 
+@@ -50,8 +63,8 @@ setxattrat(int dirfd, const char *path, int at_flags, const char *name,
+ 	   const void *value, size_t size, int flags)
+ {
+ #ifdef __NR_setxattrat
+-	struct xattr_args uargs = {
+-		.value = (unsigned long)value,
++	struct attr_xattr_args uargs = {
++		.value = (uintptr_t)value,
+ 		.size = size,
+ 		.flags = flags,
+ 	};
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot