mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-04 12:52:15 +00:00
Make system call modules a bit more robust:
- If we fail to register the system call during MOD_LOAD, then note that so that we don't try to deregister it or invoke the chained event handler during the subsequent MOD_UNLOAD event. Doing the deregister when the register failed could result in trashing system call entries. - Add a SI_SUB_SYSCALLS just before starting up init and use that to register syscall modules instead of SI_SUB_DRIVERS. Registering system calls as late as possible increases the chances that any other module event handlers or SYSINITs in a module are executed to initialize the data in a kld before a syscall dependent on that data is able to be invoked. MFC after: 3 days
This commit is contained in:
parent
6cba7f3609
commit
03e161fdb1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160882
@ -97,8 +97,11 @@ syscall_module_handler(struct module *mod, int what, void *arg)
|
||||
case MOD_LOAD :
|
||||
error = syscall_register(data->offset, data->new_sysent,
|
||||
&data->old_sysent);
|
||||
if (error)
|
||||
if (error) {
|
||||
/* Leave a mark so we know to safely unload below. */
|
||||
data->offset = NULL;
|
||||
return error;
|
||||
}
|
||||
ms.intval = *data->offset;
|
||||
MOD_XLOCK;
|
||||
module_setspecific(mod, &ms);
|
||||
@ -108,6 +111,13 @@ syscall_module_handler(struct module *mod, int what, void *arg)
|
||||
return error;
|
||||
|
||||
case MOD_UNLOAD :
|
||||
/*
|
||||
* MOD_LOAD failed, so just return without calling the
|
||||
* chained handler since we didn't pass along the MOD_LOAD
|
||||
* event.
|
||||
*/
|
||||
if (data->offset == NULL)
|
||||
return (0);
|
||||
if (data->chainevh) {
|
||||
error = data->chainevh(mod, what, data->chainarg);
|
||||
if (error)
|
||||
|
@ -157,6 +157,7 @@ enum sysinit_sub_id {
|
||||
SI_SUB_MOUNT_ROOT = 0xb400000, /* root mount*/
|
||||
SI_SUB_SWAP = 0xc000000, /* swap */
|
||||
SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup*/
|
||||
SI_SUB_SYSCALLS = 0xd800000, /* register system calls */
|
||||
SI_SUB_KTHREAD_INIT = 0xe000000, /* init process*/
|
||||
SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon*/
|
||||
SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon*/
|
||||
|
@ -113,7 +113,7 @@ static moduledata_t name##_mod = { \
|
||||
syscall_module_handler, \
|
||||
&name##_syscall_mod \
|
||||
}; \
|
||||
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
|
||||
DECLARE_MODULE(name, name##_mod, SI_SUB_SYSCALLS, SI_ORDER_MIDDLE)
|
||||
|
||||
#define SYSCALL_MODULE_HELPER(syscallname) \
|
||||
static int syscallname##_syscall = SYS_##syscallname; \
|
||||
|
Loading…
Reference in New Issue
Block a user