Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 222149
b: refs/heads/master
c: 12b3052
h: refs/heads/master
i:
  222147: 7773b04
v: v3
  • Loading branch information
Eric Paris authored and Linus Torvalds committed Nov 15, 2010
1 parent 887695f commit 111c9c9
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6800e4c0ea3e96cf78953b8b5743381cb1bb9e37
refs/heads/master: 12b3052c3ee8f508b2c7ee4ddd63ed03423409d8
9 changes: 4 additions & 5 deletions trunk/include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
extern int cap_task_setscheduler(struct task_struct *p);
extern int cap_task_setioprio(struct task_struct *p, int ioprio);
extern int cap_task_setnice(struct task_struct *p, int nice);
extern int cap_syslog(int type, bool from_file);
extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);

struct msghdr;
Expand Down Expand Up @@ -1388,7 +1387,7 @@ struct security_operations {
int (*sysctl) (struct ctl_table *table, int op);
int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
int (*quota_on) (struct dentry *dentry);
int (*syslog) (int type, bool from_file);
int (*syslog) (int type);
int (*settime) (struct timespec *ts, struct timezone *tz);
int (*vm_enough_memory) (struct mm_struct *mm, long pages);

Expand Down Expand Up @@ -1671,7 +1670,7 @@ int security_real_capable_noaudit(struct task_struct *tsk, int cap);
int security_sysctl(struct ctl_table *table, int op);
int security_quotactl(int cmds, int type, int id, struct super_block *sb);
int security_quota_on(struct dentry *dentry);
int security_syslog(int type, bool from_file);
int security_syslog(int type);
int security_settime(struct timespec *ts, struct timezone *tz);
int security_vm_enough_memory(long pages);
int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
Expand Down Expand Up @@ -1901,9 +1900,9 @@ static inline int security_quota_on(struct dentry *dentry)
return 0;
}

static inline int security_syslog(int type, bool from_file)
static inline int security_syslog(int type)
{
return cap_syslog(type, from_file);
return 0;
}

static inline int security_settime(struct timespec *ts, struct timezone *tz)
Expand Down
15 changes: 14 additions & 1 deletion trunk/kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,20 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
char c;
int error = 0;

error = security_syslog(type, from_file);
/*
* If this is from /proc/kmsg we only do the capabilities checks
* at open time.
*/
if (type == SYSLOG_ACTION_OPEN || !from_file) {
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;
}

error = security_syslog(type);
if (error)
return error;

Expand Down
5 changes: 5 additions & 0 deletions trunk/security/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ static int cap_sysctl(ctl_table *table, int op)
return 0;
}

static int cap_syslog(int type)
{
return 0;
}

static int cap_quotactl(int cmds, int type, int id, struct super_block *sb)
{
return 0;
Expand Down
21 changes: 0 additions & 21 deletions trunk/security/commoncap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -883,26 +882,6 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
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
Expand Down
4 changes: 2 additions & 2 deletions trunk/security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ int security_quota_on(struct dentry *dentry)
return security_ops->quota_on(dentry);
}

int security_syslog(int type, bool from_file)
int security_syslog(int type)
{
return security_ops->syslog(type, from_file);
return security_ops->syslog(type);
}

int security_settime(struct timespec *ts, struct timezone *tz)
Expand Down
6 changes: 1 addition & 5 deletions trunk/security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1973,14 +1973,10 @@ static int selinux_quota_on(struct dentry *dentry)
return dentry_has_perm(cred, NULL, dentry, FILE__QUOTAON);
}

static int selinux_syslog(int type, bool from_file)
static int selinux_syslog(int type)
{
int rc;

rc = cap_syslog(type, from_file);
if (rc)
return rc;

switch (type) {
case SYSLOG_ACTION_READ_ALL: /* Read last kernel messages */
case SYSLOG_ACTION_SIZE_BUFFER: /* Return size of the log buffer */
Expand Down
8 changes: 2 additions & 6 deletions trunk/security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,11 @@ static int smack_ptrace_traceme(struct task_struct *ptp)
*
* Returns 0 on success, error code otherwise.
*/
static int smack_syslog(int type, bool from_file)
static int smack_syslog(int typefrom_file)
{
int rc;
int rc = 0;
char *sp = current_security();

rc = cap_syslog(type, from_file);
if (rc != 0)
return rc;

if (capable(CAP_MAC_OVERRIDE))
return 0;

Expand Down

0 comments on commit 111c9c9

Please sign in to comment.