proc: Fix timerslack_ns CAP_SYS_NICE check when adjusting self
PATCH RESEND 1/1 proc: Fix timerslack_ns CAP_SYS_NICE check when adjusting self
In changing from checking ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS) to capable(CAP_SYS_NICE), I missed that ptrace_my_access succeeds when p == current, but the CAP_SYS_NICE doesn't.
Thus while the previous commit was intended to loosen the needed privledges to modify a processes timerslack, it needlessly restricted a task modifying its own timerslack via the proc/<tid>/timerslack_ns (which is permitted also via the PR_SET_TIMERSLACK method).
This patch corrects this by checking if p == current before checking the CAP_SYS_NICE value.
This patch applies on top of my two previous patches currently in -mm
--- fs/proc/base.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
fs/proc/base.c +19 -15
@@ -2281,15 +2281,17 @@ static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,if (!p)return -ESRCH ; -if (!capable (CAP_SYS_NICE )) { - count = -EPERM ; - goto out; - } +if (p != current) { +if (!capable (CAP_SYS_NICE )) { + count = -EPERM ; + goto out; + } - err =security_task_setscheduler (p); -if (err) { - count = err; - goto out; + err =security_task_setscheduler (p); +if (err) { + count = err; + goto out; + } }task_lock (p);
@@ -2315,14 +2317,16 @@ static int timerslack_ns_show(struct seq_file *m, void *v)if (!p)return -ESRCH ; -if (!capable (CAP_SYS_NICE )) { - err = -EPERM ; - goto out; - } +if (p != current) { - err =security_task_getscheduler (p); -if (err) - goto out; +if (!capable (CAP_SYS_NICE )) { + err = -EPERM ; + goto out; + } + err =security_task_getscheduler (p); +if (err) + goto out; + }task_lock (p);seq_printf (m,"%llu\n" , p->timer_slack_ns);
Signature · 1 line
1.9.1
Quoted 9 lines · John Stultz
In changing from checking
ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)tocapable(CAP_SYS_NICE), I missed thatptrace_my_accesssucceeds when p == current, but theCAP_SYS_NICEdoesn't.Thus while the previous commit was intended to loosen the needed privledges to modify a processes timerslack, it needlessly restricted a task modifying its own timerslack via the proc/<tid>/timerslack_ns (which is permitted also via the
PR_SET_TIMERSLACKmethod).
Quoted 4 lines
This patch corrects this by checking if p == current before checking the
CAP_SYS_NICEvalue.This patch applies on top of my two previous patches currently in -mm
Ping? Any feedback or comments on this one?
thanks
-john
Quoted 10 lines · John Stultz
Quoted 9 lines · John Stultz
In changing from checking
ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)tocapable(CAP_SYS_NICE), I missed thatptrace_my_accesssucceeds when p == current, but theCAP_SYS_NICEdoesn't.Thus while the previous commit was intended to loosen the needed privledges to modify a processes timerslack, it needlessly restricted a task modifying its own timerslack via the proc/<tid>/timerslack_ns (which is permitted also via the
PR_SET_TIMERSLACKmethod).
Quoted 6 lines
Quoted 4 lines
This patch corrects this by checking if p == current before checking the
CAP_SYS_NICEvalue.This patch applies on top of my two previous patches currently in -mm
Ping? Any feedback or comments on this one?
(sorry - no objection from me on this patch, thanks)
Quoted 14 lines · John Stultz
In changing from checking
ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)tocapable(CAP_SYS_NICE), I missed thatptrace_my_accesssucceeds when p == current, but theCAP_SYS_NICEdoesn't.Thus while the previous commit was intended to loosen the needed privledges to modify a processes timerslack, it needlessly restricted a task modifying its own timerslack via the proc/<tid>/timerslack_ns (which is permitted also via the
PR_SET_TIMERSLACKmethod).This patch corrects this by checking if p == current before checking the
CAP_SYS_NICEvalue.This patch applies on top of my two previous patches currently in -mm
Quoted 16 lines
Cc Kees Cook <[email protected]>Cc "Serge E. Hallyn" <[email protected]>Cc Andrew Morton <[email protected]>Cc Thomas Gleixner <[email protected]>CC Arjan van de Ven <[email protected]>Cc Oren Laadan <[email protected]>Cc Ruchi Kandoi <[email protected]>Cc Rom Lemarchand <[email protected]>Cc Todd Kjos <[email protected]>Cc Colin Cross <[email protected]>Cc Nick Kralevich <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Elliott Hughes <[email protected]>Cc Android Kernel Team <[email protected]>Acked-by Kees Cook <[email protected]>Signed-off-by John Stultz <[email protected]>
Andrew, can you take this for v4.8?
-Kees
Quoted 61 lines
--- fs/proc/base.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)fs/proc/base.c +19
-16@@ -2281,15 +2281,17 @@ static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,if (!p)return -ESRCH ; -if (!capable (CAP_SYS_NICE )) { - count = -EPERM ; - goto out; - } +if (p != current) { +if (!capable (CAP_SYS_NICE )) { + count = -EPERM ; + goto out; + } - err =security_task_setscheduler (p); -if (err) { - count = err; - goto out; + err =security_task_setscheduler (p); +if (err) { + count = err; + goto out; + } }task_lock (p);@@ -2315,14 +2317,16 @@ static int timerslack_ns_show(struct seq_file *m, void *v)if (!p)return -ESRCH ; -if (!capable (CAP_SYS_NICE )) { - err = -EPERM ; - goto out; - } +if (p != current) { - err =security_task_getscheduler (p); -if (err) - goto out; +if (!capable (CAP_SYS_NICE )) { + err = -EPERM ; + goto out; + } + err =security_task_getscheduler (p); +if (err) + goto out; + }task_lock (p);seq_printf (m,"%llu\n" , p->timer_slack_ns); --1.9.1
Signature · 2 lines
Kees Cook Nexus Security
Quoted 32 lines · On Tue, 30 Aug 2016 18:46:23 -0400 Kees Cook <[email protected]> wrote:
Quoted 14 lines · John Stultz
In changing from checking
ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)tocapable(CAP_SYS_NICE), I missed thatptrace_my_accesssucceeds when p == current, but theCAP_SYS_NICEdoesn't.Thus while the previous commit was intended to loosen the needed privledges to modify a processes timerslack, it needlessly restricted a task modifying its own timerslack via the proc/<tid>/timerslack_ns (which is permitted also via the
PR_SET_TIMERSLACKmethod).This patch corrects this by checking if p == current before checking the
CAP_SYS_NICEvalue.This patch applies on top of my two previous patches currently in -mm
Quoted 16 lines
Cc Kees Cook <[email protected]>Cc "Serge E. Hallyn" <[email protected]>Cc Andrew Morton <[email protected]>Cc Thomas Gleixner <[email protected]>CC Arjan van de Ven <[email protected]>Cc Oren Laadan <[email protected]>Cc Ruchi Kandoi <[email protected]>Cc Rom Lemarchand <[email protected]>Cc Todd Kjos <[email protected]>Cc Colin Cross <[email protected]>Cc Nick Kralevich <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Elliott Hughes <[email protected]>Cc Android Kernel Team <[email protected]>Acked-by Kees Cook <[email protected]>Signed-off-by John Stultz <[email protected]>
Quoted 1 line
Andrew, can you take this for v4.8?
Well, it fixes proc-relax-proc-tid-timerslack_ns-capability-requirements.patch, somewhat. And it textually depends on that.
Do we want all of
proc-relax-proc-tid-timerslack_ns-capability-requirements.patch proc-add-lsm-hook-checks-to-proc-tid-timerslack_ns.patch proc-fix-timerslack_ns-cap_sys_nice-check-when-adjusting-self.patch
in 4.8? If so, why?
Quoted 40 lines · Andrew Morton
Quoted 32 lines · On Tue, 30 Aug 2016 18:46:23 -0400 Kees Cook <[email protected]> wrote:
Quoted 14 lines · John Stultz
In changing from checking
ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)tocapable(CAP_SYS_NICE), I missed thatptrace_my_accesssucceeds when p == current, but theCAP_SYS_NICEdoesn't.Thus while the previous commit was intended to loosen the needed privledges to modify a processes timerslack, it needlessly restricted a task modifying its own timerslack via the proc/<tid>/timerslack_ns (which is permitted also via the
PR_SET_TIMERSLACKmethod).This patch corrects this by checking if p == current before checking the
CAP_SYS_NICEvalue.This patch applies on top of my two previous patches currently in -mm
Quoted 16 lines
Cc Kees Cook <[email protected]>Cc "Serge E. Hallyn" <[email protected]>Cc Andrew Morton <[email protected]>Cc Thomas Gleixner <[email protected]>CC Arjan van de Ven <[email protected]>Cc Oren Laadan <[email protected]>Cc Ruchi Kandoi <[email protected]>Cc Rom Lemarchand <[email protected]>Cc Todd Kjos <[email protected]>Cc Colin Cross <[email protected]>Cc Nick Kralevich <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Elliott Hughes <[email protected]>Cc Android Kernel Team <[email protected]>Acked-by Kees Cook <[email protected]>Signed-off-by John Stultz <[email protected]>Quoted 1 line
Andrew, can you take this for v4.8?
Well, it fixes proc-relax-proc-tid-timerslack_ns-capability-requirements.patch, somewhat. And it textually depends on that.
Quoted 7 lines
Do we want all of
proc-relax-proc-tid-timerslack_ns-capability-requirements.patch proc-add-lsm-hook-checks-to-proc-tid-timerslack_ns.patch proc-fix-timerslack_ns-cap_sys_nice-check-when-adjusting-self.patch
in 4.8? If so, why?
Oh, my misunderstanding. I thought those already landed in 4.8. If not, nevermind on the "rush". :) Thanks for picking it up!
-Kees
Signature · 2 lines
Kees Cook Nexus Security
Quoted 40 lines · Andrew Morton
Quoted 32 lines · On Tue, 30 Aug 2016 18:46:23 -0400 Kees Cook <[email protected]> wrote:
Quoted 14 lines · John Stultz
In changing from checking
ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)tocapable(CAP_SYS_NICE), I missed thatptrace_my_accesssucceeds when p == current, but theCAP_SYS_NICEdoesn't.Thus while the previous commit was intended to loosen the needed privledges to modify a processes timerslack, it needlessly restricted a task modifying its own timerslack via the proc/<tid>/timerslack_ns (which is permitted also via the
PR_SET_TIMERSLACKmethod).This patch corrects this by checking if p == current before checking the
CAP_SYS_NICEvalue.This patch applies on top of my two previous patches currently in -mm
Quoted 16 lines
Cc Kees Cook <[email protected]>Cc "Serge E. Hallyn" <[email protected]>Cc Andrew Morton <[email protected]>Cc Thomas Gleixner <[email protected]>CC Arjan van de Ven <[email protected]>Cc Oren Laadan <[email protected]>Cc Ruchi Kandoi <[email protected]>Cc Rom Lemarchand <[email protected]>Cc Todd Kjos <[email protected]>Cc Colin Cross <[email protected]>Cc Nick Kralevich <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Elliott Hughes <[email protected]>Cc Android Kernel Team <[email protected]>Acked-by Kees Cook <[email protected]>Signed-off-by John Stultz <[email protected]>Quoted 1 line
Andrew, can you take this for v4.8?
Well, it fixes proc-relax-proc-tid-timerslack_ns-capability-requirements.patch, somewhat. And it textually depends on that.
Quoted 7 lines
Do we want all of
proc-relax-proc-tid-timerslack_ns-capability-requirements.patch proc-add-lsm-hook-checks-to-proc-tid-timerslack_ns.patch proc-fix-timerslack_ns-cap_sys_nice-check-when-adjusting-self.patch
in 4.8? If so, why?
No.. they're fine to wait for the 4.9 merge window. But you picking up this last fix is appreciated!
thanks
-john