diff mbox series

[RFC] sysvipc: Fix handling of direct syscalls

Message ID 20200501221733.14456-1-shorne@gmail.com
State Not Applicable
Headers show
Series [RFC] sysvipc: Fix handling of direct syscalls | expand

Commit Message

Stafford Horne May 1, 2020, 10:17 p.m. UTC
Working on the OpenRISC port I get an error that __NR_ipc is not
defined using the default kernel-features.h with kernel 5.7.

It seems this would also impact riscv and csky that also do not
do any special SYSVIPC defines or use __NR_ipc.

Compiler output:

In file included from ../sysdeps/unix/sysv/linux/msgctl.c:21:
../sysdeps/unix/sysv/linux/msgctl.c: In function '__old_msgctl':
../sysdeps/unix/sysv/linux/or1k/sysdep.h:23:34: error: '__NR_ipc' undeclared (first use in this function)
   23 | #define SYS_ify(syscall_name)   (__NR_##syscall_name)
      |                                  ^~~~~
../sysdeps/unix/sysv/linux/or1k/sysdep.h:103:35: note: in definition of macro 'INTERNAL_SYSCALL_NCS'
  103 |             long _sc_ret = (long) number;                                      \
      |                                   ^~~~~~
../sysdeps/unix/sysv/linux/or1k/sysdep.h:96:24: note: in expansion of macro 'SYS_ify'
   96 |  INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
      |                        ^~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro 'INTERNAL_SYSCALL'
   43 |     long int sc_ret = INTERNAL_SYSCALL (name, nr, args);  \
      |                       ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:71:3: note: in expansion of macro 'INLINE_SYSCALL'
   71 |   INLINE_SYSCALL (name, 5, a1, a2, a3, a4, a5)
      |   ^~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:27:37: note: in expansion of macro '__INLINE_SYSCALL5'
   27 | #define __SYSCALL_CONCAT_X(a,b)     a##b
      |                                     ^
../sysdeps/unix/sysdep.h:28:37: note: in expansion of macro '__SYSCALL_CONCAT_X'
   28 | #define __SYSCALL_CONCAT(a,b)       __SYSCALL_CONCAT_X (a, b)
      |                                     ^~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:81:3: note: in expansion of macro '__SYSCALL_CONCAT'
   81 |   __SYSCALL_CONCAT (b,__INLINE_SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
      |   ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:89:3: note: in expansion of macro '__INLINE_SYSCALL_DISP'
   89 |   __INLINE_SYSCALL_DISP (__INLINE_SYSCALL, __VA_ARGS__)
      |   ^~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/msgctl.c:127:10: note: in expansion of macro 'INLINE_SYSCALL_CALL'
  127 |   return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
---
 sysdeps/unix/sysv/linux/msgctl.c | 8 ++------
 sysdeps/unix/sysv/linux/semctl.c | 9 +++------
 sysdeps/unix/sysv/linux/shmctl.c | 8 ++------
 3 files changed, 7 insertions(+), 18 deletions(-)

Comments

Andreas Schwab May 2, 2020, 6:55 a.m. UTC | #1
On Mai 02 2020, Stafford Horne via Libc-alpha wrote:

> ../sysdeps/unix/sysv/linux/msgctl.c:127:10: note: in expansion of macro 'INLINE_SYSCALL_CALL'
>   127 |   return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);

This is pre-2.2 compat code.  Why does the compiler even get that far?

Andreas.
Stafford Horne May 2, 2020, 8:41 a.m. UTC | #2
On Sat, May 02, 2020 at 08:55:35AM +0200, Andreas Schwab wrote:
> On Mai 02 2020, Stafford Horne via Libc-alpha wrote:
> 
> > ../sysdeps/unix/sysv/linux/msgctl.c:127:10: note: in expansion of macro 'INLINE_SYSCALL_CALL'
> >   127 |   return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
> 
> This is pre-2.2 compat code.  Why does the compiler even get that far?

Thanks for your comment,

For some reason I didn't notice this was all wrapped by SHLIB_COMPAT,  your
comment helped me to double check.

I'll figure out why it's still trying to compile the compat API's, this patch
should not be needed.

-Stafford
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c
index fd46aec1a0..a49c1e81fa 100644
--- a/sysdeps/unix/sysv/linux/msgctl.c
+++ b/sysdeps/unix/sysv/linux/msgctl.c
@@ -117,12 +117,8 @@  int
 attribute_compat_text_section
 __old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
 {
-#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS \
-    && !defined __ASSUME_SYSVIPC_DEFAULT_IPC_64
-  /* For architecture that have wire-up msgctl but also have __IPC_64 to a
-     value different than default (0x0) it means the compat symbol used the
-     __NR_ipc syscall.  */
-  return INLINE_SYSCALL_CALL (msgctl, msqid, cmd, buf);
+#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, buf);
 #else
   return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
 #endif
diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
index 30571af49f..ba3d0b206c 100644
--- a/sysdeps/unix/sysv/linux/semctl.c
+++ b/sysdeps/unix/sysv/linux/semctl.c
@@ -174,12 +174,9 @@  __old_semctl (int semid, int semnum, int cmd, ...)
       break;
     }
 
-#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS \
-    && !defined __ASSUME_SYSVIPC_DEFAULT_IPC_64
- /* For architectures that have wire-up semctl but also have __IPC_64 to a
-    value different than default (0x0) it means the compat symbol used the
-    __NR_ipc syscall.  */
-  return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd, arg.array);
+#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64,
+			      arg.array);
 # else
   return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd,
 			      SEMCTL_ARG_ADDRESS (arg));
diff --git a/sysdeps/unix/sysv/linux/shmctl.c b/sysdeps/unix/sysv/linux/shmctl.c
index f41b359b8b..c97db208c6 100644
--- a/sysdeps/unix/sysv/linux/shmctl.c
+++ b/sysdeps/unix/sysv/linux/shmctl.c
@@ -117,12 +117,8 @@  int
 attribute_compat_text_section
 __old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
 {
-#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS \
-    && !defined __ASSUME_SYSVIPC_DEFAULT_IPC_64
-  /* For architecture that have wire-up shmctl but also have __IPC_64 to a
-     value different than default (0x0), it means the compat symbol used the
-     __NR_ipc syscall.  */
-  return INLINE_SYSCALL_CALL (shmctl, shmid, cmd, buf);
+#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (shmctl, shmid, cmd | __IPC_64, buf);
 #else
   return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd, 0, buf);
 #endif