Page MenuHomeFreeBSD

Call sv_onexec handler after the process VA is created.
ClosedPublic

Authored by dchagin on Jun 25 2021, 3:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 21, 6:10 AM
Unknown Object (File)
Sat, Dec 21, 5:51 AM
Unknown Object (File)
Sat, Dec 21, 2:53 AM
Unknown Object (File)
Fri, Dec 13, 7:50 PM
Unknown Object (File)
Mon, Dec 9, 4:08 PM
Unknown Object (File)
Nov 15 2024, 6:55 AM
Unknown Object (File)
Nov 15 2024, 6:33 AM
Unknown Object (File)
Nov 15 2024, 6:20 AM
Subscribers

Details

Summary

For future use in the Linux emulation layer call sv_onexec handler
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.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 40106
Build 36995: arc lint + arc unit

Event Timeline

Does the move after process event handler breaks existing linux_on_exec()?

sys/kern/kern_exec.c
1116

This is weird place to put the call. The vmspace is indeed constructed, but not everything yet mapped into it. It is not quite logical to have e.g. shared page mapped, but stack not, when claiming that you put the callback after the vmspace is constructed.

In D30899#695137, @kib wrote:

Does the move after process event handler breaks existing linux_on_exec()?

no, I even tested it, linux_on_exec() does not depend on process vm space noe eventhandler

sys/kern/kern_exec.c
1116

well, I can put it right after the stack creation or change clarification, for linux_on_exec() it doesn't matter

move linux_on_exec() call below, after the stack is created

sys/kern/kern_exec.c
1116

Then move it to the very end of the function, right before return.

1156

Move the call right before this return.

fixed, thank you,
one question, in D30900 I'll change this, sv_onexec() will return an error,
should I call vm_object_deallocate(obj) or somthing other. seems that
on if vm_map_stack() return error no resources are released

fixed, thank you,
one question, in D30900 I'll change this, sv_onexec() will return an error,
should I call vm_object_deallocate(obj) or somthing other. seems that
on if vm_map_stack() return error no resources are released

Everything done before the call is recorded as the state of the new vmspace. In case of error return, we eventually call exit1() terminate the process, and this destroys current vmspace, which holds references to the shared_page object etc.

I suggest you to make the dedicated change for making sv_onexec() possibly return an error.

This revision is now accepted and ready to land.Jun 26 2021, 12:08 AM