? diff.txt ? arch/amd64/compile/GENERIC ? arch/amd64/conf/GENERIC.local Index: compat/linux/arch/amd64/linux_syscall.h =================================================================== RCS file: /cvsroot/src/sys/compat/linux/arch/amd64/linux_syscall.h,v retrieving revision 1.85 diff -u -r1.85 linux_syscall.h --- compat/linux/arch/amd64/linux_syscall.h 26 Oct 2025 16:25:16 -0000 1.85 +++ compat/linux/arch/amd64/linux_syscall.h 8 Nov 2025 00:58:52 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_syscall.h,v 1.85 2025/10/26 16:25:16 christos Exp $ */ +/* $NetBSD$ */ /* * System call numbers. @@ -471,6 +471,9 @@ /* syscall: "__sysctl" ret: "int" args: "struct linux___sysctl *" */ #define LINUX_SYS___sysctl 156 +/* syscall: "__prctl" ret: "int" args: "int" "..." */ +#define LINUX_SYS___prctl 157 + /* syscall: "arch_prctl" ret: "int" args: "int" "unsigned long" */ #define LINUX_SYS_arch_prctl 158 Index: compat/linux/arch/amd64/linux_syscallargs.h =================================================================== RCS file: /cvsroot/src/sys/compat/linux/arch/amd64/linux_syscallargs.h,v retrieving revision 1.85 diff -u -r1.85 linux_syscallargs.h --- compat/linux/arch/amd64/linux_syscallargs.h 26 Oct 2025 16:25:16 -0000 1.85 +++ compat/linux/arch/amd64/linux_syscallargs.h 8 Nov 2025 00:58:53 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_syscallargs.h,v 1.85 2025/10/26 16:25:16 christos Exp $ */ +/* $NetBSD$ */ /* * System call argument lists. @@ -652,6 +652,11 @@ }; check_syscall_args(linux_sys___sysctl) +struct linux_sys___prctl_args { + syscallarg(int) code; + syscallarg(void *) args[SYS_MAXSYSARGS]; +}; + struct linux_sys_arch_prctl_args { syscallarg(int) code; syscallarg(unsigned long) addr; @@ -1648,6 +1653,8 @@ int linux_sys___sysctl(struct lwp *, const struct linux_sys___sysctl_args *, register_t *); +int linux_sys___prctl(struct lwp *, const struct linux_sys___prctl_args *, register_t *); + int linux_sys_arch_prctl(struct lwp *, const struct linux_sys_arch_prctl_args *, register_t *); int linux_sys_setrlimit(struct lwp *, const struct linux_sys_setrlimit_args *, register_t *); Index: compat/linux/arch/amd64/linux_syscalls.c =================================================================== RCS file: /cvsroot/src/sys/compat/linux/arch/amd64/linux_syscalls.c,v retrieving revision 1.85 diff -u -r1.85 linux_syscalls.c --- compat/linux/arch/amd64/linux_syscalls.c 26 Oct 2025 16:25:16 -0000 1.85 +++ compat/linux/arch/amd64/linux_syscalls.c 8 Nov 2025 00:58:53 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_syscalls.c,v 1.85 2025/10/26 16:25:16 christos Exp $ */ +/* $NetBSD$ */ /* * System call names. @@ -8,7 +8,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_syscalls.c,v 1.85 2025/10/26 16:25:16 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD$"); #if defined(_KERNEL_OPT) #if defined(_KERNEL_OPT) @@ -227,7 +227,7 @@ /* 154 */ "modify_ldt", /* 155 */ "#155 (unimplemented pivot_root)", /* 156 */ "__sysctl", - /* 157 */ "#157 (unimplemented prctl)", + /* 157 */ "__prctl", /* 158 */ "arch_prctl", /* 159 */ "#159 (unimplemented adjtimex)", /* 160 */ "setrlimit", @@ -771,7 +771,7 @@ /* 154 */ NULL, /* modify_ldt */ /* 155 */ NULL, /* unimplemented pivot_root */ /* 156 */ NULL, /* __sysctl */ - /* 157 */ NULL, /* unimplemented prctl */ + /* 157 */ NULL, /* __prctl */ /* 158 */ NULL, /* arch_prctl */ /* 159 */ NULL, /* unimplemented adjtimex */ /* 160 */ NULL, /* setrlimit */ Index: compat/linux/arch/amd64/linux_sysent.c =================================================================== RCS file: /cvsroot/src/sys/compat/linux/arch/amd64/linux_sysent.c,v retrieving revision 1.85 diff -u -r1.85 linux_sysent.c --- compat/linux/arch/amd64/linux_sysent.c 26 Oct 2025 16:25:16 -0000 1.85 +++ compat/linux/arch/amd64/linux_sysent.c 8 Nov 2025 00:58:53 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sysent.c,v 1.85 2025/10/26 16:25:16 christos Exp $ */ +/* $NetBSD$ */ /* * System call switch table. @@ -8,7 +8,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sysent.c,v 1.85 2025/10/26 16:25:16 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD$"); #if defined(_KERNEL_OPT) #include "opt_sysv.h" @@ -793,8 +793,10 @@ .sy_call = (sy_call_t *)linux_sys___sysctl }, /* 156 = __sysctl */ { - .sy_call = linux_sys_nosys, - }, /* 157 = filler */ + ns(struct linux_sys___prctl_args), + .sy_flags = SYCALL_ARG_PTR | SYCALL_INDIRECT, + .sy_call = (sy_call_t *)linux_sys___prctl + }, /* 157 = __prctl */ { ns(struct linux_sys_arch_prctl_args), .sy_call = (sy_call_t *)linux_sys_arch_prctl Index: compat/linux/arch/amd64/linux_systrace_args.c =================================================================== RCS file: /cvsroot/src/sys/compat/linux/arch/amd64/linux_systrace_args.c,v retrieving revision 1.29 diff -u -r1.29 linux_systrace_args.c --- compat/linux/arch/amd64/linux_systrace_args.c 26 Oct 2025 16:25:16 -0000 1.29 +++ compat/linux/arch/amd64/linux_systrace_args.c 8 Nov 2025 00:58:54 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_systrace_args.c,v 1.29 2025/10/26 16:25:16 christos Exp $ */ +/* $NetBSD$ */ /* * System call argument to DTrace register array conversion. @@ -1230,6 +1230,14 @@ *n_args = 1; break; } + /* linux_sys___prctl */ + case 157: { + const struct linux_sys___prctl_args *p = params; + iarg[0] = SCARG(p, code); /* int */ + uarg[1] = (intptr_t) SCARG(p, args[0]); /* void * */ + *n_args = 2; + break; + } /* linux_sys_arch_prctl */ case 158: { const struct linux_sys_arch_prctl_args *p = params; @@ -4187,6 +4195,19 @@ break; }; break; + /* linux_sys___prctl */ + case 157: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "void *"; + break; + default: + break; + }; + break; /* linux_sys_arch_prctl */ case 158: switch(ndx) { @@ -6614,6 +6635,11 @@ if (ndx == 0 || ndx == 1) p = "int"; break; + /* linux_sys___prctl */ + case 157: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_sys_arch_prctl */ case 158: if (ndx == 0 || ndx == 1) Index: compat/linux/arch/amd64/syscalls.master =================================================================== RCS file: /cvsroot/src/sys/compat/linux/arch/amd64/syscalls.master,v retrieving revision 1.76 diff -u -r1.76 syscalls.master --- compat/linux/arch/amd64/syscalls.master 26 Oct 2025 16:19:05 -0000 1.76 +++ compat/linux/arch/amd64/syscalls.master 8 Nov 2025 00:58:55 -0000 @@ -340,7 +340,8 @@ size_t bytecount); } 155 UNIMPL pivot_root 156 STD { int|linux_sys||__sysctl(struct linux___sysctl *lsp); } -157 UNIMPL prctl +157 INDIR { int|linux_sys||__prctl(int code, \ + ... void * args[SYS_MAXSYSARGS]); } 158 STD { int|linux_sys||arch_prctl(int code, \ unsigned long addr); } 159 UNIMPL adjtimex Index: compat/linux/common/linux_sched.c =================================================================== RCS file: /cvsroot/src/sys/compat/linux/common/linux_sched.c,v retrieving revision 1.85 diff -u -r1.85 linux_sched.c --- compat/linux/common/linux_sched.c 19 Sep 2025 19:35:15 -0000 1.85 +++ compat/linux/common/linux_sched.c 8 Nov 2025 00:58:55 -0000 @@ -782,3 +782,78 @@ return sys__sched_setaffinity(l, &ssa, retval); } + +int +linux_sys___prctl(struct lwp *l, const struct linux_sys___prctl_args *uap, + register_t *retval) +{ + /* { + syscallarg(int) code; + syscallarg(void *) args[SYS_MAXSYSARGS]; + } */ + + /* linux prctl truncates name to 16 bytes */ + size_t len = 16; + lwpid_t target = l->l_lid; + proc_t *p = curproc; + lwp_t *t; + unsigned int c = SCARG(uap, code); + int error; + + /* TODO: add other commonly used prctl codes */ + switch(c) { + case 15: { // PR_SET_NAME + char *name, *oname; + name = kmem_alloc(len, KM_SLEEP); + error = copyinstr(SCARG(uap, args[0]), name, len, NULL); + switch (error) { + case ENAMETOOLONG: + case 0: + name[len - 1] = '\0'; + break; + default: + kmem_free(name, len); + return error; + } + + p = curproc; + mutex_enter(p->p_lock); + if ((t = lwp_find(p, target)) == NULL) { + mutex_exit(p->p_lock); + kmem_free(name, len); + return ESRCH; + } + lwp_lock(t); + oname = t->l_name; + t->l_name = name; + lwp_unlock(t); + mutex_exit(p->p_lock); + + if (oname != NULL) + kmem_free(oname, len); + + return 0; + } + + case 16: { // PR_GET_NAME + char name[len]; + mutex_enter(p->p_lock); + if ((t = lwp_find(p, target)) == NULL) { + mutex_exit(p->p_lock); + return ESRCH; + } + lwp_lock(t); + if (t->l_name == NULL) + name[0] = '\0'; + else + strlcpy(name, t->l_name, sizeof(name)); + lwp_unlock(t); + mutex_exit(p->p_lock); + + return copyoutstr(name, SCARG(uap, args[0]), len, NULL); + } + default: + return 0; + } + +}