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 29 – Aug 31

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

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

---
 ...ly-on-kernel-headers-for-struct-xatt.patch | 83 +++++++++++++++++++
 1 file changed, 83 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 +83 -0
new file mode 100644
index 0000000000..a9c04f8723
@@ -0,0 +1,83 @@
+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.
+
+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
Quoted 11 lines · On Sat, Aug 29, 2026 at 10:51 PM <[email protected]> wrote:

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

Quoted 8 lines
     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.

Forgot to add the upstream URL:

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

Regards,
Yegor

Quoted 99 lines

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

---
 ...ly-on-kernel-headers-for-struct-xatt.patch | 83 +++++++++++++++++++
 1 file changed, 83 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 +83 -1
new file mode 100644
index 0000000000..a9c04f8723
@@ -0,0 +1,83 @@
+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.
+
+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
+
--
Quoted 2 lines

2.34.1

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