All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] compat: update linux/compat.h and kernel/sys_ni.c
@ 2022-08-22 19:43 Randy Dunlap
  2022-08-22 20:46 ` Andrew Morton
  2022-08-25 14:38 ` Arnd Bergmann
  0 siblings, 2 replies; 4+ messages in thread
From: Randy Dunlap @ 2022-08-22 19:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Randy Dunlap, Arnd Bergmann, Andrew Morton

Add conditional syscalls entries in kernel/sys_ni.c
for any syscalls that are arch- or config-dependent.

Update the prototype entries in <linux/compat.h>.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 include/linux/compat.h |   27 ++++++---------------------
 kernel/sys_ni.c        |   20 ++++++++++++++++++--
 2 files changed, 24 insertions(+), 23 deletions(-)

--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -610,7 +610,7 @@ asmlinkage long compat_sys_fcntl64(unsig
 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
 				 compat_ulong_t arg);
 
-/* fs/open.c */
+/* fs/statfs.c */
 asmlinkage long compat_sys_statfs(const char __user *pathname,
 				  struct compat_statfs __user *buf);
 asmlinkage long compat_sys_statfs64(const char __user *pathname,
@@ -620,6 +620,8 @@ asmlinkage long compat_sys_fstatfs(unsig
 				   struct compat_statfs __user *buf);
 asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
 				     struct compat_statfs64 __user *buf);
+
+/* fs/open.c */
 asmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
 asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t);
 /* No generic prototype for truncate64, ftruncate64, fallocate */
@@ -640,17 +642,12 @@ asmlinkage ssize_t compat_sys_preadv(com
 asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
 		const struct iovec __user *vec,
 		compat_ulong_t vlen, u32 pos_low, u32 pos_high);
-#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
 asmlinkage long compat_sys_preadv64(unsigned long fd,
 		const struct iovec __user *vec,
 		unsigned long vlen, loff_t pos);
-#endif
-
-#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
 asmlinkage long compat_sys_pwritev64(unsigned long fd,
 		const struct iovec __user *vec,
 		unsigned long vlen, loff_t pos);
-#endif
 
 /* fs/sendfile.c */
 asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
@@ -702,7 +699,7 @@ asmlinkage long compat_sys_waitid(int, c
 
 
 
-/* kernel/futex.c */
+/* kernel/futex/syscalls.c */
 asmlinkage long
 compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
 			   compat_size_t len);
@@ -816,7 +813,7 @@ asmlinkage long compat_sys_sendmsg(int f
 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
 				   unsigned int flags);
 
-/* mm/filemap.c: No generic prototype for readahead */
+/* mm/readahead.c: No generic prototype for readahead */
 
 /* security/keys/keyctl.c */
 asmlinkage long compat_sys_keyctl(u32 option,
@@ -857,18 +854,12 @@ asmlinkage ssize_t compat_sys_preadv2(co
 asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,
 		const struct iovec __user *vec,
 		compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
-#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2
 asmlinkage long  compat_sys_preadv64v2(unsigned long fd,
 		const struct iovec __user *vec,
 		unsigned long vlen, loff_t pos, rwf_t flags);
-#endif
-
-#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2
 asmlinkage long compat_sys_pwritev64v2(unsigned long fd,
 		const struct iovec __user *vec,
 		unsigned long vlen, loff_t pos, rwf_t flags);
-#endif
-
 
 /*
  * Deprecated system calls which are still defined in
@@ -910,19 +901,13 @@ asmlinkage long compat_sys_old_select(st
 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
 
 /* obsolete: kernel/signal.c */
-#ifdef __ARCH_WANT_SYS_SIGPENDING
 asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set);
-#endif
-
-#ifdef __ARCH_WANT_SYS_SIGPROCMASK
 asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset,
 				       compat_old_sigset_t __user *oset);
-#endif
-#ifdef CONFIG_COMPAT_OLD_SIGACTION
+struct compat_old_sigaction;
 asmlinkage long compat_sys_sigaction(int sig,
                                    const struct compat_old_sigaction __user *act,
                                    struct compat_old_sigaction __user *oact);
-#endif
 
 /* obsolete: net/socket.c */
 asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -63,7 +63,7 @@ COND_SYSCALL_COMPAT(lookup_dcookie);
 /* fs/eventfd.c */
 COND_SYSCALL(eventfd2);
 
-/* fs/eventfd.c */
+/* fs/eventpoll.c */
 COND_SYSCALL(epoll_create1);
 COND_SYSCALL(epoll_ctl);
 COND_SYSCALL(epoll_pwait);
@@ -94,6 +94,9 @@ COND_SYSCALL(flock);
 /* fs/nfsctl.c */
 
 /* fs/open.c */
+COND_SYSCALL_COMPAT(truncate64);
+COND_SYSCALL_COMPAT(ftruncate64);
+COND_SYSCALL_COMPAT(fallocate);
 
 /* fs/pipe.c */
 
@@ -104,6 +107,10 @@ COND_SYSCALL(quotactl_fd);
 /* fs/readdir.c */
 
 /* fs/read_write.c */
+COND_SYSCALL_COMPAT(preadv64);
+COND_SYSCALL_COMPAT(pwritev64);
+COND_SYSCALL_COMPAT(pread64);
+COND_SYSCALL_COMPAT(pwrite64);
 
 /* fs/sendfile.c */
 
@@ -118,6 +125,7 @@ COND_SYSCALL_COMPAT(signalfd4);
 /* fs/stat.c */
 
 /* fs/sync.c */
+COND_SYSCALL_COMPAT(sync_file_range);
 
 /* fs/timerfd.c */
 COND_SYSCALL(timerfd_create);
@@ -173,6 +181,11 @@ COND_SYSCALL(syslog);
 
 /* kernel/sched/core.c */
 
+/* kernel/signal.c */
+COND_SYSCALL_COMPAT(sigpending);
+COND_SYSCALL_COMPAT(sigprocmask);
+COND_SYSCALL_COMPAT(sigaction);
+
 /* kernel/sys.c */
 COND_SYSCALL(setregid);
 COND_SYSCALL(setgid);
@@ -257,7 +270,8 @@ COND_SYSCALL_COMPAT(sendmsg);
 COND_SYSCALL(recvmsg);
 COND_SYSCALL_COMPAT(recvmsg);
 
-/* mm/filemap.c */
+/* mm/readahead.c */
+COND_SYSCALL_COMPAT(readahead);
 
 /* mm/nommu.c, also with MMU */
 COND_SYSCALL(mremap);
@@ -306,6 +320,8 @@ COND_SYSCALL(recvmmsg);
 COND_SYSCALL(recvmmsg_time32);
 COND_SYSCALL_COMPAT(recvmmsg_time32);
 COND_SYSCALL_COMPAT(recvmmsg_time64);
+COND_SYSCALL_COMPAT(preadv64v2);
+COND_SYSCALL_COMPAT(pwritev64v2);
 
 /*
  * Architecture specific syscalls: see further below

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

* Re: [RFC PATCH] compat: update linux/compat.h and kernel/sys_ni.c
  2022-08-22 19:43 [RFC PATCH] compat: update linux/compat.h and kernel/sys_ni.c Randy Dunlap
@ 2022-08-22 20:46 ` Andrew Morton
  2022-08-25  0:36   ` Randy Dunlap
  2022-08-25 14:38 ` Arnd Bergmann
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2022-08-22 20:46 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel, Arnd Bergmann

On Mon, 22 Aug 2022 12:43:10 -0700 Randy Dunlap <rdunlap@infradead.org> wrote:

> Add conditional syscalls entries in kernel/sys_ni.c
> for any syscalls that are arch- or config-dependent.

What is the reason for this?  What effects does it have?

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

* Re: [RFC PATCH] compat: update linux/compat.h and kernel/sys_ni.c
  2022-08-22 20:46 ` Andrew Morton
@ 2022-08-25  0:36   ` Randy Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2022-08-25  0:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Arnd Bergmann



On 8/22/22 13:46, Andrew Morton wrote:
> On Mon, 22 Aug 2022 12:43:10 -0700 Randy Dunlap <rdunlap@infradead.org> wrote:
> 
>> Add conditional syscalls entries in kernel/sys_ni.c
>> for any syscalls that are arch- or config-dependent.
> 
> What is the reason for this?  What effects does it have?

Hi Andrew,

For <linux/compat.h> it's mostly a cleanup/completeness change,
as suggested by Arnd here:
  https://lore.kernel.org/lkml/CAK8P3a140FFhCvrOXbCtYKCW6BR6tEz6uy8Wqd0aG3DdHiZSXg@mail.gmail.com/


For kernel/sys_ni.c, it adds compat syscalls that are arch- or
config-dependent, to prevent the possibility of linker errors.

I have successfully built allnoconfig, defconfig, and allmodconfig for around 20
architectures with this patch applied.

-- 
~Randy

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

* Re: [RFC PATCH] compat: update linux/compat.h and kernel/sys_ni.c
  2022-08-22 19:43 [RFC PATCH] compat: update linux/compat.h and kernel/sys_ni.c Randy Dunlap
  2022-08-22 20:46 ` Andrew Morton
@ 2022-08-25 14:38 ` Arnd Bergmann
  1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2022-08-25 14:38 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel, Arnd Bergmann, Andrew Morton

On Mon, Aug 22, 2022 at 9:43 PM Randy Dunlap <rdunlap@infradead.org> wrote:

>   * Deprecated system calls which are still defined in
> @@ -910,19 +901,13 @@ asmlinkage long compat_sys_old_select(st
> -#ifdef CONFIG_COMPAT_OLD_SIGACTION
> +struct compat_old_sigaction;
>  asmlinkage long compat_sys_sigaction(int sig,
>                                     const struct compat_old_sigaction __user *act,
>                                     struct compat_old_sigaction __user *oact);
> -#endif

All the removed #ifdef look good to me here, and I checked that there
are no conflicting prototypes for the ones you change.

For COND_SYSCALL_COMPAT(), I think they should not be part of
this patch, and only added for specific optional calls that would cause
a link failure.

> @@ -94,6 +94,9 @@ COND_SYSCALL(flock);
>  /* fs/nfsctl.c */
>
>  /* fs/open.c */
> +COND_SYSCALL_COMPAT(truncate64);
> +COND_SYSCALL_COMPAT(ftruncate64);
> +COND_SYSCALL_COMPAT(fallocate);

COND_SYSCALL_COMPAT() doesn't really make sense for non-optional syscalls
like these: if an architecture neither sets __ARCH_WANT_COMPAT_FALLOCATE
nor provides its own implementation, then a link failure is the
appropriate output, hiding it with a COND_SYSCALL_COMPAT() just turns that
into a runtime failure that is harder to analyse.

>  /* fs/read_write.c */
> +COND_SYSCALL_COMPAT(preadv64);
> +COND_SYSCALL_COMPAT(pwritev64);
> +COND_SYSCALL_COMPAT(pread64);
> +COND_SYSCALL_COMPAT(pwrite64);

These are specific to x32, and we don't want to ever add them to another
architecture, so they should not get a COND_SYSCALL_COMPAT()
either.

> @@ -118,6 +125,7 @@ COND_SYSCALL_COMPAT(signalfd4);
>  /* fs/sync.c */
> +COND_SYSCALL_COMPAT(sync_file_range);
....
> +COND_SYSCALL_COMPAT(readahead);

Same as above, but these have an additional angle to them, as
there are conflicting prototypes and implementations:

arch/sparc/kernel/systbls.h:long compat_sys_sync_file_range(unsigned int fd,
arch/sparc/kernel/systbls.h-                       unsigned off_high,
unsigned off_low,
arch/sparc/kernel/systbls.h-                       unsigned nb_high,
unsigned nb_low,
include/linux/compat.h:asmlinkage long compat_sys_sync_file_range(int
fd, compat_arg_u64(pos),
include/linux/compat.h-
compat_arg_u64(nbytes), unsigned int flags);

The current code works fine, but if you still want to improve this,
it would be great to convert the architecture specific helpers
to be shared with the common ones. For those that have non-matching
prototypes like

include/linux/compat.h:asmlinkage long compat_sys_pwrite64(unsigned
int fd, const char __user *buf, size_t count,
include/linux/compat.h-                             compat_arg_u64(pos));
arch/powerpc/include/asm/syscalls.h:compat_ssize_t
compat_sys_pwrite64(unsigned int fd, const char __user *ubuf,
compat_size_t count,
arch/powerpc/include/asm/syscalls.h-                               u32
reg6, u32 pos1, u32 pos2);

that have an extra argument in them, I would instead suggest renaming
the nonstandard ones.

       Arnd

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

end of thread, other threads:[~2022-08-25 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22 19:43 [RFC PATCH] compat: update linux/compat.h and kernel/sys_ni.c Randy Dunlap
2022-08-22 20:46 ` Andrew Morton
2022-08-25  0:36   ` Randy Dunlap
2022-08-25 14:38 ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.