From efc9605e03c8e17450aa0afdd329cd7ae5a549f9 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 19 May 2011 17:02:35 -0500 Subject: [PATCH] SOLARIS: Reset syscalls on mod_install failure If our call to mod_install fails for any reason (for example, if the afs entry is missing from /etc/name_to_sysnum), we may still have set the sysent structures for setgroups and ioctl to point at libafs code. So calls to those syscalls will cause a panic, since the code they point to is no longer loaded. To avoid this, just reset the sysent entries back to what they were if we fail to load, just like we do when unloading the module. Reviewed-on: http://gerrit.openafs.org/4685 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit ca425b7d49a2bf4c079aa38c0abf68596eca0b30) Change-Id: Ifb2cd9848b5468c950b600052308370b7c8c2af9 Reviewed-on: http://gerrit.openafs.org/4687 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/SOLARIS/osi_vfsops.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c index f923e4ef9..bd04f6047 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -586,6 +586,19 @@ static struct modlinkage afs_modlinkage = { NULL }; +static void +reset_sysent(void) +{ + if (afs_sinited) { + sysent[SYS_setgroups].sy_callc = afs_orig_setgroups; + sysent[SYS_ioctl].sy_call = afs_orig_ioctl; +#if defined(AFS_SUN57_64BIT_ENV) + sysent32[SYS_setgroups].sy_callc = afs_orig_setgroups32; + sysent32[SYS_ioctl].sy_call = afs_orig_ioctl32; +#endif + } +} + /** This is the function that modload calls when loading the afs kernel * extensions. The solaris modload program searches for the _init * function in a module and calls it when modloading @@ -682,6 +695,11 @@ _init() osi_Init(); /* initialize global lock, etc */ code = mod_install(&afs_modlinkage); + if (code) { + /* we failed to load, so make sure we don't leave behind any + * references to our syscall handlers */ + reset_sysent(); + } return code; } @@ -701,14 +719,7 @@ _fini() if (afs_globalVFS) return EBUSY; - if (afs_sinited) { - sysent[SYS_setgroups].sy_callc = afs_orig_setgroups; - sysent[SYS_ioctl].sy_call = afs_orig_ioctl; -#if defined(AFS_SUN57_64BIT_ENV) - sysent32[SYS_setgroups].sy_callc = afs_orig_setgroups32; - sysent32[SYS_ioctl].sy_call = afs_orig_ioctl32; -#endif - } + reset_sysent(); code = mod_remove(&afs_modlinkage); return code; } -- 2.39.5