cred: conditionally declare groups-related functions
authorOndrej Mosnáček <omosnace@redhat.com>
Tue, 26 Jun 2018 11:04:42 +0000 (13:04 +0200)
committerPaul Moore <paul@paul-moore.com>
Thu, 28 Jun 2018 15:02:44 +0000 (11:02 -0400)
commit4b09791ba059cc5a5ec7d69049f5d05da65b6418
tree2744e9479fc37926fe3b755aa08a678efea0a1b3
parentf7859590d97614815b35a755c8213dfb8f2766bd
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

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
include/linux/cred.h