From: Andrew Deason Date: Mon, 9 Mar 2015 23:01:29 +0000 (-0500) Subject: LINUX: Don't compile syscall code with keyrings X-Git-Tag: upstream/1.8.0_pre1^2~7 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=32901c58b29ba4ac666f1dba9915cae2c1f03b52;p=packages%2Fo%2Fopenafs.git LINUX: Don't compile syscall code with keyrings osi_syscall_init() is not currently called if we have kernel keyrings support, since we don't need to set up or alter any syscalls if we have kernel keyrings (we track PAGs by keyrings, and we use ioctls instead of the AFS syscall now). Since we don't call it, this commit makes us also not compile the relevant syscall-related code. This allows new platforms to be added without needing to deal with any platform-specific code for handling 32-bit compat processes and such, since usually we don't need to deal with intercepting syscalls. To do this, we just define osi_syscall_init and osi_syscall_cleanup as noops if we have keyrings support. This allows us to reduce the #ifdef clutter in the actual callers. Note that the 'afspag' module does currently call osi_syscall_init unconditionally, but this seems like an oversight. With this change, the afspag module will no longer alter syscalls when we have linux keyrings support. Change-Id: I219b92d89303975765743712587ff897b55a2631 Reviewed-on: https://gerrit.openafs.org/11936 Reviewed-by: Chas Williams <3chas3@gmail.com> Reviewed-by: Perry Ruiter Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index de3671c3a..a52cc68b5 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -279,7 +279,7 @@ setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, return code; } - +#ifndef LINUX_KEYRING_SUPPORT /* Intercept the standard system call. */ extern asmlinkage long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist); asmlinkage long @@ -340,7 +340,7 @@ afs_xsetgroups32(int gidsetsize, gid_t * grouplist) return (-code); } -#if defined(AFS_PPC64_LINUX20_ENV) +# if defined(AFS_PPC64_LINUX20_ENV) /* Intercept the uid16 system call as used by 32bit programs. */ extern asmlinkage long (*sys32_setgroupsp)(int gidsetsize, gid_t *grouplist); asmlinkage long afs32_xsetgroups(int gidsetsize, gid_t *grouplist) @@ -368,17 +368,17 @@ asmlinkage long afs32_xsetgroups(int gidsetsize, gid_t *grouplist) /* Linux syscall ABI returns errno as negative */ return (-code); } -#endif +# endif -#if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_AMD64_LINUX20_ENV) +# if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_AMD64_LINUX20_ENV) /* Intercept the uid16 system call as used by 32bit programs. */ -#ifdef AFS_AMD64_LINUX20_ENV +# ifdef AFS_AMD64_LINUX20_ENV extern asmlinkage long (*sys32_setgroupsp) (int gidsetsize, u16 * grouplist); -#endif /* AFS_AMD64_LINUX20_ENV */ -#ifdef AFS_SPARC64_LINUX26_ENV +# endif /* AFS_AMD64_LINUX20_ENV */ +# ifdef AFS_SPARC64_LINUX26_ENV extern asmlinkage int (*sys32_setgroupsp) (int gidsetsize, __kernel_gid32_t * grouplist); -#endif /* AFS_SPARC64_LINUX26_ENV */ +# endif /* AFS_SPARC64_LINUX26_ENV */ asmlinkage long afs32_xsetgroups(int gidsetsize, u16 * grouplist) { @@ -407,13 +407,13 @@ afs32_xsetgroups(int gidsetsize, u16 * grouplist) } /* Intercept the uid32 system call as used by 32bit programs. */ -#ifdef AFS_AMD64_LINUX20_ENV +# ifdef AFS_AMD64_LINUX20_ENV extern asmlinkage long (*sys32_setgroups32p) (int gidsetsize, gid_t * grouplist); -#endif /* AFS_AMD64_LINUX20_ENV */ -#ifdef AFS_SPARC64_LINUX26_ENV +# endif /* AFS_AMD64_LINUX20_ENV */ +# ifdef AFS_SPARC64_LINUX26_ENV extern asmlinkage int (*sys32_setgroups32p) (int gidsetsize, __kernel_gid32_t * grouplist); -#endif /* AFS_SPARC64_LINUX26_ENV */ +# endif /* AFS_SPARC64_LINUX26_ENV */ asmlinkage long afs32_xsetgroups32(int gidsetsize, gid_t * grouplist) { @@ -440,8 +440,8 @@ afs32_xsetgroups32(int gidsetsize, gid_t * grouplist) /* Linux syscall ABI returns errno as negative */ return (-code); } -#endif - +# endif +#endif /* !LINUX_KEYRING_SUPPORT */ #ifdef LINUX_KEYRING_SUPPORT static void afs_pag_describe(const struct key *key, struct seq_file *m) diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index 2cc0e488e..d6172c1ad 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -61,24 +61,18 @@ afs_init(void) osi_linux_nfssrv_init(); #endif -#ifndef LINUX_KEYRING_SUPPORT err = osi_syscall_init(); if (err) return err; -#endif err = afs_init_inodecache(); if (err) { -#ifndef LINUX_KEYRING_SUPPORT osi_syscall_clean(); -#endif return err; } err = register_filesystem(&afs_fs_type); if (err) { afs_destroy_inodecache(); -#ifndef LINUX_KEYRING_SUPPORT osi_syscall_clean(); -#endif return err; } @@ -102,9 +96,7 @@ afs_cleanup(void) osi_keyring_shutdown(); #endif osi_sysctl_clean(); -#ifndef LINUX_KEYRING_SUPPORT osi_syscall_clean(); -#endif unregister_filesystem(&afs_fs_type); afs_destroy_inodecache(); diff --git a/src/afs/LINUX/osi_syscall.c b/src/afs/LINUX/osi_syscall.c index 0640723ec..921a7a8de 100644 --- a/src/afs/LINUX/osi_syscall.c +++ b/src/afs/LINUX/osi_syscall.c @@ -14,6 +14,22 @@ #include #include "afs/param.h" +#ifdef LINUX_KEYRING_SUPPORT +/* The syscall probing stuff is unnecessary (and is never called) if we have + * keyrings support; we rely on keyrings instead of group ids to track PAGs. + * So if we have keyrings, just stub out the syscall functions to do nothing. */ +int +osi_syscall_init(void) +{ + return 0; +} +void +osi_syscall_clean(void) +{ + return; +} + +#else /* LINUX_KEYRING_SUPPORT */ #include /* early to avoid printf->printk mapping */ #include "afs/sysincludes.h" @@ -626,3 +642,5 @@ void osi_syscall_clean(void) } #endif } + +#endif /* !LINUX_KEYRING_SUPPORT */