cred: conditionally declare groups-related functions
Subsystems (2)
PATCH v3 1/1 cred: conditionally declare groups-related functions
The groups-related functions declared in include/linux/cred.h are defined in kernel/groups.c, which is compiled only when CONFIG_MULTIUSER=y. Move all these function declarations under #ifdef CONFIG_MULTIUSER to help avoid accidental usage in contexts where CONFIG_MULTIUSER might be disabled.
This patch also adds a fallback for groups_search(). Currently this function is only called from kernel/groups.c itself and security/keys/permissions.c, where the call is (by coincidence) optimized away in case CONFIG_MULTIUSER=n. However, the audit subsystem (which does not depend on CONFIG_MULTIUSER) calls this function in -next, so the fallback will be needed to avoid compilation errors or ugly workarounds.
See also:
https://lkml.org/lkml/2018/6/20/670
https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git/commit/?h=next&id=af85d1772e31fed34165a1b3decef340cf4080c0
---
Changes:
v2->v3: commit message corrections
v1->v2: change default return value of groups_search() to 1include/linux/cred.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
include/linux/cred.h +10 -5
@@ -65,6 +65,12 @@ extern void groups_free(struct group_info *);extern int in_group_p (kgid_t );extern int in_egroup_p (kgid_t ); +extern int groups_search (const struct group_info *,kgid_t ); + +extern int set_current_groups (struct group_info *); +extern void set_groups (struct cred *,struct group_info *); +extern bool may_setgroups (void ); +extern void groups_sort (struct group_info *);#else static inline void groups_free (struct group_info *group_info) {
@@ -78,12 +84,11 @@ static inline int in_egroup_p(kgid_t grp) {return 1 ; } +static inline int groups_search (const struct group_info *group_info,kgid_t grp) +{ +return 1 ; +}#endif -extern int set_current_groups (struct group_info *); -extern void set_groups (struct cred *,struct group_info *); -extern int groups_search (const struct group_info *,kgid_t ); -extern bool may_setgroups (void ); -extern void groups_sort (struct group_info *);/* * The security context of a task
Signature · 1 line
2.17.1
Quoted 22 lines · Ondrej Mosnacek
The groups-related functions declared in
include/linux/cred.hare defined inkernel/groups.c, which is compiled only whenCONFIG_MULTIUSER=y. Move all these function declarations under #ifdefCONFIG_MULTIUSERto help avoid accidental usage in contexts whereCONFIG_MULTIUSERmight be disabled.This patch also adds a fallback for
groups_search(). Currently this function is only called fromkernel/groups.citself andsecurity/keys/permissions.c, where the call is (by coincidence) optimized away in caseCONFIG_MULTIUSER=n. However, the audit subsystem (which does not depend onCONFIG_MULTIUSER) calls this function in -next, so the fallback will be needed to avoid compilation errors or ugly workarounds.See also:
https://lkml.org/lkml/2018/6/20/670
https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git/commit/?h=next&id=af85d1772e31fed34165a1b3decef340cf4080c0Reported-by Randy Dunlap <[email protected]>Tested-by Randy Dunlap <[email protected]>Signed-off-by Ondrej Mosnacek <[email protected]>
Quoted 8 lines
---
Changes:
v2->v3: commit message corrections v1->v2: change default return value of groups_search() to 1include/linux/cred.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
Merged, thanks guys.
Quoted 37 lines
include/linux/cred.h +10
-6@@ -65,6 +65,12 @@ extern void groups_free(struct group_info *);extern int in_group_p (kgid_t );extern int in_egroup_p (kgid_t ); +extern int groups_search (const struct group_info *,kgid_t ); + +extern int set_current_groups (struct group_info *); +extern void set_groups (struct cred *,struct group_info *); +extern bool may_setgroups (void ); +extern void groups_sort (struct group_info *);#else static inline void groups_free (struct group_info *group_info) {@@ -78,12 +84,11 @@ static inline int in_egroup_p(kgid_t grp) {return 1 ; } +static inline int groups_search (const struct group_info *group_info,kgid_t grp) +{ +return 1 ; +}#endif -extern int set_current_groups (struct group_info *); -extern void set_groups (struct cred *,struct group_info *); -extern int groups_search (const struct group_info *,kgid_t ); -extern bool may_setgroups (void ); -extern void groups_sort (struct group_info *);/* * The security context of a task -- 2.17.1
Signature · 2 lines
paul moore www.paul-moore.com