public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] aarch64: morello: fix missing variadic argument in fcntl
@ 2022-10-27 13:53 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-27 13:53 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ab9182522f8de407c2447239ddb1f12218f43a15

commit ab9182522f8de407c2447239ddb1f12218f43a15
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Jul 15 14:10:53 2022 +0100

    aarch64: morello: fix missing variadic argument in fcntl
    
    In fcntl va_arg is currently used even if the caller did not pass
    any variadic arguments. This is undefined behaviour and does not
    work with the Morello purecap ABI, so use a helper macro.
    
    When the argument is missing, the result of the helper macro is
    arbitrary as it will be ignored by the kernel, we just have to
    ensure it does not cause a runtime crash.

Diff:
---
 sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h | 2 ++
 sysdeps/unix/sysv/linux/fcntl64.c                | 6 +++++-
 sysdeps/unix/sysv/linux/fcntl_nocancel.c         | 6 +++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
index 5db89b096d..bad64a0674 100644
--- a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
@@ -105,6 +105,8 @@ typedef __intcap_t __sysarg_t;
   LOAD_ARGS_6 (c0, c1, c2, c3, c4, c5)		\
   register __sysarg_t _x6 asm ("c6") = _x6tmp;
 
+# define FCNTL_VA_ARG(a, t) (a ? va_arg(a, t) : 0)
+
 #endif	/* __ASSEMBLER__ */
 
 /* Disable pointer mangling for purecap ABI.  */
diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c
index 5192b2d672..0b6afd3b59 100644
--- a/sysdeps/unix/sysv/linux/fcntl64.c
+++ b/sysdeps/unix/sysv/linux/fcntl64.c
@@ -29,6 +29,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -40,7 +44,7 @@ __libc_fcntl64 (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index 7c38e22399..f21b56d95b 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -26,6 +26,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -37,7 +41,7 @@ __fcntl64_nocancel (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);

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

* [glibc/arm/morello/main] aarch64: morello: fix missing variadic argument in fcntl
@ 2022-11-23 14:43 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-11-23 14:43 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=868b753880f56e598c62c5345769064d35cf9687

commit 868b753880f56e598c62c5345769064d35cf9687
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Jul 15 14:10:53 2022 +0100

    aarch64: morello: fix missing variadic argument in fcntl
    
    In fcntl va_arg is currently used even if the caller did not pass
    any variadic arguments. This is undefined behaviour and does not
    work with the Morello purecap ABI, so use a helper macro.
    
    When the argument is missing, the result of the helper macro is
    arbitrary as it will be ignored by the kernel, we just have to
    ensure it does not cause a runtime crash.

Diff:
---
 sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h | 2 ++
 sysdeps/unix/sysv/linux/fcntl64.c                | 6 +++++-
 sysdeps/unix/sysv/linux/fcntl_nocancel.c         | 6 +++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
index 5db89b096d..bad64a0674 100644
--- a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
@@ -105,6 +105,8 @@ typedef __intcap_t __sysarg_t;
   LOAD_ARGS_6 (c0, c1, c2, c3, c4, c5)		\
   register __sysarg_t _x6 asm ("c6") = _x6tmp;
 
+# define FCNTL_VA_ARG(a, t) (a ? va_arg(a, t) : 0)
+
 #endif	/* __ASSEMBLER__ */
 
 /* Disable pointer mangling for purecap ABI.  */
diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c
index 5192b2d672..0b6afd3b59 100644
--- a/sysdeps/unix/sysv/linux/fcntl64.c
+++ b/sysdeps/unix/sysv/linux/fcntl64.c
@@ -29,6 +29,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -40,7 +44,7 @@ __libc_fcntl64 (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index 7c38e22399..f21b56d95b 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -26,6 +26,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -37,7 +41,7 @@ __fcntl64_nocancel (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);

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

* [glibc/arm/morello/main] aarch64: morello: fix missing variadic argument in fcntl
@ 2022-10-26 15:14 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:14 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=909759bc11edf5ce396a384bcc3f9d7c465f14a4

commit 909759bc11edf5ce396a384bcc3f9d7c465f14a4
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Jul 15 14:10:53 2022 +0100

    aarch64: morello: fix missing variadic argument in fcntl
    
    In fcntl va_arg is currently used even if the caller did not pass
    any variadic arguments. This is undefined behaviour and does not
    work with the Morello purecap ABI, so use a helper macro.
    
    When the argument is missing, the result of the helper macro is
    arbitrary as it will be ignored by the kernel, we just have to
    ensure it does not cause a runtime crash.

Diff:
---
 sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h | 2 ++
 sysdeps/unix/sysv/linux/fcntl64.c                | 6 +++++-
 sysdeps/unix/sysv/linux/fcntl_nocancel.c         | 6 +++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
index 5db89b096d..bad64a0674 100644
--- a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
@@ -105,6 +105,8 @@ typedef __intcap_t __sysarg_t;
   LOAD_ARGS_6 (c0, c1, c2, c3, c4, c5)		\
   register __sysarg_t _x6 asm ("c6") = _x6tmp;
 
+# define FCNTL_VA_ARG(a, t) (a ? va_arg(a, t) : 0)
+
 #endif	/* __ASSEMBLER__ */
 
 /* Disable pointer mangling for purecap ABI.  */
diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c
index 5192b2d672..0b6afd3b59 100644
--- a/sysdeps/unix/sysv/linux/fcntl64.c
+++ b/sysdeps/unix/sysv/linux/fcntl64.c
@@ -29,6 +29,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -40,7 +44,7 @@ __libc_fcntl64 (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index 7c38e22399..f21b56d95b 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -26,6 +26,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -37,7 +41,7 @@ __fcntl64_nocancel (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);

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

* [glibc/arm/morello/main] aarch64: morello: fix missing variadic argument in fcntl
@ 2022-08-05 19:32 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-08-05 19:32 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ed90470cc02574d8a0f1aae6c38089b43cc6e5f6

commit ed90470cc02574d8a0f1aae6c38089b43cc6e5f6
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Jul 15 14:10:53 2022 +0100

    aarch64: morello: fix missing variadic argument in fcntl
    
    In fcntl va_arg is currently used even if the caller did not pass
    any variadic arguments. This is undefined behaviour and does not
    work with the Morello purecap ABI, so use a helper macro.
    
    When the argument is missing, the result of the helper macro is
    arbitrary as it will be ignored by the kernel, we just have to
    ensure it does not cause a runtime crash.

Diff:
---
 sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h | 2 ++
 sysdeps/unix/sysv/linux/fcntl64.c                | 6 +++++-
 sysdeps/unix/sysv/linux/fcntl_nocancel.c         | 6 +++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
index 5db89b096d..bad64a0674 100644
--- a/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/morello/sysdep.h
@@ -105,6 +105,8 @@ typedef __intcap_t __sysarg_t;
   LOAD_ARGS_6 (c0, c1, c2, c3, c4, c5)		\
   register __sysarg_t _x6 asm ("c6") = _x6tmp;
 
+# define FCNTL_VA_ARG(a, t) (a ? va_arg(a, t) : 0)
+
 #endif	/* __ASSEMBLER__ */
 
 /* Disable pointer mangling for purecap ABI.  */
diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c
index 5192b2d672..0b6afd3b59 100644
--- a/sysdeps/unix/sysv/linux/fcntl64.c
+++ b/sysdeps/unix/sysv/linux/fcntl64.c
@@ -29,6 +29,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -40,7 +44,7 @@ __libc_fcntl64 (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index 7c38e22399..f21b56d95b 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -26,6 +26,10 @@
 # define __NR_fcntl64 __NR_fcntl
 #endif
 
+#ifndef FCNTL_VA_ARG
+# define FCNTL_VA_ARG(a, t) va_arg(a, t)
+#endif
+
 #ifndef FCNTL_ADJUST_CMD
 # define FCNTL_ADJUST_CMD(__cmd) __cmd
 #endif
@@ -37,7 +41,7 @@ __fcntl64_nocancel (int fd, int cmd, ...)
   void *arg;
 
   va_start (ap, cmd);
-  arg = va_arg (ap, void *);
+  arg = FCNTL_VA_ARG (ap, void *);
   va_end (ap);
 
   cmd = FCNTL_ADJUST_CMD (cmd);


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

end of thread, other threads:[~2022-11-23 14:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 13:53 [glibc/arm/morello/main] aarch64: morello: fix missing variadic argument in fcntl Szabolcs Nagy
  -- strict thread matches above, loose matches on Subject: below --
2022-11-23 14:43 Szabolcs Nagy
2022-10-26 15:14 Szabolcs Nagy
2022-08-05 19:32 Szabolcs Nagy

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 read-only IMAP folder(s) and NNTP newsgroup(s).