Fix prlimit64 for suid/sgid processes
PATCH 1/1 Fix prlimit64 for suid/sgid processes
Since check_prlimit_permission always fails in the case of SUID/GUID processes, such processes are not able to read or set their own limits. This commit changes this by assuming that process can always read/change its own limits.
--- kernel/sys.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
kernel/sys.c +6 -4
@@ -1409,10 +1409,12 @@ SYSCALL_DEFINE4(prlimit64, pid_t, pid, unsigned int, resource,rcu_read_unlock ();return -ESRCH ; } - ret =check_prlimit_permission (tsk); -if (ret) { -rcu_read_unlock (); -return ret; +if (tsk != current) { + ret =check_prlimit_permission (tsk); +if (ret) { +rcu_read_unlock (); +return ret; + } }get_task_struct (tsk);rcu_read_unlock ();
Signature · 1 line
Kacper Kornet
Quoted 4 lines · Kacper Kornet
Since
check_prlimit_permissionalways fails in the case of SUID/GUID processes, such processes are not able to read or set their own limits. This commit changes this by assuming that process can always read/change its own limits.
Shouldn't this be fixed in check_prlimit_permissions() instead of in the caller?
Linus
PATCH v2 1/1 Fix prlimit64 for suid/sgid processes
Since check_prlimit_permission always fails in the case of SUID/GUID processes, such processes are not able to read or set their own limits. This commit changes this by assuming that process can always read/change its own limits.
--- kernel/sys.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/sys.c +2 -1
@@ -1375,7 +1375,8 @@ static int check_prlimit_permission(struct task_struct *task)const struct cred *cred =current_cred (), *tcred; tcred =__task_cred (task); - if ((cred->uid != tcred->euid || + if (current != task && + (cred->uid != tcred->euid || cred->uid != tcred->suid || cred->uid != tcred->uid || cred->gid != tcred->egid ||
Signature · 4 lines
1.7.3.5 -- Kacper
Quoted 6 lines · Kacper Kornet
Since
check_prlimit_permissionalways fails in the case of SUID/GUID processes, such processes are not able to read or set their own limits. This commit changes this by assuming that process can always read/change its own limits.Signed-off-by Kacper Kornet <[email protected]>
ACK. The check comes from the ptrace code. I forgot to copy this test.
Quoted 9 lines
--- kernel/sys.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)kernel/sys.c +0
-0
kernel/sys.c static int check_prlimit_permission(struct task_struct *task) · line 1382
Quoted 9 lines
kernel/sys.c +2
-1@@ -1375,7 +1375,8 @@ static int check_prlimit_permission(struct task_struct *task)const struct cred *cred =current_cred (), *tcred; tcred =__task_cred (task); - if ((cred->uid != tcred->euid || + if (current != task && + (cred->uid != tcred->euid || cred->uid != tcred->suid || cred->uid != tcred->uid || cred->gid != tcred->egid ||
thanks,
Signature · 2 lines
js suse labs
Ccing stable.
Merged as aa5bd67dcfdf9 and should go into:
->.36-stable (if maintained still)
->.37-stable
Quoted 15 lines · Kacper Kornet
Since
check_prlimit_permissionalways fails in the case of SUID/GUID processes, such processes are not able to read or set their own limits. This commit changes this by assuming that process can always read/change its own limits.Signed-off-by Kacper Kornet <[email protected]>--- kernel/sys.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)kernel/sys.c +0
-0
kernel/sys.c static int check_prlimit_permission(struct task_struct *task) · line 1382
Quoted 9 lines
kernel/sys.c +2
-1@@ -1375,7 +1375,8 @@ static int check_prlimit_permission(struct task_struct *task)const struct cred *cred =current_cred (), *tcred; tcred =__task_cred (task); - if ((cred->uid != tcred->euid || + if (current != task && + (cred->uid != tcred->euid || cred->uid != tcred->suid || cred->uid != tcred->uid || cred->gid != tcred->egid ||
thanks,
Signature · 2 lines
js suse labs
Quoted 5 lines · Jiri Slaby
Ccing stable.
Merged as
aa5bd67dcfdf9and should go into:
->.36-stable (if maintained still)
->.37-stable
Thanks, now queued up.
greg k-h