git: fbed3bdfd4ca - stable/13 - Call sv_onexec hook after the process VA is created.

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Fri, 17 Jun 2022 19:36:51 UTC
The branch stable/13 has been updated by dchagin:

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

commit fbed3bdfd4ca06459590ad2b713a8b6eea53e832
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-06-17 19:33:04 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:33:04 +0000

    Call sv_onexec hook after the process VA is created.
    
    For future use in the Linux emulation layer call sv_onexec hook right after
    the new process address space is created. It's safe, as sv_onexec used only
    by Linux abi and linux_on_exec() does not depend on a state of process VA.
    
    Reviewed by:            kib
    Differential revision:  https://reviews.freebsd.org/D30899
    MFC after:              2 weeks
    
    (cherry picked from commit 62ba4cd340670e901fbaab98766bd5490b4334bd)
---
 sys/kern/kern_exec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 9dbafe52119a..e6081cba7a4b 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1143,8 +1143,6 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
 	if (p->p_sysent->sv_onexec_old != NULL)
 		p->p_sysent->sv_onexec_old(td);
 	itimers_exec(p);
-	if (sv->sv_onexec != NULL)
-		sv->sv_onexec(p, imgp);
 
 	EVENTHANDLER_DIRECT_INVOKE(process_exec, p, imgp);
 
@@ -1198,6 +1196,8 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
 		}
 	}
 
+	if (sv->sv_onexec != NULL)
+		sv->sv_onexec(p, imgp);
 	return (0);
 }