| Message ID | 20260829205149.958488-1-yegorslists@googlemail.com |
|---|---|
| State | New |
| Headers | show |
| Series | package/attr: don't rely on kernel headers for struct xattr_args | expand |
On Sat, Aug 29, 2026 at 10:51 PM <yegorslists@googlemail.com> wrote: > > From: Yegor Yefremov <yegorslists@googlemail.com> > > 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. > Forgot to add the upstream URL: https://lists.nongnu.org/archive/html/acl-devel/2026-08/msg00000.html Regards, Yegor > Fixes: > https://autobuild.buildroot.org/results/10926ccaf3d3212d8816f5156ae2405b469195aa > > Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> > --- > ...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 > > diff --git a/package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch b/package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch > new file mode 100644 > index 0000000000..a9c04f8723 > --- /dev/null > +++ b/package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch > @@ -0,0 +1,83 @@ > +From 9755020b815066732677d6107d40af12a58d1a0d Mon Sep 17 00:00:00 2001 > +From: Yegor Yefremov <yegorslists@googlemail.com> > +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 <yegorslists@googlemail.com> > +--- > + 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 > + > -- > 2.34.1 >
diff --git a/package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch b/package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch new file mode 100644 index 0000000000..a9c04f8723 --- /dev/null +++ b/package/attr/0002-libmisc-don-t-rely-on-kernel-headers-for-struct-xatt.patch @@ -0,0 +1,83 @@ +From 9755020b815066732677d6107d40af12a58d1a0d Mon Sep 17 00:00:00 2001 +From: Yegor Yefremov <yegorslists@googlemail.com> +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 <yegorslists@googlemail.com> +--- + 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 +