mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vfs: use UAPI types for new struct delegation definition
@ 2025-12-03 13:57 Thomas Weißschuh
  2025-12-03 14:01 ` Jeff Layton
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-03 13:57 UTC (permalink / raw)
  To: Jeff Layton, Chuck Lever, Alexander Aring, Jan Kara, Christian Brauner
  Cc: Arnd Bergmann, linux-fsdevel, linux-kernel, Thomas Weißschuh

Using libc types and headers from the UAPI headers is problematic as it
introduces a dependency on a full C toolchain.

Use the fixed-width integer types provided by the UAPI headers instead.

Fixes: 1602bad16d7d ("vfs: expose delegation support to userland")
Fixes: 4be9e04ebf75 ("vfs: add needed headers for new struct delegation definition")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 include/uapi/linux/fcntl.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index 5e277fd955aa..aadfbf6e0cb3 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -4,11 +4,7 @@
 
 #include <asm/fcntl.h>
 #include <linux/openat2.h>
-#ifdef __KERNEL__
 #include <linux/types.h>
-#else
-#include <stdint.h>
-#endif
 
 #define F_SETLEASE	(F_LINUX_SPECIFIC_BASE + 0)
 #define F_GETLEASE	(F_LINUX_SPECIFIC_BASE + 1)
@@ -90,9 +86,9 @@
 
 /* Argument structure for F_GETDELEG and F_SETDELEG */
 struct delegation {
-	uint32_t	d_flags;	/* Must be 0 */
-	uint16_t	d_type;		/* F_RDLCK, F_WRLCK, F_UNLCK */
-	uint16_t	__pad;		/* Must be 0 */
+	__u32	d_flags;	/* Must be 0 */
+	__u16	d_type;		/* F_RDLCK, F_WRLCK, F_UNLCK */
+	__u16	__pad;		/* Must be 0 */
 };
 
 /*

---
base-commit: 3f9f0252130e7dd60d41be0802bf58f6471c691d
change-id: 20251203-uapi-fcntl-f49d5b30f8cd

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vfs: use UAPI types for new struct delegation definition
  2025-12-03 13:57 [PATCH] vfs: use UAPI types for new struct delegation definition Thomas Weißschuh
@ 2025-12-03 14:01 ` Jeff Layton
  2025-12-03 14:14 ` Arnd Bergmann
  2025-12-04  9:02 ` Christian Brauner
  2 siblings, 0 replies; 8+ messages in thread
From: Jeff Layton @ 2025-12-03 14:01 UTC (permalink / raw)
  To: Thomas Weißschuh, Chuck Lever, Alexander Aring, Jan Kara,
	Christian Brauner
  Cc: Arnd Bergmann, linux-fsdevel, linux-kernel

On Wed, 2025-12-03 at 14:57 +0100, Thomas Weißschuh wrote:
> Using libc types and headers from the UAPI headers is problematic as it
> introduces a dependency on a full C toolchain.
> 
> Use the fixed-width integer types provided by the UAPI headers instead.
> 
> Fixes: 1602bad16d7d ("vfs: expose delegation support to userland")
> Fixes: 4be9e04ebf75 ("vfs: add needed headers for new struct delegation definition")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
>  include/uapi/linux/fcntl.h | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
> index 5e277fd955aa..aadfbf6e0cb3 100644
> --- a/include/uapi/linux/fcntl.h
> +++ b/include/uapi/linux/fcntl.h
> @@ -4,11 +4,7 @@
>  
>  #include <asm/fcntl.h>
>  #include <linux/openat2.h>
> -#ifdef __KERNEL__
>  #include <linux/types.h>
> -#else
> -#include <stdint.h>
> -#endif
>  
>  #define F_SETLEASE	(F_LINUX_SPECIFIC_BASE + 0)
>  #define F_GETLEASE	(F_LINUX_SPECIFIC_BASE + 1)
> @@ -90,9 +86,9 @@
>  
>  /* Argument structure for F_GETDELEG and F_SETDELEG */
>  struct delegation {
> -	uint32_t	d_flags;	/* Must be 0 */
> -	uint16_t	d_type;		/* F_RDLCK, F_WRLCK, F_UNLCK */
> -	uint16_t	__pad;		/* Must be 0 */
> +	__u32	d_flags;	/* Must be 0 */
> +	__u16	d_type;		/* F_RDLCK, F_WRLCK, F_UNLCK */
> +	__u16	__pad;		/* Must be 0 */
>  };
>  
>  /*
> 
> ---
> base-commit: 3f9f0252130e7dd60d41be0802bf58f6471c691d
> change-id: 20251203-uapi-fcntl-f49d5b30f8cd
> 
> Best regards,

Thanks. I wasn't sure of the right way to do this.

Acked-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vfs: use UAPI types for new struct delegation definition
  2025-12-03 13:57 [PATCH] vfs: use UAPI types for new struct delegation definition Thomas Weißschuh
  2025-12-03 14:01 ` Jeff Layton
@ 2025-12-03 14:14 ` Arnd Bergmann
  2025-12-04  6:58   ` Thomas Weißschuh
  2025-12-04  9:02 ` Christian Brauner
  2 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2025-12-03 14:14 UTC (permalink / raw)
  To: Thomas Weißschuh, Jeff Layton, Chuck Lever, Alexander Aring,
	Jan Kara, Christian Brauner
  Cc: linux-fsdevel, linux-kernel

On Wed, Dec 3, 2025, at 14:57, Thomas Weißschuh wrote:
> Using libc types and headers from the UAPI headers is problematic as it
> introduces a dependency on a full C toolchain.
>
> Use the fixed-width integer types provided by the UAPI headers instead.
>
> Fixes: 1602bad16d7d ("vfs: expose delegation support to userland")
> Fixes: 4be9e04ebf75 ("vfs: add needed headers for new struct delegation 
> definition")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Acked-by: Arnd Bergmann <arnd@arndb.de>

> --- a/include/uapi/linux/fcntl.h
> +++ b/include/uapi/linux/fcntl.h
> @@ -4,11 +4,7 @@
> 
>  #include <asm/fcntl.h>
>  #include <linux/openat2.h>
> -#ifdef __KERNEL__
>  #include <linux/types.h>
> -#else
> -#include <stdint.h>
> -#endif

I think we have a couple more files that could use similar changes,
but they tend to be at a larger scale:

include/uapi/linux/fuse.h
include/uapi/linux/idxd.h
include/uapi/linux/ax25.h
include/uapi/regulator/regulator.h
include/uapi/xen/privcmd.h

     Arnd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vfs: use UAPI types for new struct delegation definition
  2025-12-03 14:14 ` Arnd Bergmann
@ 2025-12-04  6:58   ` Thomas Weißschuh
  2025-12-04  9:09     ` Arnd Bergmann
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-04  6:58 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jeff Layton, Chuck Lever, Alexander Aring, Jan Kara,
	Christian Brauner, linux-fsdevel, linux-kernel

On Wed, Dec 03, 2025 at 03:14:31PM +0100, Arnd Bergmann wrote:
> On Wed, Dec 3, 2025, at 14:57, Thomas Weißschuh wrote:
> > Using libc types and headers from the UAPI headers is problematic as it
> > introduces a dependency on a full C toolchain.
> >
> > Use the fixed-width integer types provided by the UAPI headers instead.
> >
> > Fixes: 1602bad16d7d ("vfs: expose delegation support to userland")
> > Fixes: 4be9e04ebf75 ("vfs: add needed headers for new struct delegation 
> > definition")
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Thanks!

> > --- a/include/uapi/linux/fcntl.h
> > +++ b/include/uapi/linux/fcntl.h
> > @@ -4,11 +4,7 @@
> > 
> >  #include <asm/fcntl.h>
> >  #include <linux/openat2.h>
> > -#ifdef __KERNEL__
> >  #include <linux/types.h>
> > -#else
> > -#include <stdint.h>
> > -#endif
> 
> I think we have a couple more files that could use similar changes,
> but they tend to be at a larger scale:

To start, let's extend the UAPI header tests to detect such dependencies [0].
Then we can clean them up without new ones popping up.

> include/uapi/linux/fuse.h
> include/uapi/linux/idxd.h
> include/uapi/linux/ax25.h
> include/uapi/regulator/regulator.h

> include/uapi/xen/privcmd.h

I have no idea how that header is supposed to work at all, as it depends on
non-UAPI headers. It is also ignored in the UAPI header tests.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/thomas.weissschuh/linux.git/commit/?h=b4/uapi-nostdinc


Thomas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vfs: use UAPI types for new struct delegation definition
  2025-12-03 13:57 [PATCH] vfs: use UAPI types for new struct delegation definition Thomas Weißschuh
  2025-12-03 14:01 ` Jeff Layton
  2025-12-03 14:14 ` Arnd Bergmann
@ 2025-12-04  9:02 ` Christian Brauner
  2025-12-04  9:17   ` Thomas Weißschuh
  2 siblings, 1 reply; 8+ messages in thread
From: Christian Brauner @ 2025-12-04  9:02 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Christian Brauner, Arnd Bergmann, linux-fsdevel, linux-kernel,
	Jeff Layton, Chuck Lever, Alexander Aring, Jan Kara

On Wed, 03 Dec 2025 14:57:57 +0100, Thomas Weißschuh wrote:
> Using libc types and headers from the UAPI headers is problematic as it
> introduces a dependency on a full C toolchain.
> 
> Use the fixed-width integer types provided by the UAPI headers instead.
> 
> 

Applied to the vfs-6.20.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.20.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.20.misc

[1/1] vfs: use UAPI types for new struct delegation definition
      https://git.kernel.org/vfs/vfs/c/b496744de0d0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vfs: use UAPI types for new struct delegation definition
  2025-12-04  6:58   ` Thomas Weißschuh
@ 2025-12-04  9:09     ` Arnd Bergmann
  0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2025-12-04  9:09 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Jeff Layton, Chuck Lever, Alexander Aring, Jan Kara,
	Christian Brauner, linux-fsdevel, linux-kernel

On Thu, Dec 4, 2025, at 07:58, Thomas Weißschuh wrote:
> On Wed, Dec 03, 2025 at 03:14:31PM +0100, Arnd Bergmann wrote:
>> > --- a/include/uapi/linux/fcntl.h
>> > +++ b/include/uapi/linux/fcntl.h
>> > @@ -4,11 +4,7 @@
>> > 
>> >  #include <asm/fcntl.h>
>> >  #include <linux/openat2.h>
>> > -#ifdef __KERNEL__
>> >  #include <linux/types.h>
>> > -#else
>> > -#include <stdint.h>
>> > -#endif
>> 
>> I think we have a couple more files that could use similar changes,
>> but they tend to be at a larger scale:
>
> To start, let's extend the UAPI header tests to detect such dependencies [0].
> Then we can clean them up without new ones popping up.

Sounds good to me. This also caused some problems when I did some
validation to find implicit padding in uapi data structures (using -Wpadded).
I eventually figured out how to build all uapi headers against nolibc
on all architectures with my cross-compilers and clang.

Specifically, I needed some macro definitions for architecture specific
padding in linux/types.h.

I'll have to rebase my patches after -rc1, and we can see if it's
worth upstreaming, either the bits improve the test coverage or
the actual padding annotations I added.

>> include/uapi/xen/privcmd.h
>
> I have no idea how that header is supposed to work at all, as it depends on
> non-UAPI headers. It is also ignored in the UAPI header tests.

This is the hack I'm using to test-build the header, but I don't
think that is what we want upstream:

--- a/include/uapi/xen/privcmd.h
+++ b/include/uapi/xen/privcmd.h
@@ -36,7 +36,12 @@
 
 #include <linux/types.h>
 #include <linux/compiler.h>
+#ifdef __KERNEL__
 #include <xen/interface/xen.h>
+#else
+typedef __u16 domid_t;
+typedef __u64 xen_pfn_t;
+#endif
 
 struct privcmd_hypercall {
        __u64 op;

     Arnd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vfs: use UAPI types for new struct delegation definition
  2025-12-04  9:02 ` Christian Brauner
@ 2025-12-04  9:17   ` Thomas Weißschuh
  2025-12-05  8:52     ` Christian Brauner
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-04  9:17 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Arnd Bergmann, linux-fsdevel, linux-kernel, Jeff Layton,
	Chuck Lever, Alexander Aring, Jan Kara

On Thu, Dec 04, 2025 at 10:02:05AM +0100, Christian Brauner wrote:
> On Wed, 03 Dec 2025 14:57:57 +0100, Thomas Weißschuh wrote:
> > Using libc types and headers from the UAPI headers is problematic as it
> > introduces a dependency on a full C toolchain.
> > 
> > Use the fixed-width integer types provided by the UAPI headers instead.
> > 
> > 
> 
> Applied to the vfs-6.20.misc branch of the vfs/vfs.git tree.
> Patches in the vfs-6.20.misc branch should appear in linux-next soon.

Thanks.

Given that this is a bugfix is there any chance to get it into v6.19?
Preferably even -rc1? This is currently breaking the nolibc tests.

> Please report any outstanding bugs that were missed during review in a
> new review to the original patch series allowing us to drop it.
> 
> It's encouraged to provide Acked-bys and Reviewed-bys even though the
> patch has now been applied. If possible patch trailers will be updated.
> 
> Note that commit hashes shown below are subject to change due to rebase,
> trailer updates or similar. If in doubt, please check the listed branch.
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
> branch: vfs-6.20.misc
> 
> [1/1] vfs: use UAPI types for new struct delegation definition
>       https://git.kernel.org/vfs/vfs/c/b496744de0d0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vfs: use UAPI types for new struct delegation definition
  2025-12-04  9:17   ` Thomas Weißschuh
@ 2025-12-05  8:52     ` Christian Brauner
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Brauner @ 2025-12-05  8:52 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Arnd Bergmann, linux-fsdevel, linux-kernel, Jeff Layton,
	Chuck Lever, Alexander Aring, Jan Kara

On Thu, Dec 04, 2025 at 10:17:01AM +0100, Thomas Weißschuh wrote:
> On Thu, Dec 04, 2025 at 10:02:05AM +0100, Christian Brauner wrote:
> > On Wed, 03 Dec 2025 14:57:57 +0100, Thomas Weißschuh wrote:
> > > Using libc types and headers from the UAPI headers is problematic as it
> > > introduces a dependency on a full C toolchain.
> > > 
> > > Use the fixed-width integer types provided by the UAPI headers instead.
> > > 
> > > 
> > 
> > Applied to the vfs-6.20.misc branch of the vfs/vfs.git tree.
> > Patches in the vfs-6.20.misc branch should appear in linux-next soon.
> 
> Thanks.
> 
> Given that this is a bugfix is there any chance to get it into v6.19?
> Preferably even -rc1? This is currently breaking the nolibc tests.

Yeah, I guess so.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-12-05  8:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-03 13:57 [PATCH] vfs: use UAPI types for new struct delegation definition Thomas Weißschuh
2025-12-03 14:01 ` Jeff Layton
2025-12-03 14:14 ` Arnd Bergmann
2025-12-04  6:58   ` Thomas Weißschuh
2025-12-04  9:09     ` Arnd Bergmann
2025-12-04  9:02 ` Christian Brauner
2025-12-04  9:17   ` Thomas Weißschuh
2025-12-05  8:52     ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®