linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43
       [not found] <CAHaCkme7C8LDpWVX8TnDQQ+feWeQy_SA3HYfpyyPNFee_+Z2EA@mail.gmail.com>
@ 2025-11-09  7:13 ` Masaharu Noguchi
  2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
  2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
  0 siblings, 2 replies; 5+ messages in thread
From: Masaharu Noguchi @ 2025-11-09  7:13 UTC (permalink / raw)
  To: jesperjuhl76, Jeff Layton, Chuck Lever
  Cc: Alexander Aring, linux-fsdevel, linux-kernel, Masaharu Noguchi

LKML reports show that `allyesconfig` currently fails with glibc 2.42
because both `<stdio.h>` and `<linux/fcntl.h>` define the AT_RENAME_*
macros.  A follow-up pointed to glibc commit `1166170d9586 ("libio:
Define AT_RENAME_* with the same tokens as Linux")`, which will first
appear in glibc 2.43.  Until that release lands in common distributions,
upstream kernels still build against glibc versions that redeclare the
macros and fail under `-Werror`.

This series is a small, revertable workaround so developers on Fedora 43
(glibc 2.42) and other distributions with glibc < 2.43 can keep building
the samples.  The
first patch only emits the AT_RENAME_* aliases when libc does not do so
already, and the second patch undefines any libc-provided macros before
including `<linux/fcntl.h>` in the VFS sample.  Once glibc 2.43+ is
ubiquitous (or if we decide to remove the aliases entirely), these
changes can be dropped.

Link: https://lore.kernel.org/all/CAHaCkme7C8LDpWVX8TnDQQ+feWeQy_SA3HYfpyyPNFee_+Z2EA@mail.gmail.com/ # LKML report
Link: https://lore.kernel.org/all/20251013012423.GA331@ax162/ # follow-up
Link: https://sourceware.org/git/?p=glibc.git;a=commit;h=1166170d95863e5a6f8121a5ca9d97713f524f49 # glibc fix

Masaharu Noguchi (2):
  uapi: fcntl: guard AT_RENAME_* aliases
  samples: vfs: avoid libc AT_RENAME_* redefinitions

 include/uapi/linux/fcntl.h | 6 ++++++
 samples/vfs/test-statx.c   | 9 +++++++++
 2 files changed, 15 insertions(+)

-- 
2.51.1

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

* [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases
  2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
@ 2025-11-09  7:13   ` Masaharu Noguchi
  2025-11-09 16:13     ` David Laight
  2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
  1 sibling, 1 reply; 5+ messages in thread
From: Masaharu Noguchi @ 2025-11-09  7:13 UTC (permalink / raw)
  To: jesperjuhl76, Jeff Layton, Chuck Lever
  Cc: Alexander Aring, linux-fsdevel, linux-kernel, Masaharu Noguchi

Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
---
 include/uapi/linux/fcntl.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index 3741ea1b73d8..e3026381fbe7 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -157,9 +157,15 @@
  */
 
 /* Flags for renameat2(2) (must match legacy RENAME_* flags). */
+#ifndef AT_RENAME_NOREPLACE
 #define AT_RENAME_NOREPLACE	0x0001
+#endif
+#ifndef AT_RENAME_EXCHANGE
 #define AT_RENAME_EXCHANGE	0x0002
+#endif
+#ifndef AT_RENAME_WHITEOUT
 #define AT_RENAME_WHITEOUT	0x0004
+#endif
 
 /* Flag for faccessat(2). */
 #define AT_EACCESS		0x200	/* Test access permitted for
-- 
2.51.1


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

* [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
  2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
  2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
@ 2025-11-09  7:13   ` Masaharu Noguchi
  2025-11-09 16:04     ` David Laight
  1 sibling, 1 reply; 5+ messages in thread
From: Masaharu Noguchi @ 2025-11-09  7:13 UTC (permalink / raw)
  To: jesperjuhl76, Jeff Layton, Chuck Lever
  Cc: Alexander Aring, linux-fsdevel, linux-kernel, Masaharu Noguchi

Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
---
 samples/vfs/test-statx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
index 49c7a46cee07..eabea80e9db8 100644
--- a/samples/vfs/test-statx.c
+++ b/samples/vfs/test-statx.c
@@ -20,6 +20,15 @@
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <linux/stat.h>
+#ifdef AT_RENAME_NOREPLACE
+#undef AT_RENAME_NOREPLACE
+#endif
+#ifdef AT_RENAME_EXCHANGE
+#undef AT_RENAME_EXCHANGE
+#endif
+#ifdef AT_RENAME_WHITEOUT
+#undef AT_RENAME_WHITEOUT
+#endif
 #include <linux/fcntl.h>
 #define statx foo
 #define statx_timestamp foo_timestamp
-- 
2.51.1


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

* Re: [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
  2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
@ 2025-11-09 16:04     ` David Laight
  0 siblings, 0 replies; 5+ messages in thread
From: David Laight @ 2025-11-09 16:04 UTC (permalink / raw)
  To: Masaharu Noguchi
  Cc: jesperjuhl76, Jeff Layton, Chuck Lever, Alexander Aring,
	linux-fsdevel, linux-kernel

On Sun,  9 Nov 2025 16:13:04 +0900
Masaharu Noguchi <nogunix@gmail.com> wrote:

> Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
> ---
>  samples/vfs/test-statx.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
> index 49c7a46cee07..eabea80e9db8 100644
> --- a/samples/vfs/test-statx.c
> +++ b/samples/vfs/test-statx.c
> @@ -20,6 +20,15 @@
>  #include <sys/syscall.h>
>  #include <sys/types.h>
>  #include <linux/stat.h>
> +#ifdef AT_RENAME_NOREPLACE
> +#undef AT_RENAME_NOREPLACE
> +#endif
> +#ifdef AT_RENAME_EXCHANGE
> +#undef AT_RENAME_EXCHANGE
> +#endif
> +#ifdef AT_RENAME_WHITEOUT
> +#undef AT_RENAME_WHITEOUT
> +#endif

There is no need for the #if, just #undef the symbols.
It is probably worthy of a short comment.

	David

>  #include <linux/fcntl.h>
>  #define statx foo
>  #define statx_timestamp foo_timestamp


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

* Re: [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases
  2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
@ 2025-11-09 16:13     ` David Laight
  0 siblings, 0 replies; 5+ messages in thread
From: David Laight @ 2025-11-09 16:13 UTC (permalink / raw)
  To: Masaharu Noguchi
  Cc: jesperjuhl76, Jeff Layton, Chuck Lever, Alexander Aring,
	linux-fsdevel, linux-kernel

On Sun,  9 Nov 2025 16:13:03 +0900
Masaharu Noguchi <nogunix@gmail.com> wrote:

> Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
> ---
>  include/uapi/linux/fcntl.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
> index 3741ea1b73d8..e3026381fbe7 100644
> --- a/include/uapi/linux/fcntl.h
> +++ b/include/uapi/linux/fcntl.h
> @@ -157,9 +157,15 @@
>   */
>  
>  /* Flags for renameat2(2) (must match legacy RENAME_* flags). */
> +#ifndef AT_RENAME_NOREPLACE
>  #define AT_RENAME_NOREPLACE	0x0001
> +#endif
> +#ifndef AT_RENAME_EXCHANGE
>  #define AT_RENAME_EXCHANGE	0x0002
> +#endif
> +#ifndef AT_RENAME_WHITEOUT
>  #define AT_RENAME_WHITEOUT	0x0004
> +#endif

That looks like the start of an 'accident waiting to happen'.
Either #undef the constants so that code is guaranteed to get the 'uapi' values,
or do explicit checks, eg:

/* stdio.h may have defined AT_RENAME_NOREPLACE */
#if !defined(AT_RENAME_NOREPLACE) || AT_RENAME_NOREPLACE != 0x0001
#define AT_RENAME_NOREPLACE 0x0001
#endif

	David


>  
>  /* Flag for faccessat(2). */
>  #define AT_EACCESS		0x200	/* Test access permitted for


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

end of thread, other threads:[~2025-11-09 16:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAHaCkme7C8LDpWVX8TnDQQ+feWeQy_SA3HYfpyyPNFee_+Z2EA@mail.gmail.com>
2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
2025-11-09 16:13     ` David Laight
2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
2025-11-09 16:04     ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).