Skip to content

Commit

Permalink
Merge branch 'stable-4.11' of git://git.infradead.org/users/pcmoore/s…
Browse files Browse the repository at this point in the history
…elinux into next
  • Loading branch information
James Morris committed Feb 9, 2017
2 parents e2241be + 1ea0ce4 commit a2a1547
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 314 deletions.
13 changes: 9 additions & 4 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2488,6 +2488,12 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
length = -ESRCH;
if (!task)
goto out_no_task;

/* A task may only write its own attributes. */
length = -EACCES;
if (current != task)
goto out;

if (count > PAGE_SIZE)
count = PAGE_SIZE;

Expand All @@ -2503,14 +2509,13 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
}

/* Guard against adverse ptrace interaction */
length = mutex_lock_interruptible(&task->signal->cred_guard_mutex);
length = mutex_lock_interruptible(&current->signal->cred_guard_mutex);
if (length < 0)
goto out_free;

length = security_setprocattr(task,
(char*)file->f_path.dentry->d_name.name,
length = security_setprocattr(file->f_path.dentry->d_name.name,
page, count);
mutex_unlock(&task->signal->cred_guard_mutex);
mutex_unlock(&current->signal->cred_guard_mutex);
out_free:
kfree(page);
out:
Expand Down
10 changes: 1 addition & 9 deletions include/linux/lsm_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,6 @@
* @sig contains the signal value.
* @secid contains the sid of the process where the signal originated
* Return 0 if permission is granted.
* @task_wait:
* Check permission before allowing a process to reap a child process @p
* and collect its status information.
* @p contains the task_struct for process.
* Return 0 if permission is granted.
* @task_prctl:
* Check permission before performing a process control operation on the
* current process.
Expand Down Expand Up @@ -1506,7 +1501,6 @@ union security_list_options {
int (*task_movememory)(struct task_struct *p);
int (*task_kill)(struct task_struct *p, struct siginfo *info,
int sig, u32 secid);
int (*task_wait)(struct task_struct *p);
int (*task_prctl)(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5);
void (*task_to_inode)(struct task_struct *p, struct inode *inode);
Expand Down Expand Up @@ -1546,8 +1540,7 @@ union security_list_options {
void (*d_instantiate)(struct dentry *dentry, struct inode *inode);

int (*getprocattr)(struct task_struct *p, char *name, char **value);
int (*setprocattr)(struct task_struct *p, char *name, void *value,
size_t size);
int (*setprocattr)(const char *name, void *value, size_t size);
int (*ismaclabel)(const char *name);
int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
int (*secctx_to_secid)(const char *secdata, u32 seclen, u32 *secid);
Expand Down Expand Up @@ -1767,7 +1760,6 @@ struct security_hook_heads {
struct list_head task_getscheduler;
struct list_head task_movememory;
struct list_head task_kill;
struct list_head task_wait;
struct list_head task_prctl;
struct list_head task_to_inode;
struct list_head ipc_permission;
Expand Down
10 changes: 2 additions & 8 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ int security_task_getscheduler(struct task_struct *p);
int security_task_movememory(struct task_struct *p);
int security_task_kill(struct task_struct *p, struct siginfo *info,
int sig, u32 secid);
int security_task_wait(struct task_struct *p);
int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5);
void security_task_to_inode(struct task_struct *p, struct inode *inode);
Expand Down Expand Up @@ -361,7 +360,7 @@ int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
unsigned nsops, int alter);
void security_d_instantiate(struct dentry *dentry, struct inode *inode);
int security_getprocattr(struct task_struct *p, char *name, char **value);
int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
int security_setprocattr(const char *name, void *value, size_t size);
int security_netlink_send(struct sock *sk, struct sk_buff *skb);
int security_ismaclabel(const char *name);
int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
Expand Down Expand Up @@ -980,11 +979,6 @@ static inline int security_task_kill(struct task_struct *p,
return 0;
}

static inline int security_task_wait(struct task_struct *p)
{
return 0;
}

static inline int security_task_prctl(int option, unsigned long arg2,
unsigned long arg3,
unsigned long arg4,
Expand Down Expand Up @@ -1106,7 +1100,7 @@ static inline int security_getprocattr(struct task_struct *p, char *name, char *
return -EINVAL;
}

static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
static inline int security_setprocattr(char *name, void *value, size_t size)
{
return -EINVAL;
}
Expand Down
19 changes: 2 additions & 17 deletions kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <linux/tty.h>
#include <linux/iocontext.h>
#include <linux/key.h>
#include <linux/security.h>
#include <linux/cpu.h>
#include <linux/acct.h>
#include <linux/tsacct_kern.h>
Expand Down Expand Up @@ -1360,7 +1359,7 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
* Returns nonzero for a final return, when we have unlocked tasklist_lock.
* Returns zero if the search for a child should continue;
* then ->notask_error is 0 if @p is an eligible child,
* or another error from security_task_wait(), or still -ECHILD.
* or still -ECHILD.
*/
static int wait_consider_task(struct wait_opts *wo, int ptrace,
struct task_struct *p)
Expand All @@ -1380,20 +1379,6 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
if (!ret)
return ret;

ret = security_task_wait(p);
if (unlikely(ret < 0)) {
/*
* If we have not yet seen any eligible child,
* then let this error code replace -ECHILD.
* A permission error will give the user a clue
* to look for security policy problems, rather
* than for mysterious wait bugs.
*/
if (wo->notask_error)
wo->notask_error = ret;
return 0;
}

if (unlikely(exit_state == EXIT_TRACE)) {
/*
* ptrace == 0 means we are the natural parent. In this case
Expand Down Expand Up @@ -1486,7 +1471,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
* Returns nonzero for a final return, when we have unlocked tasklist_lock.
* Returns zero if the search for a child should continue; then
* ->notask_error is 0 if there were any eligible children,
* or another error from security_task_wait(), or still -ECHILD.
* or still -ECHILD.
*/
static int do_wait_thread(struct wait_opts *wo, struct task_struct *tsk)
{
Expand Down
7 changes: 2 additions & 5 deletions security/apparmor/lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ static int apparmor_getprocattr(struct task_struct *task, char *name,
return error;
}

static int apparmor_setprocattr(struct task_struct *task, char *name,
void *value, size_t size)
static int apparmor_setprocattr(const char *name, void *value,
size_t size)
{
char *command, *largs = NULL, *args = value;
size_t arg_size;
Expand All @@ -515,9 +515,6 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,

if (size == 0)
return -EINVAL;
/* task can only write its own attributes */
if (current != task)
return -EACCES;

/* AppArmor requires that the buffer must be null terminated atm */
if (args[size - 1] != '\0') {
Expand Down
10 changes: 2 additions & 8 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,11 +1063,6 @@ int security_task_kill(struct task_struct *p, struct siginfo *info,
return call_int_hook(task_kill, 0, p, info, sig, secid);
}

int security_task_wait(struct task_struct *p)
{
return call_int_hook(task_wait, 0, p);
}

int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
Expand Down Expand Up @@ -1208,9 +1203,9 @@ int security_getprocattr(struct task_struct *p, char *name, char **value)
return call_int_hook(getprocattr, -EINVAL, p, name, value);
}

int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
int security_setprocattr(const char *name, void *value, size_t size)
{
return call_int_hook(setprocattr, -EINVAL, p, name, value, size);
return call_int_hook(setprocattr, -EINVAL, name, value, size);
}

int security_netlink_send(struct sock *sk, struct sk_buff *skb)
Expand Down Expand Up @@ -1807,7 +1802,6 @@ struct security_hook_heads security_hook_heads = {
.task_movememory =
LIST_HEAD_INIT(security_hook_heads.task_movememory),
.task_kill = LIST_HEAD_INIT(security_hook_heads.task_kill),
.task_wait = LIST_HEAD_INIT(security_hook_heads.task_wait),
.task_prctl = LIST_HEAD_INIT(security_hook_heads.task_prctl),
.task_to_inode =
LIST_HEAD_INIT(security_hook_heads.task_to_inode),
Expand Down
Loading

0 comments on commit a2a1547

Please sign in to comment.