Module Name: src Committed By: ryo Date: Thu Dec 2 04:29:49 UTC 2021
Modified Files: src/sys/compat/linux/arch/aarch64: syscalls.master src/sys/compat/linux/arch/alpha: syscalls.master src/sys/compat/linux/arch/amd64: syscalls.master src/sys/compat/linux/arch/arm: syscalls.master src/sys/compat/linux/arch/i386: syscalls.master src/sys/compat/linux/arch/m68k: syscalls.master src/sys/compat/linux/arch/mips: syscalls.master src/sys/compat/linux/arch/powerpc: syscalls.master src/sys/compat/linux/common: linux_limit.h linux_misc.c src/sys/compat/linux32/arch/aarch64: syscalls.master src/sys/compat/linux32/arch/amd64: syscalls.master src/sys/compat/linux32/common: linux32_resource.c Log Message: add prlimit64(2) syscall to COMPAT_LINUX and COMPAT_LINUX32 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/compat/linux/arch/aarch64/syscalls.master cvs rdiff -u -r1.101 -r1.102 src/sys/compat/linux/arch/alpha/syscalls.master cvs rdiff -u -r1.66 -r1.67 src/sys/compat/linux/arch/amd64/syscalls.master cvs rdiff -u -r1.74 -r1.75 src/sys/compat/linux/arch/arm/syscalls.master cvs rdiff -u -r1.128 -r1.129 src/sys/compat/linux/arch/i386/syscalls.master cvs rdiff -u -r1.100 -r1.101 src/sys/compat/linux/arch/m68k/syscalls.master cvs rdiff -u -r1.73 -r1.74 src/sys/compat/linux/arch/mips/syscalls.master cvs rdiff -u -r1.79 -r1.80 src/sys/compat/linux/arch/powerpc/syscalls.master cvs rdiff -u -r1.7 -r1.8 src/sys/compat/linux/common/linux_limit.h cvs rdiff -u -r1.255 -r1.256 src/sys/compat/linux/common/linux_misc.c cvs rdiff -u -r1.2 -r1.3 src/sys/compat/linux32/arch/aarch64/syscalls.master cvs rdiff -u -r1.76 -r1.77 src/sys/compat/linux32/arch/amd64/syscalls.master cvs rdiff -u -r1.12 -r1.13 src/sys/compat/linux32/common/linux32_resource.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/linux/arch/aarch64/syscalls.master diff -u src/sys/compat/linux/arch/aarch64/syscalls.master:1.3 src/sys/compat/linux/arch/aarch64/syscalls.master:1.4 --- src/sys/compat/linux/arch/aarch64/syscalls.master:1.3 Thu Nov 25 02:29:33 2021 +++ src/sys/compat/linux/arch/aarch64/syscalls.master Thu Dec 2 04:29:47 2021 @@ -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 Index: src/sys/compat/linux/arch/alpha/syscalls.master diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.101 src/sys/compat/linux/arch/alpha/syscalls.master:1.102 --- src/sys/compat/linux/arch/alpha/syscalls.master:1.101 Mon Sep 20 02:20:02 2021 +++ src/sys/compat/linux/arch/alpha/syscalls.master Thu Dec 2 04:29:47 2021 @@ -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 Index: src/sys/compat/linux/arch/amd64/syscalls.master diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.66 src/sys/compat/linux/arch/amd64/syscalls.master:1.67 --- src/sys/compat/linux/arch/amd64/syscalls.master:1.66 Mon Sep 20 02:20:02 2021 +++ src/sys/compat/linux/arch/amd64/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux/arch/arm/syscalls.master diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.74 src/sys/compat/linux/arch/arm/syscalls.master:1.75 --- src/sys/compat/linux/arch/arm/syscalls.master:1.74 Wed Nov 24 18:52:13 2021 +++ src/sys/compat/linux/arch/arm/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux/arch/i386/syscalls.master diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.128 src/sys/compat/linux/arch/i386/syscalls.master:1.129 --- src/sys/compat/linux/arch/i386/syscalls.master:1.128 Mon Sep 20 02:20:02 2021 +++ src/sys/compat/linux/arch/i386/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux/arch/m68k/syscalls.master diff -u src/sys/compat/linux/arch/m68k/syscalls.master:1.100 src/sys/compat/linux/arch/m68k/syscalls.master:1.101 --- src/sys/compat/linux/arch/m68k/syscalls.master:1.100 Wed Nov 24 18:52:13 2021 +++ src/sys/compat/linux/arch/m68k/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux/arch/mips/syscalls.master diff -u src/sys/compat/linux/arch/mips/syscalls.master:1.73 src/sys/compat/linux/arch/mips/syscalls.master:1.74 --- src/sys/compat/linux/arch/mips/syscalls.master:1.73 Wed Nov 24 18:52:13 2021 +++ src/sys/compat/linux/arch/mips/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux/arch/powerpc/syscalls.master diff -u src/sys/compat/linux/arch/powerpc/syscalls.master:1.79 src/sys/compat/linux/arch/powerpc/syscalls.master:1.80 --- src/sys/compat/linux/arch/powerpc/syscalls.master:1.79 Wed Nov 24 18:52:13 2021 +++ src/sys/compat/linux/arch/powerpc/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux/common/linux_limit.h diff -u src/sys/compat/linux/common/linux_limit.h:1.7 src/sys/compat/linux/common/linux_limit.h:1.8 --- src/sys/compat/linux/common/linux_limit.h:1.7 Sat Feb 28 13:08:00 2015 +++ src/sys/compat/linux/common/linux_limit.h Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.255 src/sys/compat/linux/common/linux_misc.c:1.256 --- src/sys/compat/linux/common/linux_misc.c:1.255 Thu Nov 25 03:08:04 2021 +++ src/sys/compat/linux/common/linux_misc.c Thu Dec 2 04:29:48 2021 @@ -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 @@ linux_sys_ugetrlimit(struct lwp *l, cons } # 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. Index: src/sys/compat/linux32/arch/aarch64/syscalls.master diff -u src/sys/compat/linux32/arch/aarch64/syscalls.master:1.2 src/sys/compat/linux32/arch/aarch64/syscalls.master:1.3 --- src/sys/compat/linux32/arch/aarch64/syscalls.master:1.2 Sat Nov 27 21:15:07 2021 +++ src/sys/compat/linux32/arch/aarch64/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 Index: src/sys/compat/linux32/arch/amd64/syscalls.master diff -u src/sys/compat/linux32/arch/amd64/syscalls.master:1.76 src/sys/compat/linux32/arch/amd64/syscalls.master:1.77 --- src/sys/compat/linux32/arch/amd64/syscalls.master:1.76 Sat Nov 27 21:15:07 2021 +++ src/sys/compat/linux32/arch/amd64/syscalls.master Thu Dec 2 04:29:48 2021 @@ -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 343 UNIMPL clock_adjtime Index: src/sys/compat/linux32/common/linux32_resource.c diff -u src/sys/compat/linux32/common/linux32_resource.c:1.12 src/sys/compat/linux32/common/linux32_resource.c:1.13 --- src/sys/compat/linux32/common/linux32_resource.c:1.12 Tue Sep 7 11:43:04 2021 +++ src/sys/compat/linux32/common/linux32_resource.c Thu Dec 2 04:29:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_resource.c,v 1.12 2021/09/07 11:43:04 riastradh Exp $ */ +/* $NetBSD: linux32_resource.c,v 1.13 2021/12/02 04:29:49 ryo Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_resource.c,v 1.12 2021/09/07 11:43:04 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_resource.c,v 1.13 2021/12/02 04:29:49 ryo Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -124,6 +124,48 @@ linux32_sys_ugetrlimit(struct lwp *l, co } int +linux32_sys_prlimit64(struct lwp *l, const struct linux32_sys_prlimit64_args *uap, register_t *retval) +{ + /* { + syscallarg(pid_t) pid; + syscallarg(int) which; + syscallarg(netbsd32_rlimitp_t) new_rlp; + syscallarg(netbsd32_rlimitp_t) 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_P32(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_P32(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; +} + +int linux32_sys_getpriority(struct lwp *l, const struct linux32_sys_getpriority_args *uap, register_t *retval) { /* {