Commit 62561c77 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

LSM: change if statements into something more readable for the kernel.* files.

parent c0315f4b
...@@ -223,7 +223,8 @@ asmlinkage long sys_acct(const char *name) ...@@ -223,7 +223,8 @@ asmlinkage long sys_acct(const char *name)
} }
} }
if ((error = security_acct(file))) error = security_acct(file);
if (error)
return error; return error;
spin_lock(&acct_globals.lock); spin_lock(&acct_globals.lock);
......
...@@ -717,7 +717,8 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -717,7 +717,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
if ((clone_flags & CLONE_DETACHED) && !(clone_flags & CLONE_THREAD)) if ((clone_flags & CLONE_DETACHED) && !(clone_flags & CLONE_THREAD))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if ((retval = security_task_create(clone_flags))) retval = security_task_create(clone_flags);
if (retval)
goto fork_out; goto fork_out;
retval = -ENOMEM; retval = -ENOMEM;
......
...@@ -101,7 +101,8 @@ int ptrace_attach(struct task_struct *task) ...@@ -101,7 +101,8 @@ int ptrace_attach(struct task_struct *task)
/* the same process cannot be attached many times */ /* the same process cannot be attached many times */
if (task->ptrace & PT_PTRACED) if (task->ptrace & PT_PTRACED)
goto bad; goto bad;
if ((retval = security_ptrace(current, task))) retval = security_ptrace(current, task);
if (retval)
goto bad; goto bad;
/* Go */ /* Go */
......
...@@ -1348,7 +1348,8 @@ asmlinkage long sys_nice(int increment) ...@@ -1348,7 +1348,8 @@ asmlinkage long sys_nice(int increment)
if (nice > 19) if (nice > 19)
nice = 19; nice = 19;
if ((retval = security_task_setnice(current, nice))) retval = security_task_setnice(current, nice);
if (retval)
return retval; return retval;
set_user_nice(current, nice); set_user_nice(current, nice);
...@@ -1469,7 +1470,8 @@ static int setscheduler(pid_t pid, int policy, struct sched_param *param) ...@@ -1469,7 +1470,8 @@ static int setscheduler(pid_t pid, int policy, struct sched_param *param)
!capable(CAP_SYS_NICE)) !capable(CAP_SYS_NICE))
goto out_unlock; goto out_unlock;
if ((retval = security_task_setscheduler(p, policy, &lp))) retval = security_task_setscheduler(p, policy, &lp);
if (retval)
goto out_unlock; goto out_unlock;
array = p->array; array = p->array;
...@@ -1532,7 +1534,8 @@ asmlinkage long sys_sched_getscheduler(pid_t pid) ...@@ -1532,7 +1534,8 @@ asmlinkage long sys_sched_getscheduler(pid_t pid)
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
p = find_process_by_pid(pid); p = find_process_by_pid(pid);
if (p) { if (p) {
if (!(retval = security_task_getscheduler(p))) retval = security_task_getscheduler(p);
if (!retval)
retval = p->policy; retval = p->policy;
} }
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
...@@ -1561,7 +1564,8 @@ asmlinkage long sys_sched_getparam(pid_t pid, struct sched_param *param) ...@@ -1561,7 +1564,8 @@ asmlinkage long sys_sched_getparam(pid_t pid, struct sched_param *param)
if (!p) if (!p)
goto out_unlock; goto out_unlock;
if ((retval = security_task_getscheduler(p))) retval = security_task_getscheduler(p);
if (retval)
goto out_unlock; goto out_unlock;
lp.sched_priority = p->rt_priority; lp.sched_priority = p->rt_priority;
...@@ -1820,7 +1824,8 @@ asmlinkage long sys_sched_rr_get_interval(pid_t pid, struct timespec *interval) ...@@ -1820,7 +1824,8 @@ asmlinkage long sys_sched_rr_get_interval(pid_t pid, struct timespec *interval)
if (!p) if (!p)
goto out_unlock; goto out_unlock;
if ((retval = security_task_getscheduler(p))) retval = security_task_getscheduler(p);
if (retval)
goto out_unlock; goto out_unlock;
jiffies_to_timespec(p->policy & SCHED_FIFO ? jiffies_to_timespec(p->policy & SCHED_FIFO ?
......
...@@ -739,7 +739,8 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t, int ...@@ -739,7 +739,8 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t, int
ret = -EPERM; ret = -EPERM;
if (bad_signal(sig, info, t)) if (bad_signal(sig, info, t))
goto out; goto out;
if ((ret = security_task_kill(t, info, sig))) ret = security_task_kill(t, info, sig);
if (ret)
goto out; goto out;
/* The null signal is a permissions and process existence probe. /* The null signal is a permissions and process existence probe.
......
...@@ -485,7 +485,8 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid) ...@@ -485,7 +485,8 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid)
int new_egid = old_egid; int new_egid = old_egid;
int retval; int retval;
if ((retval = security_task_setgid(rgid, egid, (gid_t)-1, LSM_SETID_RE))) retval = security_task_setgid(rgid, egid, (gid_t)-1, LSM_SETID_RE);
if (retval)
return retval; return retval;
if (rgid != (gid_t) -1) { if (rgid != (gid_t) -1) {
...@@ -530,7 +531,8 @@ asmlinkage long sys_setgid(gid_t gid) ...@@ -530,7 +531,8 @@ asmlinkage long sys_setgid(gid_t gid)
int old_egid = current->egid; int old_egid = current->egid;
int retval; int retval;
if ((retval = security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_ID))) retval = security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_ID);
if (retval)
return retval; return retval;
if (capable(CAP_SETGID)) if (capable(CAP_SETGID))
...@@ -603,7 +605,8 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid) ...@@ -603,7 +605,8 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
int old_ruid, old_euid, old_suid, new_ruid, new_euid; int old_ruid, old_euid, old_suid, new_ruid, new_euid;
int retval; int retval;
if ((retval = security_task_setuid(ruid, euid, (uid_t)-1, LSM_SETID_RE))) retval = security_task_setuid(ruid, euid, (uid_t)-1, LSM_SETID_RE);
if (retval)
return retval; return retval;
new_ruid = old_ruid = current->uid; new_ruid = old_ruid = current->uid;
...@@ -663,7 +666,8 @@ asmlinkage long sys_setuid(uid_t uid) ...@@ -663,7 +666,8 @@ asmlinkage long sys_setuid(uid_t uid)
int old_ruid, old_suid, new_ruid, new_suid; int old_ruid, old_suid, new_ruid, new_suid;
int retval; int retval;
if ((retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID))) retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
if (retval)
return retval; return retval;
old_ruid = new_ruid = current->uid; old_ruid = new_ruid = current->uid;
...@@ -700,7 +704,8 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid) ...@@ -700,7 +704,8 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
int old_suid = current->suid; int old_suid = current->suid;
int retval; int retval;
if ((retval = security_task_setuid(ruid, euid, suid, LSM_SETID_RES))) retval = security_task_setuid(ruid, euid, suid, LSM_SETID_RES);
if (retval)
return retval; return retval;
if (!capable(CAP_SETUID)) { if (!capable(CAP_SETUID)) {
...@@ -751,7 +756,8 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid) ...@@ -751,7 +756,8 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
{ {
int retval; int retval;
if ((retval = security_task_setgid(rgid, egid, sgid, LSM_SETID_RES))) retval = security_task_setgid(rgid, egid, sgid, LSM_SETID_RES);
if (retval)
return retval; return retval;
if (!capable(CAP_SETGID)) { if (!capable(CAP_SETGID)) {
...@@ -804,7 +810,8 @@ asmlinkage long sys_setfsuid(uid_t uid) ...@@ -804,7 +810,8 @@ asmlinkage long sys_setfsuid(uid_t uid)
int old_fsuid; int old_fsuid;
int retval; int retval;
if ((retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS))) retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS);
if (retval)
return retval; return retval;
old_fsuid = current->fsuid; old_fsuid = current->fsuid;
...@@ -820,7 +827,8 @@ asmlinkage long sys_setfsuid(uid_t uid) ...@@ -820,7 +827,8 @@ asmlinkage long sys_setfsuid(uid_t uid)
current->fsuid = uid; current->fsuid = uid;
} }
if ((retval = security_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS))) retval = security_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS);
if (retval)
return retval; return retval;
return old_fsuid; return old_fsuid;
...@@ -834,7 +842,8 @@ asmlinkage long sys_setfsgid(gid_t gid) ...@@ -834,7 +842,8 @@ asmlinkage long sys_setfsgid(gid_t gid)
int old_fsgid; int old_fsgid;
int retval; int retval;
if ((retval = security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_FS))) retval = security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_FS);
if (retval)
return retval; return retval;
old_fsgid = current->fsgid; old_fsgid = current->fsgid;
...@@ -959,7 +968,8 @@ asmlinkage long sys_getpgid(pid_t pid) ...@@ -959,7 +968,8 @@ asmlinkage long sys_getpgid(pid_t pid)
retval = -ESRCH; retval = -ESRCH;
if (p) { if (p) {
if (!(retval = security_task_getpgid(p))) retval = security_task_getpgid(p);
if (!retval)
retval = p->pgrp; retval = p->pgrp;
} }
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
...@@ -986,7 +996,8 @@ asmlinkage long sys_getsid(pid_t pid) ...@@ -986,7 +996,8 @@ asmlinkage long sys_getsid(pid_t pid)
retval = -ESRCH; retval = -ESRCH;
if(p) { if(p) {
if (!(retval = security_task_getsid(p))) retval = security_task_getsid(p);
if (!retval)
retval = p->session; retval = p->session;
} }
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
...@@ -1067,7 +1078,8 @@ asmlinkage long sys_setgroups(int gidsetsize, gid_t *grouplist) ...@@ -1067,7 +1078,8 @@ asmlinkage long sys_setgroups(int gidsetsize, gid_t *grouplist)
return -EINVAL; return -EINVAL;
if(copy_from_user(groups, grouplist, gidsetsize * sizeof(gid_t))) if(copy_from_user(groups, grouplist, gidsetsize * sizeof(gid_t)))
return -EFAULT; return -EFAULT;
if ((retval = security_task_setgroups(gidsetsize, groups))) retval = security_task_setgroups(gidsetsize, groups);
if (retval)
return retval; return retval;
memcpy(current->groups, groups, gidsetsize * sizeof(gid_t)); memcpy(current->groups, groups, gidsetsize * sizeof(gid_t));
current->ngroups = gidsetsize; current->ngroups = gidsetsize;
...@@ -1230,7 +1242,8 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit *rlim) ...@@ -1230,7 +1242,8 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit *rlim)
return -EPERM; return -EPERM;
} }
if ((retval = security_task_setrlimit(resource, &new_rlim))) retval = security_task_setrlimit(resource, &new_rlim);
if (retval)
return retval; return retval;
*old_rlim = new_rlim; *old_rlim = new_rlim;
...@@ -1304,7 +1317,8 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3, ...@@ -1304,7 +1317,8 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
int error = 0; int error = 0;
int sig; int sig;
if ((error = security_task_prctl(option, arg2, arg3, arg4, arg5))) error = security_task_prctl(option, arg2, arg3, arg4, arg5);
if (error)
return error; return error;
switch (option) { switch (option) {
......
...@@ -140,7 +140,8 @@ asmlinkage long sys_setgroups16(int gidsetsize, old_gid_t *grouplist) ...@@ -140,7 +140,8 @@ asmlinkage long sys_setgroups16(int gidsetsize, old_gid_t *grouplist)
return -EFAULT; return -EFAULT;
for (i = 0 ; i < gidsetsize ; i++) for (i = 0 ; i < gidsetsize ; i++)
new_groups[i] = (gid_t)groups[i]; new_groups[i] = (gid_t)groups[i];
if ((i = security_task_setgroups(gidsetsize, new_groups))) i = security_task_setgroups(gidsetsize, new_groups);
if (i)
return i; return i;
memcpy(current->groups, new_groups, gidsetsize * sizeof(gid_t)); memcpy(current->groups, new_groups, gidsetsize * sizeof(gid_t));
current->ngroups = gidsetsize; current->ngroups = gidsetsize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment