capabilities/syslog: open code cap_syslog logic to fix build failure
The addition of CONFIG_SECURITY_DMESG_RESTRICT resulted in a build failure when CONFIG_PRINTK=n. This is because the capabilities code which used the new option was built even though the variable in question didn't exist. The patch here fixes this by moving the capabilities checks out of the LSM and into the caller. All (known) LSMs should have been calling the capabilities hook already so it actually makes the code organization better to eliminate the hook altogether. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: James Morris <jmorris@namei.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
6800e4c0ea
commit
12b3052c3e
@@ -27,7 +27,6 @@
|
||||
#include <linux/sched.h>
|
||||
#include <linux/prctl.h>
|
||||
#include <linux/securebits.h>
|
||||
#include <linux/syslog.h>
|
||||
|
||||
/*
|
||||
* If a non-root user executes a setuid-root binary in
|
||||
@@ -883,26 +882,6 @@ error:
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* cap_syslog - Determine whether syslog function is permitted
|
||||
* @type: Function requested
|
||||
* @from_file: Whether this request came from an open file (i.e. /proc)
|
||||
*
|
||||
* Determine whether the current process is permitted to use a particular
|
||||
* syslog function, returning 0 if permission is granted, -ve if not.
|
||||
*/
|
||||
int cap_syslog(int type, bool from_file)
|
||||
{
|
||||
if (type != SYSLOG_ACTION_OPEN && from_file)
|
||||
return 0;
|
||||
if (dmesg_restrict && !capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
if ((type != SYSLOG_ACTION_READ_ALL &&
|
||||
type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* cap_vm_enough_memory - Determine whether a new virtual mapping is permitted
|
||||
* @mm: The VM space in which the new mapping is to be made
|
||||
|
Reference in New Issue
Block a user