The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5fd9cd53d256e08c601548c425bfcb3472f2d09b

commit 5fd9cd53d256e08c601548c425bfcb3472f2d09b
Author:     Dmitry Chagin <dcha...@freebsd.org>
AuthorDate: 2021-07-20 06:56:25 +0000
Commit:     Dmitry Chagin <dcha...@freebsd.org>
CommitDate: 2021-07-20 06:56:25 +0000

    linux(4): Modify sv_onexec hook to return an error.
    
    Temporary add stubs to the Linux emulation layer which calls the existing 
hook.
    
    Reviewed by:            kib
    Differential Revision:  https://reviews.freebsd.org/D30911
    MFC after:              2 weeks
---
 sys/amd64/linux/linux_sysvec.c     | 12 +++++++++++-
 sys/amd64/linux32/linux32_sysvec.c | 12 +++++++++++-
 sys/arm64/linux/linux_sysvec.c     | 12 +++++++++++-
 sys/i386/linux/linux_sysvec.c      | 14 ++++++++++++--
 sys/kern/kern_exec.c               |  4 +---
 sys/sys/sysent.h                   |  2 +-
 6 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
index 566af6de29e7..2d3406582a33 100644
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -106,6 +106,8 @@ static void linux_set_syscall_retval(struct thread *td, int 
error);
 static int     linux_fetch_syscall_args(struct thread *td);
 static void    linux_exec_setregs(struct thread *td, struct image_params *imgp,
                    uintptr_t stack);
+static int     linux_on_exec_vmspace(struct proc *p,
+                   struct image_params *imgp);
 static int     linux_vsyscall(struct thread *td);
 
 #define LINUX_T_UNKNOWN  255
@@ -766,12 +768,20 @@ struct sysentvec elf_linux_sysvec = {
        .sv_schedtail   = linux_schedtail,
        .sv_thread_detach = linux_thread_detach,
        .sv_trap        = linux_vsyscall,
-       .sv_onexec      = linux_on_exec,
+       .sv_onexec      = linux_on_exec_vmspace,
        .sv_onexit      = linux_on_exit,
        .sv_ontdexit    = linux_thread_dtor,
        .sv_setid_allowed = &linux_setid_allowed_query,
 };
 
+static int
+linux_on_exec_vmspace(struct proc *p, struct image_params *imgp)
+{
+
+       linux_on_exec(p, imgp);
+       return (0);
+}
+
 static void
 linux_vdso_install(void *param)
 {
diff --git a/sys/amd64/linux32/linux32_sysvec.c 
b/sys/amd64/linux32/linux32_sysvec.c
index 7dfd57a74a1e..90b6207a50c9 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -111,6 +111,8 @@ static int  linux_copyout_strings(struct image_params *imgp,
 static void     linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
 static void    linux_exec_setregs(struct thread *td,
                                   struct image_params *imgp, uintptr_t stack);
+static int     linux_on_exec_vmspace(struct proc *p,
+                   struct image_params *imgp);
 static void    linux32_fixlimit(struct rlimit *rl, int which);
 static bool    linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
 static void    linux_vdso_install(void *param);
@@ -938,12 +940,20 @@ struct sysentvec elf_linux_sysvec = {
        .sv_schedtail   = linux_schedtail,
        .sv_thread_detach = linux_thread_detach,
        .sv_trap        = NULL,
-       .sv_onexec      = linux_on_exec,
+       .sv_onexec      = linux_on_exec_vmspace,
        .sv_onexit      = linux_on_exit,
        .sv_ontdexit    = linux_thread_dtor,
        .sv_setid_allowed = &linux_setid_allowed_query,
 };
 
+static int
+linux_on_exec_vmspace(struct proc *p, struct image_params *imgp)
+{
+
+       linux_on_exec(p, imgp);
+       return (0);
+}
+
 static void
 linux_vdso_install(void *param)
 {
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
index e684fb604889..706b97894f9c 100644
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -86,6 +86,8 @@ static void   linux_set_syscall_retval(struct thread *td, int 
error);
 static int     linux_fetch_syscall_args(struct thread *td);
 static void    linux_exec_setregs(struct thread *td, struct image_params *imgp,
                    uintptr_t stack);
+static int     linux_on_exec_vmspace(struct proc *p,
+                   struct image_params *imgp);
 
 /* DTrace init */
 LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
@@ -433,12 +435,20 @@ struct sysentvec elf_linux_sysvec = {
        .sv_trap        = NULL,
        .sv_hwcap       = &elf_hwcap,
        .sv_hwcap2      = &elf_hwcap2,
-       .sv_onexec      = linux_on_exec,
+       .sv_onexec      = linux_on_exec_vmspace,
        .sv_onexit      = linux_on_exit,
        .sv_ontdexit    = linux_thread_dtor,
        .sv_setid_allowed = &linux_setid_allowed_query,
 };
 
+static int
+linux_on_exec_vmspace(struct proc *p, struct image_params *imgp)
+{
+
+       linux_on_exec(p, imgp);
+       return (0);
+}
+
 static void
 linux_vdso_install(const void *param)
 {
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index a0959d55b585..048bc6dffdca 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -94,6 +94,8 @@ static int    linux_fixup_elf(uintptr_t *stack_base,
 static void     linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
 static void    linux_exec_setregs(struct thread *td,
                    struct image_params *imgp, uintptr_t stack);
+static int     linux_on_exec_vmspace(struct proc *p,
+                   struct image_params *imgp);
 static int     linux_copyout_strings(struct image_params *imgp,
                    uintptr_t *stack_base);
 static bool    linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
@@ -838,7 +840,7 @@ struct sysentvec linux_sysvec = {
        .sv_schedtail   = linux_schedtail,
        .sv_thread_detach = linux_thread_detach,
        .sv_trap        = NULL,
-       .sv_onexec      = linux_on_exec,
+       .sv_onexec      = linux_on_exec_vmspace,
        .sv_onexit      = linux_on_exit,
        .sv_ontdexit    = linux_thread_dtor,
        .sv_setid_allowed = &linux_setid_allowed_query,
@@ -880,12 +882,20 @@ struct sysentvec elf_linux_sysvec = {
        .sv_schedtail   = linux_schedtail,
        .sv_thread_detach = linux_thread_detach,
        .sv_trap        = NULL,
-       .sv_onexec      = linux_on_exec,
+       .sv_onexec      = linux_on_exec_vmspace,
        .sv_onexit      = linux_on_exit,
        .sv_ontdexit    = linux_thread_dtor,
        .sv_setid_allowed = &linux_setid_allowed_query,
 };
 
+static int
+linux_on_exec_vmspace(struct proc *p, struct image_params *imgp)
+{
+
+       linux_on_exec(p, imgp);
+       return (0);
+}
+
 static void
 linux_vdso_install(void *param)
 {
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index eff48b2c86f3..e5944bfc5ac6 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1163,9 +1163,7 @@ exec_new_vmspace(struct image_params *imgp, struct 
sysentvec *sv)
        vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT;
        vmspace->vm_maxsaddr = (char *)stack_addr;
 
-       if (sv->sv_onexec != NULL)
-               sv->sv_onexec(p, imgp);
-       return (0);
+       return (sv->sv_onexec != NULL ? sv->sv_onexec(p, imgp) : 0);
 }
 
 /*
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index f0bb084d59dc..1b43e9692153 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -151,7 +151,7 @@ struct sysentvec {
        const char      *(*sv_machine_arch)(struct proc *);
        vm_offset_t     sv_fxrng_gen_base;
        void            (*sv_onexec_old)(struct thread *td);
-       void            (*sv_onexec)(struct proc *, struct image_params *);
+       int             (*sv_onexec)(struct proc *, struct image_params *);
        void            (*sv_onexit)(struct proc *);
        void            (*sv_ontdexit)(struct thread *td);
        int             (*sv_setid_allowed)(struct thread *td,
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to