Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux32/common add prlimit64(2) syscall to COMPAT...



details:   https://anonhg.NetBSD.org/src/rev/ecc1fab6ee38
branches:  trunk
changeset: 1026598:ecc1fab6ee38
user:      ryo <ryo%NetBSD.org@localhost>
date:      Thu Dec 02 04:29:47 2021 +0000

description:
add prlimit64(2) syscall to COMPAT_LINUX and COMPAT_LINUX32

diffstat:

 sys/compat/linux/arch/aarch64/syscalls.master   |   5 +-
 sys/compat/linux/arch/alpha/syscalls.master     |   5 +-
 sys/compat/linux/arch/amd64/syscalls.master     |   5 +-
 sys/compat/linux/arch/arm/syscalls.master       |   5 +-
 sys/compat/linux/arch/i386/syscalls.master      |   5 +-
 sys/compat/linux/arch/m68k/syscalls.master      |   5 +-
 sys/compat/linux/arch/mips/syscalls.master      |   5 +-
 sys/compat/linux/arch/powerpc/syscalls.master   |   5 +-
 sys/compat/linux/common/linux_limit.h           |  23 ++++++++----
 sys/compat/linux/common/linux_misc.c            |  46 +++++++++++++++++++++++-
 sys/compat/linux32/arch/aarch64/syscalls.master |   5 +-
 sys/compat/linux32/arch/amd64/syscalls.master   |   5 +-
 sys/compat/linux32/common/linux32_resource.c    |  46 +++++++++++++++++++++++-
 13 files changed, 133 insertions(+), 32 deletions(-)

diffs (truncated from 368 to 300 lines):

diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/aarch64/syscalls.master
--- a/sys/compat/linux/arch/aarch64/syscalls.master     Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/aarch64/syscalls.master     Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.3 2021/11/25 02:29:33 ryo Exp $
+       $NetBSD: syscalls.master,v 1.4 2021/12/02 04:29:47 ryo Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -490,7 +490,8 @@
 259    UNIMPL
 260    STD             { int|linux_sys||wait4(int pid, int *status, \
                            int options, struct rusage50 *rusage); }
-261    UNIMPL          prlimit64
+261    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 262    UNIMPL          fanotify_init
 263    UNIMPL          fanotify_mark
 264    UNIMPL          name_to_handle_at
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/alpha/syscalls.master
--- a/sys/compat/linux/arch/alpha/syscalls.master       Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/alpha/syscalls.master       Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.101 2021/09/20 02:20:02 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.102 2021/12/02 04:29:47 ryo Exp $
 ;
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -794,7 +794,8 @@
 493    UNIMPL          perf_counter_open
 494    UNIMPL          fanotify_init
 495    UNIMPL          fanotify_mark
-496    UNIMPL          prlimit64
+496    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 497    UNIMPL          name_to_handle_at
 498    UNIMPL          open_by_handle_at
 499    UNIMPL          clock_adjtime
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/amd64/syscalls.master
--- a/sys/compat/linux/arch/amd64/syscalls.master       Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/amd64/syscalls.master       Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.66 2021/09/20 02:20:02 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.67 2021/12/02 04:29:48 ryo Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -552,7 +552,8 @@
                            unsigned int flags, struct timespec *timeout); }
 300    UNIMPL          fanotify_init
 301    UNIMPL          fanotify_mark
-302    UNIMPL          prlimit64
+302    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 303    UNIMPL          name_to_handle_at
 304    UNIMPL          open_by_handle_at
 305    UNIMPL          clock_adjtime
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/arm/syscalls.master
--- a/sys/compat/linux/arch/arm/syscalls.master Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/arm/syscalls.master Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.74 2021/11/24 18:52:13 ryo Exp $
+       $NetBSD: syscalls.master,v 1.75 2021/12/02 04:29:48 ryo Exp $
 
 ; Derived from sys/compat/linux/arch/*/syscalls.master
 ; and from Linux 2.4.12 arch/arm/kernel/calls.S
@@ -595,7 +595,8 @@
                            int *anamelen, int flags); }
 367    UNIMPL          fanotify_init
 368    UNIMPL          fanotify_mark
-369    UNIMPL          prlimit64
+369    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 370    UNIMPL          name_to_handle_at
 371    UNIMPL          open_by_handle_at
 372    UNIMPL          clock_adjtime
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/i386/syscalls.master
--- a/sys/compat/linux/arch/i386/syscalls.master        Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/i386/syscalls.master        Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.128 2021/09/20 02:20:02 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.129 2021/12/02 04:29:48 ryo Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -557,7 +557,8 @@
 337    UNIMPL          recvmmsg
 338    UNIMPL          fanotify_init
 339    UNIMPL          fanotify_mark
-340    UNIMPL          prlimit64
+340    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 341    UNIMPL          name_to_handle_at
 342    UNIMPL          open_by_handle_at
 343    UNIMPL          clock_adjtime
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/m68k/syscalls.master
--- a/sys/compat/linux/arch/m68k/syscalls.master        Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/m68k/syscalls.master        Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.100 2021/11/24 18:52:13 ryo Exp $
+       $NetBSD: syscalls.master,v 1.101 2021/12/02 04:29:48 ryo Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -578,7 +578,8 @@
 336    UNIMPL          atomic_barrier
 337    UNIMPL          fanotify_init
 338    UNIMPL          fanotify_mark
-339    UNIMPL          prlimit64
+339    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 340    UNIMPL          name_to_handle_at
 341    UNIMPL          open_by_handle_at
 342    UNIMPL          clock_adjtime
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/mips/syscalls.master
--- a/sys/compat/linux/arch/mips/syscalls.master        Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/mips/syscalls.master        Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.73 2021/11/24 18:52:13 ryo Exp $  
+       $NetBSD: syscalls.master,v 1.74 2021/12/02 04:29:48 ryo Exp $  
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -570,7 +570,8 @@
 336    UNIMPL          getdents64
 337    UNIMPL          fanotify_init
 338    UNIMPL          fanotify_mark
-339    UNIMPL          prlimit64
+339    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 340    UNIMPL          name_to_handle_at
 341    UNIMPL          open_by_handle_at
 342    UNIMPL          clock_adjtime
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/arch/powerpc/syscalls.master
--- a/sys/compat/linux/arch/powerpc/syscalls.master     Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/arch/powerpc/syscalls.master     Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.79 2021/11/24 18:52:13 ryo Exp $  
+       $NetBSD: syscalls.master,v 1.80 2021/12/02 04:29:48 ryo Exp $  
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -562,7 +562,8 @@
 322    UNIMPL          rt_tgsigqueueinfo
 323    UNIMPL          fanotify_init
 324    UNIMPL          fanotify_mark
-325    UNIMPL          prlimit64
+325    STD             { int|linux_sys||prlimit64(pid_t pid, int which, \
+                           struct rlimit *new_rlp, struct rlimit *old_rlp); }
 326    UNIMPL          socket
 327    UNIMPL          bind
 328    UNIMPL          connect
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/common/linux_limit.h
--- a/sys/compat/linux/common/linux_limit.h     Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/common/linux_limit.h     Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_limit.h,v 1.7 2015/02/28 13:08:00 njoly Exp $ */
+/*     $NetBSD: linux_limit.h,v 1.8 2021/12/02 04:29:48 ryo Exp $ */
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -35,20 +35,27 @@
 
 static int linux_to_bsd_limit(int);
 
-#ifdef LINUX_LARGEFILE64
-#define bsd_to_linux_rlimit1(l, b, f) \
+#define bsd_to_linux_rlimit64_1(l, b, f) \
     (l)->f = ((b)->f == RLIM_INFINITY || \
             ((b)->f & 0x8000000000000000UL) != 0) ? \
     LINUX_RLIM_INFINITY : (b)->f
-#else
-#define bsd_to_linux_rlimit1(l, b, f) \
+#define bsd_to_linux_rlimit32_1(l, b, f) \
     (l)->f = ((b)->f == RLIM_INFINITY || \
             ((b)->f & 0xffffffff00000000ULL) != 0) ? \
     LINUX_RLIM_INFINITY : (int32_t)(b)->f
+
+#define bsd_to_linux_rlimit64(l, b) \
+    bsd_to_linux_rlimit64_1(l, b, rlim_cur); \
+    bsd_to_linux_rlimit64_1(l, b, rlim_max)
+#define bsd_to_linux_rlimit32(l, b) \
+    bsd_to_linux_rlimit32_1(l, b, rlim_cur); \
+    bsd_to_linux_rlimit32_1(l, b, rlim_max)
+
+#ifdef LINUX_LARGEFILE64
+#define bsd_to_linux_rlimit(l, b)      bsd_to_linux_rlimit64(l, b)
+#else
+#define bsd_to_linux_rlimit(l, b)      bsd_to_linux_rlimit32(l, b)
 #endif
-#define bsd_to_linux_rlimit(l, b) \
-    bsd_to_linux_rlimit1(l, b, rlim_cur); \
-    bsd_to_linux_rlimit1(l, b, rlim_max)
 
 #define linux_to_bsd_rlimit1(b, l, f) \
     (b)->f = (l)->f == LINUX_RLIM_INFINITY ? RLIM_INFINITY : (l)->f
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_misc.c,v 1.255 2021/11/25 03:08:04 ryo Exp $     */
+/*     $NetBSD: linux_misc.c,v 1.256 2021/12/02 04:29:48 ryo Exp $     */
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.255 2021/11/25 03:08:04 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.256 2021/12/02 04:29:48 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1452,6 +1452,48 @@
 }
 # endif
 
+int
+linux_sys_prlimit64(struct lwp *l, const struct linux_sys_prlimit64_args *uap, register_t *retval)
+{
+       /* {
+               syscallarg(pid_t) pid;
+               syscallarg(int) witch;
+               syscallarg(struct rlimit *) new_rlp;
+               syscallarg(struct rlimit *) old_rlp;
+       }; */
+       struct rlimit rl, nrl, orl;
+       struct rlimit *p;
+       int which;
+       int error;
+
+       /* XXX: Cannot operate any process other than its own */
+       if (SCARG(uap, pid) != 0)
+               return EPERM;
+
+       which = linux_to_bsd_limit(SCARG(uap, which));
+       if (which < 0)
+               return -which;
+
+       p = SCARG(uap, old_rlp);
+       if (p != NULL) {
+               memset(&orl, 0, sizeof(orl));
+               bsd_to_linux_rlimit64(&orl, &l->l_proc->p_rlimit[which]);
+               if ((error = copyout(&orl, p, sizeof(orl))) != 0)
+                       return error;
+       }
+
+       p = SCARG(uap, new_rlp);
+       if (p != NULL) {
+               if ((error = copyin(p, &nrl, sizeof(nrl))) != 0)
+                       return error;
+
+               linux_to_bsd_rlimit(&rl, &nrl);
+               return dosetrlimit(l, l->l_proc, which, &rl);
+       }
+
+       return 0;
+}
+
 /*
  * This gets called for unsupported syscalls. The difference to sys_nosys()
  * is that process does not get SIGSYS, the call just returns with ENOSYS.
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux32/arch/aarch64/syscalls.master
--- a/sys/compat/linux32/arch/aarch64/syscalls.master   Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux32/arch/aarch64/syscalls.master   Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.2 2021/11/27 21:15:07 ryo Exp $
+       $NetBSD: syscalls.master,v 1.3 2021/12/02 04:29:48 ryo Exp $
 
 ; NetBSD aarch64 COMPAT_LINUX32 system call name/number "master" file.
 ;
@@ -642,7 +642,8 @@
 366    UNIMPL  accept4
 367    UNIMPL  fanotify_init
 368    UNIMPL  fanotify_mark
-369    UNIMPL  prlimit64
+369    STD     { int|linux32_sys||prlimit64(pid_t pid, int which, \
+                   netbsd32_rlimitp_t new_rlp, netbsd32_rlimitp_t old_rlp); }
 370    UNIMPL  name_to_handle_at
 371    UNIMPL  open_by_handle_at
 372    UNIMPL  clock_adjtime
diff -r e9b8c5282b11 -r ecc1fab6ee38 sys/compat/linux32/arch/amd64/syscalls.master
--- a/sys/compat/linux32/arch/amd64/syscalls.master     Thu Dec 02 04:26:09 2021 +0000
+++ b/sys/compat/linux32/arch/amd64/syscalls.master     Thu Dec 02 04:29:47 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.76 2021/11/27 21:15:07 ryo Exp $
+       $NetBSD: syscalls.master,v 1.77 2021/12/02 04:29:48 ryo Exp $
 
 ; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file.
 ; (See syscalls.conf to see what it is processed into.)
@@ -583,7 +583,8 @@
 337    UNIMPL  recvmmsg
 338    UNIMPL  fanotify_init
 339    UNIMPL  fanotify_mark
-340    UNIMPL  prlimit64
+340    STD     { int|linux32_sys||prlimit64(pid_t pid, int which, \
+                   netbsd32_rlimitp_t new_rlp, netbsd32_rlimitp_t old_rlp); }
 341    UNIMPL  name_to_handle_at
 342    UNIMPL  open_by_handle_at



Home | Main Index | Thread Index | Old Index