futex: do not leak robust list to unprivileged process
PATCH 1/1 futex: do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.
Running a setuid program that uses robust futexes would have had:
cred->euid != pcred->euid
cred->euid == pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.
(This patch is based on changes from grsecurity.)
--- kernel/futex.c | 36 +++++++++++++----------------------- kernel/futex_compat.c | 36 +++++++++++++----------------------- 2 files changed, 26 insertions(+), 46 deletions(-)
kernel/futex.c +13 -23
@@ -59,6 +59,7 @@#include <linux/magic.h> #include <linux/pid.h> #include <linux/nsproxy.h> +#include <linux/ptrace.h> #include <asm/futex.h>
@@ -2443,40 +2444,29 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, {struct robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (head, head_ptr);
kernel/futex_compat.c +13 -23
@@ -10,6 +10,7 @@#include <linux/compat.h> #include <linux/nsproxy.h> #include <linux/futex.h> +#include <linux/ptrace.h> #include <asm/uaccess.h>
@@ -136,40 +137,29 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, {struct compat_robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->compat_robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->compat_robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->compat_robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (ptr_to_compat (head), head_ptr);
Signature · 1 line
1.7.0.4
Quoted 11 lines · Kees Cook
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.
Quoted 3 lines
(This patch is based on changes from grsecurity.)
Signed-off-by Kees Cook <[email protected]>
I like the change. Much cleaner. I'm not 100% sure though that there are no legitimate cases of robust futexes use which would now be forbidden. (Explicitly cc:ing Ingo)
Quoted 138 lines
--- kernel/futex.c | 36 +++++++++++++----------------------- kernel/futex_compat.c | 36 +++++++++++++----------------------- 2 files changed, 26 insertions(+), 46 deletions(-)kernel/futex.c +13
-23@@ -59,6 +59,7 @@#include <linux/magic.h> #include <linux/pid.h> #include <linux/nsproxy.h> +#include <linux/ptrace.h> #include <asm/futex.h> @@ -2443,40 +2444,29 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, {struct robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (head, head_ptr);kernel/futex_compat.c +13
-23@@ -10,6 +10,7 @@#include <linux/compat.h> #include <linux/nsproxy.h> #include <linux/futex.h> +#include <linux/ptrace.h> #include <asm/uaccess.h> @@ -136,40 +137,29 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, {struct compat_robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->compat_robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->compat_robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->compat_robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (ptr_to_compat (head), head_ptr);Signature · 1 line
1.7.0.4
Quoted 12 lines · Serge Hallyn
Quoted 11 lines · Kees Cook
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.
Quoted 7 lines
Quoted 3 lines
(This patch is based on changes from grsecurity.)
Signed-off-by Kees Cook <[email protected]>I like the change. Much cleaner. I'm not 100% sure though that there are no legitimate cases of robust futexes use which would now be forbidden. (Explicitly cc:ing Ingo)
get_robust_list is not necessary for robust futexes. There is no reference to get_robust_list in glibc.
I really wonder why we have this syscall at all.
Thanks,
tglx
Quoted 18 lines · Thomas Gleixner
Quoted 16 lines · Serge Hallyn
Quoted 14 lines · Kees Cook
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.(This patch is based on changes from grsecurity.)
Signed-off-by Kees Cook <[email protected]>
Quoted 8 lines
Quoted 3 lines
I like the change. Much cleaner. I'm not 100% sure though that there are no legitimate cases of robust futexes use which would now be forbidden. (Explicitly cc:ing Ingo)
get_robust_listis not necessary for robust futexes. There is no reference toget_robust_listin glibc.I really wonder why we have this syscall at all.
The documentation I found yesterday while looking at this was:
http://linux.die.net/man/2/get_robust_list
Which says "The system call is only available for debugging purposes and is not needed for normal operations. Both system calls are not available to application programs as functions; they can be called using the syscall(3) function."
Dropping the syscall entirely would certainly make it secure. ;)
-Kees
Signature · 2 lines
Kees Cook ChromeOS Security
Quoted 31 lines · Kees Cook
Quoted 18 lines · Thomas Gleixner
Quoted 16 lines · Serge Hallyn
Quoted 14 lines · Kees Cook
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.(This patch is based on changes from grsecurity.)
Signed-off-by Kees Cook <[email protected]>Quoted 8 lines
Quoted 3 lines
I like the change. Much cleaner. I'm not 100% sure though that there are no legitimate cases of robust futexes use which would now be forbidden. (Explicitly cc:ing Ingo)
get_robust_listis not necessary for robust futexes. There is no reference toget_robust_listin glibc.I really wonder why we have this syscall at all.
The documentation I found yesterday while looking at this was:
http://linux.die.net/man/2/get_robust_list
Quoted 7 lines
Which says "The system call is only available for debugging purposes and is not needed for normal operations. Both system calls are not available to application programs as functions; they can be called using the syscall(3) function."
Dropping the syscall entirely would certainly make it secure. ;)
The thinking was API completeness. In general it's possible for a sufficiently privileged task to figure out all the state of a task. We can query timers, fds - the robust list is such a resource as well. The information leakage was obviously not intended.
Thanks,
Ingo
Quoted 12 lines · Ingo Molnar
Quoted 11 lines · Kees Cook
Quoted 1 line · Thomas Gleixner
I really wonder why we have this syscall at all.
The documentation I found yesterday while looking at this was:
http://linux.die.net/man/2/get_robust_listWhich says "The system call is only available for debugging purposes and is not needed for normal operations. Both system calls are not available to application programs as functions; they can be called using the syscall(3) function."
Quoted 8 lines
Quoted 2 lines
Dropping the syscall entirely would certainly make it secure. ;)
The thinking was API completeness. In general it's possible for a sufficiently privileged task to figure out all the state of a task. We can query timers, fds - the robust list is such a resource as well. The information leakage was obviously not intended.
So I think it's safe to take Kees' patch as is. On top of that we should add a WARN_ONCE when the syscall is invoked and schedule the sucker for removal.
Thoughts ?
tglx
PATCH 1/1 futex: mark get_robust_list as deprecated
Notify get_robust_list users that the syscall is going away.
--- kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
kernel/futex.c +2 -0
@@ -2449,6 +2449,8 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;
kernel/futex_compat.c +2 -0
@@ -142,6 +142,8 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;
Signature · 5 lines
1.7.0.4 -- Kees Cook ChromeOS Security
Re: [PATCH] futex: mark get_robust_list as deprecated
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.
That want's an entry in Documentation/feature-removal-schedule.txt as well.
That's on top of your previous one, right ?
Thanks,
tglx
Quoted 40 lines
Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>--- kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)kernel/futex.c +2
-0@@ -2449,6 +2449,8 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;kernel/futex_compat.c +2
-0@@ -142,6 +142,8 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;Signature · 5 lines
1.7.0.4 -- Kees Cook ChromeOS Security
Re: [PATCH] futex: mark get_robust_list as deprecated
Quoted 6 lines · Thomas Gleixner
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.That want's an entry in
Documentation/feature-removal-schedule.txtas well.
Ah! Yes, I will send a v2.
Quoted 1 line
That's on top of your previous one, right ?
Yup. :)
-Kees
Signature · 2 lines
Kees Cook ChromeOS Security
PATCH v2 1/1 futex: mark get_robust_list as deprecated
In reply to Thomas GleixnerNotify get_robust_list users that the syscall is going away.
---
v2:
- add note to feature-removal-schedule.txt.
--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-)
Documentation/feature-removal-schedule.txt +10 -0
@@ -543,3 +543,13 @@ When: 3.5 Why: The old kmap_atomic() with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it. Who: Cong Wang <[email protected]> + +---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed. +Who: Kees Cook <[email protected]>
kernel/futex.c +2 -0
@@ -2449,6 +2449,8 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;
kernel/futex_compat.c +2 -0
@@ -142,6 +142,8 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;
Signature · 1 line
1.7.0.4
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.
Has anyone asked the question if the folks working on checkpoint/restart are going to need this.
This seems like important information to know if you want to checkpoint a process.
Eric
Quoted 55 lines
Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
v2:
- add note to feature-removal-schedule.txt.--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-)Documentation/feature-removal-schedule.txt +10
-0@@ -543,3 +543,13 @@ When: 3.5 Why: The old kmap_atomic() with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it. Who: Cong Wang <[email protected]> + +---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed. +Who: Kees Cook <[email protected]>kernel/futex.c +2
-0@@ -2449,6 +2449,8 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;kernel/futex_compat.c +2
-0@@ -142,6 +142,8 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 9 lines · Eric W. Biederman
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Has anyone asked the question if the folks working on checkpoint/restart are going to need this.
This seems like important information to know if you want to checkpoint a process.
Hm, that might be true. But, I guess that's why it's lucky it's a separate patch. :) The first patch is still desirable, IMO.
-Kees
Signature · 2 lines
Kees Cook ChromeOS Security
Re: [PATCH v2] futex: mark get_robust_list as deprecated
In reply to Eric W. BiedermanQuoted 9 lines · Eric W. Biederman
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Has anyone asked the question if the folks working on checkpoint/restart are going to need this.
This seems like important information to know if you want to checkpoint a process.
I have no idea if the CRIU and DMTCP folks care about this. I've added some folks related to those projects to the Cc list.
Quoted 23 lines
Eric
Quoted 20 lines
Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
v2:
- add note to feature-removal-schedule.txt.--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-)Documentation/feature-removal-schedule.txt +1
-0@@ -543,3 +543,13 @@ When: 3.5 Why: The old kmap_atomic() with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it. Who: Cong Wang <[email protected]> +
Quoted 8 lines
Documentation/feature-removal-schedule.txt When: 3.5 · line 554
Quoted 8 lines
Documentation/feature-removal-schedule.txt +8
-0+---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed.
So I've looked in glibc, gdb, and DMTCP. The description of the intended use of get_robust_list() is accurate. However the benefit of ASLR is less clear when it comes to the robust list. In glibc the robust list is only used from NPTL. The robust list head is in struct pthread which can be obtained from pthread_self() anyway. Thus I think ASLR doesn't really help obfuscate the robust futex list unless the program is using robust futexes without the aid of glibc.
Cheers,
-Matt Helsley
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 5 lines · Matt Helsley
Quoted 4 lines · Eric W. Biederman
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.
Quoted 8 lines
Quoted 5 lines
Has anyone asked the question if the folks working on checkpoint/restart are going to need this.
This seems like important information to know if you want to checkpoint a process.
I have no idea if the CRIU and DMTCP folks care about this. I've added some folks related to those projects to the Cc list.
Nope, we don't need this syscall, thanks for notifying!
Quoted 45 lines
Quoted 23 lines
Eric
Quoted 20 lines
Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
v2:
- add note to feature-removal-schedule.txt.--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-)Documentation/feature-removal-schedule.txt +1
-0@@ -543,3 +543,13 @@ When: 3.5 Why: The old kmap_atomic() with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it. Who: Cong Wang <[email protected]> +Quoted 8 lines
Documentation/feature-removal-schedule.txt When: 3.5 · line 554
Quoted 8 lines
Documentation/feature-removal-schedule.txt +8
-0+---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed.So I've looked in glibc, gdb, and DMTCP. The description of the intended use of
get_robust_list()is accurate. However the benefit of ASLR is less clear when it comes to the robust list. In glibc the robust list is only used from NPTL. The robust list head is in struct pthread which can be obtained frompthread_self()anyway. Thus I think ASLR doesn't really help obfuscate the robust futex list unless the program is using robust futexes without the aid of glibc.Cheers,
-Matt Helsley.
Re: [PATCH v2] futex: mark get_robust_list as deprecated
In reply to Matt HelsleyThanks for including us in the cc, Matt.
We don't need the system call for DMTCP either.
Also, in our DMTCP user base, we haven't had any requests to support checkpointing of user code with get_robust_list(). If a user had needed this or a similar system call, I suspect our new plugin architecture would make it easy to eupport. But it's a non-issue now.
Thanks,
- Gene
Quoted 57 lines · Matt Helsley
Quoted 9 lines · Eric W. Biederman
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Has anyone asked the question if the folks working on checkpoint/restart are going to need this.
This seems like important information to know if you want to checkpoint a process.
I have no idea if the CRIU and DMTCP folks care about this. I've added some folks related to those projects to the Cc list.
Quoted 23 lines
Eric
Quoted 20 lines
Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
v2:
- add note to feature-removal-schedule.txt.--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-)Documentation/feature-removal-schedule.txt +1
-0@@ -543,3 +543,13 @@ When: 3.5 Why: The old kmap_atomic() with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it. Who: Cong Wang <[email protected]> +Quoted 8 lines
Documentation/feature-removal-schedule.txt When: 3.5 · line 554
Quoted 8 lines
Documentation/feature-removal-schedule.txt +8
-0+---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed.So I've looked in glibc, gdb, and DMTCP. The description of the intended use of
get_robust_list()is accurate. However the benefit of ASLR is less clear when it comes to the robust list. In glibc the robust list is only used from NPTL. The robust list head is in struct pthread which can be obtained frompthread_self()anyway. Thus I think ASLR doesn't really help obfuscate the robust futex list unless the program is using robust futexes without the aid of glibc.Cheers,
-Matt Helsley
A message that is not in the archive (sent off-list or not yet received): 20120330050544.GA32299-52DBMbEzqgQ/wnmkkaCWp/[email protected]
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Thanks for including us in the cc, Matt.
We don't need the system call for DMTCP either.
Also, in our DMTCP user base, we haven't had any requests to support checkpointing of user code with get_robust_list(). If a user had needed this or a similar system call, I suspect our new plugin architecture would make it easy to eupport. But it's a non-issue now.
Thanks,
- Gene
Quoted 57 lines · Matt Helsley
Quoted 9 lines · Eric W. Biederman
Quoted 1 line · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Has anyone asked the question if the folks working on checkpoint/restart are going to need this.
This seems like important information to know if you want to checkpoint a process.
I have no idea if the CRIU and DMTCP folks care about this. I've added some folks related to those projects to the Cc list.
Quoted 23 lines
Eric
Quoted 20 lines
Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
v2:
- add note to feature-removal-schedule.txt.--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-)Documentation/feature-removal-schedule.txt +1
-0@@ -543,3 +543,13 @@ When: 3.5 Why: The old kmap_atomic() with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it. Who: Cong Wang <[email protected]> +Quoted 8 lines
Documentation/feature-removal-schedule.txt When: 3.5 · line 554
Quoted 8 lines
Documentation/feature-removal-schedule.txt +8
-0+---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed.So I've looked in glibc, gdb, and DMTCP. The description of the intended use of
get_robust_list()is accurate. However the benefit of ASLR is less clear when it comes to the robust list. In glibc the robust list is only used from NPTL. The robust list head is in struct pthread which can be obtained frompthread_self()anyway. Thus I think ASLR doesn't really help obfuscate the robust futex list unless the program is using robust futexes without the aid of glibc.Cheers,
-Matt Helsley
Re: [PATCH v2] futex: mark get_robust_list as deprecated
In reply to Kees CookQuoted 36 lines · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
v2:
- add note to feature-removal-schedule.txt.
---
Documentation/feature-removal-schedule.txt | 10 ++++++++++kernel/futex.c| 2 ++kernel/futex_compat.c| 2 ++3 files changed, 14 insertions(+), 0 deletions(-)Documentation/feature-removal-schedule.txt +0
-0@@ -543,3 +543,13 @@ When: 3.5Why: The old
kmap_atomic()with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it.
Who: Cong Wang <[email protected]>Documentation/feature-removal-schedule.txt +10
-0+ +---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed. +Who: Kees Cook <[email protected]>kernel/futex.c +0
-0
kernel/futex.c SYSCALL_DEFINE3(get_robust_list, int, pid, · line 2453
Quoted 5 lines
kernel/futex.c +2
-0@@ -2449,6 +2449,8 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, if (!futex_cmpxchg_enabled) return -ENOSYS; + WARN_ONCE(1, "deprecated: get_robust_list will be deleted in 2013.\n"); +
Do you really need WARN_ONCE? It's going to spew a backtrace if this is called, and that is going to cause various auto-bug reporters to file bugs as well. There's nothing that can be done with those bugs other than to wait until this is removed. Maybe it won't trigger because nobody is using it, but ugh.
Is printk_once sufficient?
josh
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 4 lines · Josh Boyer
Do you really need
WARN_ONCE? It's going to spew a backtrace if this is called, and that is going to cause various auto-bug reporters to file bugs as well.
That's a positive, right? That gives extra visibility to who and what might possibly use this thing.
[tip:core/locking] futex: Mark get_robust_list as deprecated
In reply to Kees CookCommit-ID: ec0c4274e33c0373e476b73e01995c53128f1257 Gitweb: http://git.kernel.org/tip/ec0c4274e33c0373e476b73e01995c53128f1257 Author: Kees Cook <[email protected]> AuthorDate: Fri, 23 Mar 2012 12:08:55 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200
futex: Mark get_robust_list as deprecated
Notify get_robust_list users that the syscall is going away.
--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ kernel/futex.c | 2 ++ kernel/futex_compat.c | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-)
Documentation/feature-removal-schedule.txt +10 -0
@@ -529,3 +529,13 @@ When: 3.5 Why: The old kmap_atomic() with two arguments is deprecated, we only keep it for backward compatibility for few cycles and then drop it. Who: Cong Wang <[email protected]> + +---------------------------- + +What: get_robust_list syscall +When: 2013 +Why: There appear to be no production users of the get_robust_list syscall, + and it runs the risk of leaking address locations, allowing the bypass + of ASLR. It was only ever intended for debugging, so it should be + removed. +Who: Kees Cook <[email protected]>
kernel/futex.c +2 -0
@@ -2449,6 +2449,8 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;
kernel/futex_compat.c +2 -0
@@ -142,6 +142,8 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,if (!futex_cmpxchg_enabled)return -ENOSYS ; +WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); +rcu_read_lock (); ret = -ESRCH ;
Re: [PATCH v2] futex: mark get_robust_list as deprecated
In reply to Kees CookQuoted 5 lines · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
I'm using this system call in an application and noticed that's marked as deprecated now.
My application collects all kind of information from crashing programs. It's installed in /proc/sys/kernel/core_pattern.
If program X is crashing it executes get_robust_list(X) to get the address of the robust list
and reads the list from /proc/X/mem.
Is there another way to get the robust list from another program (by it's pid)?
Signature · 2 lines
Thanks, //richard
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 12 lines · richard -rw- weinberger
Quoted 5 lines · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
I'm using this system call in an application and noticed that's marked as deprecated now.
My application collects all kind of information from crashing programs. It's installed in/proc/sys/kernel/core_pattern.
Quoted 5 lines
If program X is crashing it executes
get_robust_list(X)to get the address of the robust list
and reads the list from/proc/X/mem.Is there another way to get the robust list from another program (by it's pid)?
The folks doing checkpoint/restart claim to not need this, so there might be a way either that or they just haven't hit this problem yet.
What you are doing sounds like a reasonable use of get_robust_list to me.
Eric
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 18 lines · Eric W. Biederman
Quoted 16 lines · richard -rw- weinberger
Quoted 5 lines · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
I'm using this system call in an application and noticed that's marked as deprecated now.
My application collects all kind of information from crashing programs. It's installed in/proc/sys/kernel/core_pattern.If program X is crashing it executes
get_robust_list(X)to get the address of the robust list
and reads the list from/proc/X/mem.
Quoted 7 lines
Quoted 1 line
Is there another way to get the robust list from another program (by it's pid)?
The folks doing checkpoint/restart claim to not need this, so there might be a way either that or they just haven't hit this problem yet.
What you are doing sounds like a reasonable use of
get_robust_listto me.
CRIU folks, how do you deal with futex robust lists?
Signature · 2 lines
Thanks, //richard
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 21 lines · richard -rw- weinberger
Quoted 20 lines · Eric W. Biederman
Quoted 17 lines · richard -rw- weinberger
Quoted 5 lines · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
I'm using this system call in an application and noticed that's marked as deprecated now.
My application collects all kind of information from crashing programs. It's installed in/proc/sys/kernel/core_pattern.If program X is crashing it executes
get_robust_list(X)to get the address of the robust list
and reads the list from/proc/X/mem.Is there another way to get the robust list from another program (by it's pid)?
Quoted 7 lines
Quoted 5 lines
The folks doing checkpoint/restart claim to not need this, so there might be a way either that or they just haven't hit this problem yet.
What you are doing sounds like a reasonable use of
get_robust_listto me.CRIU folks, how do you deal with futex robust lists?
Well, I believe we were over-optimistic in claiming that we don't need this syscall (to be fair I think we simply yet not faced the problem Eric points). So we need some way to fetch this address and set it back. If get_robust_list get deprecated maybe we could print it out in /proc/pid/stat or something?
Cyrill
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 17 lines · Cyrill Gorcunov
Quoted 17 lines
Quoted 16 lines
Quoted 10 lines
I'm using this system call in an application and noticed that's marked as deprecated now.
My application collects all kind of information from crashing programs. It's installed in/proc/sys/kernel/core_pattern.If program X is crashing it executes
get_robust_list(X)to get the address of the robust list
and reads the list from/proc/X/mem.Is there another way to get the robust list from another program (by it's pid)?
The folks doing checkpoint/restart claim to not need this, so there might be a way either that or they just haven't hit this problem yet.
What you are doing sounds like a reasonable use of
get_robust_listto me.
Quoted 6 lines
Quoted 1 line
CRIU folks, how do you deal with futex robust lists?
Well, I believe we were over-optimistic in claiming that we don't need this syscall (to be fair I think we simply yet not faced the problem Eric points). So we need some way to fetch this address and set it back. If
get_robust_listget deprecated maybe we could print it out in/proc/pid/stator something?
Kees, you said get_robust_list() can be used to bypass ASLR. How? What makes it worse than /proc/pid/maps?
If the robust list address itself is bad, removing get_robust_list() and putting the
information into /proc is useless.
Signature · 2 lines
Thanks, //richard
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 8 lines · richard -rw- weinberger
Quoted 7 lines
Quoted 2 lines
CRIU folks, how do you deal with futex robust lists?
Well, I believe we were over-optimistic in claiming that we don't need this syscall (to be fair I think we simply yet not faced the problem Eric points). So we need some way to fetch this address and set it back. If
get_robust_listget deprecated maybe we could print it out in/proc/pid/stator something?
Quoted 5 lines
Kees, you said
get_robust_list()can be used to bypass ASLR. How? What makes it worse than/proc/pid/maps?If the robust list address itself is bad, removing
get_robust_list()and putting the information into /proc is useless.
Look, the /proc entry might check for some CAP and do not allow a regular user to fetch this address.
Cyrill
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 9 lines · Cyrill Gorcunov
Quoted 8 lines · richard -rw- weinberger
Quoted 7 lines
Quoted 2 lines
CRIU folks, how do you deal with futex robust lists?
Well, I believe we were over-optimistic in claiming that we don't need this syscall (to be fair I think we simply yet not faced the problem Eric points). So we need some way to fetch this address and set it back. If
get_robust_listget deprecated maybe we could print it out in/proc/pid/stator something?
Quoted 8 lines
Quoted 5 lines
Kees, you said
get_robust_list()can be used to bypass ASLR. How? What makes it worse than/proc/pid/maps?If the robust list address itself is bad, removing
get_robust_list()and putting the information into /proc is useless.Look, the /proc entry might check for some CAP and do not allow a regular user to fetch this address.
We could also add another check to get_robust_list(). It does already ptrace_may_access().
Signature · 2 lines
Thanks, //richard
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 13 lines · richard -rw- weinberger
Quoted 12 lines · Cyrill Gorcunov
Quoted 11 lines · richard -rw- weinberger
Quoted 7 lines
Quoted 2 lines
CRIU folks, how do you deal with futex robust lists?
Well, I believe we were over-optimistic in claiming that we don't need this syscall (to be fair I think we simply yet not faced the problem Eric points). So we need some way to fetch this address and set it back. If
get_robust_listget deprecated maybe we could print it out in/proc/pid/stator something?Kees, you said
get_robust_list()can be used to bypass ASLR. How? What makes it worse than/proc/pid/maps?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If the robust list address itself is bad, removing
get_robust_list()and putting the information into /proc is useless.Look, the /proc entry might check for some CAP and do not allow a regular user to fetch this address.
We could also add another check to
get_robust_list(). It does alreadyptrace_may_access().
Yes, and I'm definitely not against that ;) The problem is that this syscall was marked as deprecated and if people want to drop it we need to find a way to provide this address back in a sake of c/r.
If c/r is the only _one_ who needs this facility than providing the address via /proc might be worth thing to do (since I can wrap it with CONFIG_CHECKPOINT_RESTORE and a regular kernel won't see this snippet at all).
Cyrill
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 23 lines · Cyrill Gorcunov
Quoted 13 lines · richard -rw- weinberger
Quoted 12 lines · Cyrill Gorcunov
Quoted 11 lines · richard -rw- weinberger
Quoted 7 lines
Quoted 2 lines
CRIU folks, how do you deal with futex robust lists?
Well, I believe we were over-optimistic in claiming that we don't need this syscall (to be fair I think we simply yet not faced the problem Eric points). So we need some way to fetch this address and set it back. If
get_robust_listget deprecated maybe we could print it out in/proc/pid/stator something?Kees, you said
get_robust_list()can be used to bypass ASLR. How? What makes it worse than/proc/pid/maps?Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If the robust list address itself is bad, removing
get_robust_list()and putting the information into /proc is useless.Look, the /proc entry might check for some CAP and do not allow a regular user to fetch this address.
We could also add another check to
get_robust_list(). It does alreadyptrace_may_access().
Quoted 8 lines
Yes, and I'm definitely not against that ;) The problem is that this syscall was marked as deprecated and if people want to drop it we need to find a way to provide this address back in a sake of c/r.
If c/r is the only _one_ who needs this facility than providing the address via /proc might be worth thing to do (since I can wrap it with
CONFIG_CHECKPOINT_RESTOREand a regular kernel won't see this snippet at all).
Please see my first mail above.
c/r is not the only user. :-P
Signature · 2 lines
Thanks, //richard
Re: [PATCH v2] futex: mark get_robust_list as deprecated
In reply to Cyrill GorcunovQuoted 28 lines · Cyrill Gorcunov
Quoted 27 lines · richard -rw- weinberger
Quoted 25 lines · Eric W. Biederman
Quoted 12 lines · richard -rw- weinberger
Quoted 5 lines · Kees Cook
Notify
get_robust_listusers that the syscall is going away.Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Kees Cook <[email protected]>---
I'm using this system call in an application and noticed that's marked as deprecated now.
My application collects all kind of information from crashing programs. It's installed in/proc/sys/kernel/core_pattern.Quoted 5 lines
If program X is crashing it executes
get_robust_list(X)to get the address of the robust list
and reads the list from/proc/X/mem.Is there another way to get the robust list from another program (by it's pid)?
The folks doing checkpoint/restart claim to not need this, so there might be a way either that or they just haven't hit this problem yet.
What you are doing sounds like a reasonable use of
get_robust_listto me.
Quoted 6 lines
Quoted 1 line
CRIU folks, how do you deal with futex robust lists?
Well, I believe we were over-optimistic in claiming that we don't need this syscall (to be fair I think we simply yet not faced the problem Eric points). So we need some way to fetch this address and set it back. If
get_robust_listget deprecated maybe we could print it out in/proc/pid/stator something?
I agree with Cyrill, sorry for the confusion last time. We do need some way to get the list location. The exact API is not critical, we can work with either of the mentioned above.
Quoted 3 lines
Cyrill
.
Re: [PATCH v2] futex: mark get_robust_list as deprecated
The permissions on the syscall were fixed them withR ptrace_may_access.
We have identified two legitimate use cases.
It looks like it is time for someone to generate the path to remove the depreciation.
Who is up for writing and testing that patch?
Eric
Re: [PATCH v2] futex: mark get_robust_list as deprecated
Quoted 7 lines · Eric W. Biederman
The permissions on the syscall were fixed them withR
ptrace_may_access.We have identified two legitimate use cases.
It looks like it is time for someone to generate the path to remove the depreciation.
Who is up for writing and testing that patch?
I'll send a patch.
Signature · 2 lines
Thanks, //richard
Re: [PATCH v2] futex: mark get_robust_list as deprecated
In reply to Eric W. BiedermanRight, I'm satisfied with the ptrace_may_access check that was added. The deprecation was suggested as an additional change. I'm okay keeping the syscall if someone actually needs it. :)
-Kees
Quoted 10 lines · Eric W. Biederman
The permissions on the syscall were fixed them withR
ptrace_may_access.We have identified two legitimate use cases.
It looks like it is time for someone to generate the path to remove the depreciation.
Who is up for writing and testing that patch?
Eric
Signature · 2 lines
Kees Cook Chrome OS Security
PATCH 1/1 Revert "futex: Mark get_robust_list as deprecated"
get_robust_list has at least two valid use cases.
1. checkpoint/restore in userspace
2. post mortem analysis
--- Documentation/feature-removal-schedule.txt | 10 ---------- kernel/futex.c | 2 -- kernel/futex_compat.c | 2 -- 3 files changed, 14 deletions(-)
Documentation/feature-removal-schedule.txt +0 -10
@@ -506,16 +506,6 @@ Who: Sebastian Andrzej Siewior <[email protected]> ---------------------------- -What: get_robust_list syscall -When: 2013 -Why: There appear to be no production users of the get_robust_list syscall, - and it runs the risk of leaking address locations, allowing the bypass - of ASLR. It was only ever intended for debugging, so it should be - removed. -Who: Kees Cook <[email protected]> - ----------------------------- - What: Removing the pn544 raw driver. When: 3.6 Why: With the introduction of the NFC HCI and SHDL kernel layers, pn544.c
kernel/futex.c +0 -2
@@ -2449,8 +2449,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,if (!futex_cmpxchg_enabled)return -ENOSYS ; -WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); -rcu_read_lock (); ret = -ESRCH ;
kernel/futex_compat.c +0 -2
@@ -142,8 +142,6 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,if (!futex_cmpxchg_enabled)return -ENOSYS ; -WARN_ONCE (1 ,"deprecated: get_robust_list will be deleted in 2013.\n" ); -rcu_read_lock (); ret = -ESRCH ;
Signature · 1 line
1.7.10.4
Quoted 22 lines · Thomas Gleixner
Quoted 12 lines · Ingo Molnar
Quoted 11 lines · Kees Cook
Quoted 1 line · Thomas Gleixner
I really wonder why we have this syscall at all.
The documentation I found yesterday while looking at this was:
http://linux.die.net/man/2/get_robust_listWhich says "The system call is only available for debugging purposes and is not needed for normal operations. Both system calls are not available to application programs as functions; they can be called using the syscall(3) function."
Quoted 8 lines
Quoted 2 lines
Dropping the syscall entirely would certainly make it secure. ;)
The thinking was API completeness. In general it's possible for a sufficiently privileged task to figure out all the state of a task. We can query timers, fds - the robust list is such a resource as well. The information leakage was obviously not intended.
Quoted 3 lines
So I think it's safe to take Kees' patch as is. On top of that we should add a
WARN_ONCEwhen the syscall is invoked and schedule the sucker for removal.
Can someone claim the first patch? It looks like not everyone agrees about removal, but I'd like to see at least the first one get in. :)
-Kees
Signature · 2 lines
Kees Cook ChromeOS Security
Quoted 23 lines · Kees Cook
Quoted 22 lines · Thomas Gleixner
Quoted 20 lines · Ingo Molnar
Quoted 6 lines · Kees Cook
Quoted 1 line · Thomas Gleixner
I really wonder why we have this syscall at all.
The documentation I found yesterday while looking at this was:
http://linux.die.net/man/2/get_robust_listQuoted 7 lines
Which says "The system call is only available for debugging purposes and is not needed for normal operations. Both system calls are not available to application programs as functions; they can be called using the syscall(3) function."
Dropping the syscall entirely would certainly make it secure. ;)
The thinking was API completeness. In general it's possible for a sufficiently privileged task to figure out all the state of a task. We can query timers, fds - the robust list is such a resource as well. The information leakage was obviously not intended.
Quoted 6 lines
Quoted 3 lines
So I think it's safe to take Kees' patch as is. On top of that we should add a
WARN_ONCEwhen the syscall is invoked and schedule the sucker for removal.Can someone claim the first patch? It looks like not everyone agrees about removal, but I'd like to see at least the first one get in. :)
It's on my list for tomorrow.
[tip:core/locking] futex: Do not leak robust list to unprivileged process
In reply to Kees CookCommit-ID: bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Gitweb: http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Author: Kees Cook <[email protected]> AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200
futex: Do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.
Running a setuid program that uses robust futexes would have had:
cred->euid != pcred->euid
cred->euid == pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.
(This patch is based on changes from grsecurity.)
--- kernel/futex.c | 36 +++++++++++++----------------------- kernel/futex_compat.c | 36 +++++++++++++----------------------- 2 files changed, 26 insertions(+), 46 deletions(-)
kernel/futex.c +13 -23
@@ -59,6 +59,7 @@#include <linux/magic.h> #include <linux/pid.h> #include <linux/nsproxy.h> +#include <linux/ptrace.h> #include <asm/futex.h>
@@ -2443,40 +2444,29 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, {struct robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (head, head_ptr);
kernel/futex_compat.c +13 -23
@@ -10,6 +10,7 @@#include <linux/compat.h> #include <linux/nsproxy.h> #include <linux/futex.h> +#include <linux/ptrace.h> #include <asm/uaccess.h>
@@ -136,40 +137,29 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, {struct compat_robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->compat_robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->compat_robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->compat_robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (ptr_to_compat (head), head_ptr);
Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoted 14 lines · tip-bot for Kees Cook
Commit-ID: bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Gitweb: http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Author: Kees Cook <[email protected]> AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200futex: Do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.
Quoted 6 lines
Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.
I'm not sure this change prevents the unprivileged process. Please refer to LTP test, recently I saw that this change broke the following test.
if (seteuid(1) == -1) tst_brkm(TBROK|TERRNO, cleanup, "seteuid(1) failed"); TEST(retval = syscall(__NR_get_robust_list, 1, (struct robust_list_head *)&head, &len_ptr));
We set the euid to an unprivileged user, and expect to FAIL with EPERM, without this patch, it FAIL as we expected, but with it, this call succeed.
Seems that we leaked the check of (cred->euid == pcred->euid && cred->euid == pcred->uid), I'm not sure which one is right, can you please give an explanation?
Thanks in advance,
Wanlong Gao
Quoted 154 lines
(This patch is based on changes from grsecurity.)
Signed-off-by Kees Cook <[email protected]>Cc Darren Hart <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Jiri Kosina <[email protected]>Cc Eric W. Biederman <[email protected]>Cc David Howells <[email protected]>Cc Serge E. Hallyn <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>--- kernel/futex.c | 36 +++++++++++++----------------------- kernel/futex_compat.c | 36 +++++++++++++----------------------- 2 files changed, 26 insertions(+), 46 deletions(-)kernel/futex.c +13
-23@@ -59,6 +59,7 @@#include <linux/magic.h> #include <linux/pid.h> #include <linux/nsproxy.h> +#include <linux/ptrace.h> #include <asm/futex.h> @@ -2443,40 +2444,29 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, {struct robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (head, head_ptr);kernel/futex_compat.c +13
-24@@ -10,6 +10,7 @@#include <linux/compat.h> #include <linux/nsproxy.h> #include <linux/futex.h> +#include <linux/ptrace.h> #include <asm/uaccess.h> @@ -136,40 +137,29 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, {struct compat_robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->compat_robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->compat_robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->compat_robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (ptr_to_compat (head), head_ptr); --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoted 34 lines · Wanlong Gao
Quoted 14 lines · tip-bot for Kees Cook
Commit-ID: bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Gitweb: http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Author: Kees Cook <[email protected]> AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200futex: Do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Quoted 6 lines
Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.I'm not sure this change prevents the unprivileged process. Please refer to LTP test, recently I saw that this change broke the following test.
if (seteuid(1) == -1) tst_brkm(TBROK|TERRNO, cleanup, "seteuid(1) failed"); TEST(retval = syscall(__NR_get_robust_list, 1, (struct robust_list_head *)&head, &len_ptr));
Quoted 2 lines
We set the euid to an unprivileged user, and expect to FAIL with EPERM, without this patch, it FAIL as we expected, but with it, this call succeed.
This relates to a question I asked - I believe in this thread, maybe in another thread - about ptrace_may_access. That code goes back further than our git history, and for so long has used current->uid and ->gid, not euid and gid, for permission checks. I asked if that's what we really want, but at the same am not sure we want to change something that's been like that for so long.
But that's why it succeeded - you changed your euid, not your uid.
Quoted 163 lines
Seems that we leaked the check of (
cred->euid==pcred->euid&&cred->euid==pcred->uid), I'm not sure which one is right, can you please give an explanation?Thanks in advance,
Wanlong GaoQuoted 154 lines
(This patch is based on changes from grsecurity.)
Signed-off-by Kees Cook <[email protected]>Cc Darren Hart <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Jiri Kosina <[email protected]>Cc Eric W. Biederman <[email protected]>Cc David Howells <[email protected]>Cc Serge E. Hallyn <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>--- kernel/futex.c | 36 +++++++++++++----------------------- kernel/futex_compat.c | 36 +++++++++++++----------------------- 2 files changed, 26 insertions(+), 46 deletions(-)kernel/futex.c +13
-23@@ -59,6 +59,7 @@#include <linux/magic.h> #include <linux/pid.h> #include <linux/nsproxy.h> +#include <linux/ptrace.h> #include <asm/futex.h> @@ -2443,40 +2444,29 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, {struct robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (head, head_ptr);kernel/futex_compat.c +13
-24@@ -10,6 +10,7 @@#include <linux/compat.h> #include <linux/nsproxy.h> #include <linux/futex.h> +#include <linux/ptrace.h> #include <asm/uaccess.h> @@ -136,40 +137,29 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, {struct compat_robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->compat_robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->compat_robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->compat_robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (ptr_to_compat (head), head_ptr); --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoted 38 lines · Serge Hallyn
Quoted 34 lines · Wanlong Gao
Quoted 14 lines · tip-bot for Kees Cook
Commit-ID: bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Gitweb: http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Author: Kees Cook <[email protected]> AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200futex: Do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Quoted 6 lines
Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.I'm not sure this change prevents the unprivileged process. Please refer to LTP test, recently I saw that this change broke the following test.
if (seteuid(1) == -1) tst_brkm(TBROK|TERRNO, cleanup, "seteuid(1) failed"); TEST(retval = syscall(__NR_get_robust_list, 1, (struct robust_list_head *)&head, &len_ptr));Quoted 2 lines
We set the euid to an unprivileged user, and expect to FAIL with EPERM, without this patch, it FAIL as we expected, but with it, this call succeed.
Quoted 8 lines
This relates to a question I asked - I believe in this thread, maybe in another thread - about
ptrace_may_access. That code goes back further than our git history, and for so long has usedcurrent->uidand ->gid, not euid and gid, for permission checks. I asked if that's what we really want, but at the same am not sure we want to change something that's been like that for so long.But that's why it succeeded - you changed your euid, not your uid.
Yeah, I known what I'm doing. I just wonder which is the right thing. Should we check euid or uid ? You mean that checking uid instead of checking euid for a long time, right?
Thanks,
Wanlong Gao
Quoted 165 lines
Quoted 164 lines
Seems that we leaked the check of (
cred->euid==pcred->euid&&cred->euid==pcred->uid), I'm not sure which one is right, can you please give an explanation?Thanks in advance,
Wanlong GaoQuoted 154 lines
(This patch is based on changes from grsecurity.)
Signed-off-by Kees Cook <[email protected]>Cc Darren Hart <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Jiri Kosina <[email protected]>Cc Eric W. Biederman <[email protected]>Cc David Howells <[email protected]>Cc Serge E. Hallyn <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>--- kernel/futex.c | 36 +++++++++++++----------------------- kernel/futex_compat.c | 36 +++++++++++++----------------------- 2 files changed, 26 insertions(+), 46 deletions(-)kernel/futex.c +13
-23@@ -59,6 +59,7 @@#include <linux/magic.h> #include <linux/pid.h> #include <linux/nsproxy.h> +#include <linux/ptrace.h> #include <asm/futex.h> @@ -2443,40 +2444,29 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, {struct robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (head, head_ptr);kernel/futex_compat.c +13
-24@@ -10,6 +10,7 @@#include <linux/compat.h> #include <linux/nsproxy.h> #include <linux/futex.h> +#include <linux/ptrace.h> #include <asm/uaccess.h> @@ -136,40 +137,29 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, {struct compat_robust_list_head __user *head;unsigned long ret; -const struct cred *cred =current_cred (), *pcred; +struct task_struct *p;if (!futex_cmpxchg_enabled)return -ENOSYS ; +rcu_read_lock (); + + ret = -ESRCH ;if (!pid) - head = current->compat_robust_list; + p = current;else { -struct task_struct *p; - - ret = -ESRCH ; -rcu_read_lock (); p =find_task_by_vpid (pid);if (!p) goto err_unlock; - ret = -EPERM ; - pcred =__task_cred (p); -/* If victim is in different user_ns, then uids are not -comparable, so we must have CAP_SYS_PTRACE */ -if (cred->user->user_ns != pcred->user->user_ns) { -if (!ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; - goto ok; - } -/* If victim is in same user_ns, then uids are comparable */ -if (cred->euid != pcred->euid && - cred->euid != pcred->uid && - !ns_capable (pcred->user->user_ns,CAP_SYS_PTRACE )) - goto err_unlock; -ok: - head = p->compat_robust_list; -rcu_read_unlock (); } + ret = -EPERM ; +if (!ptrace_may_access (p,PTRACE_MODE_READ )) + goto err_unlock; + + head = p->compat_robust_list; +rcu_read_unlock (); +if (put_user (sizeof (*head), len_ptr))return -EFAULT ;return put_user (ptr_to_compat (head), head_ptr); --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoted 46 lines · Wanlong Gao
Quoted 45 lines · Serge Hallyn
Quoted 34 lines · Wanlong Gao
Quoted 14 lines · tip-bot for Kees Cook
Commit-ID: bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Gitweb: http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Author: Kees Cook <[email protected]> AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200futex: Do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Quoted 6 lines
Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.I'm not sure this change prevents the unprivileged process. Please refer to LTP test, recently I saw that this change broke the following test.
if (seteuid(1) == -1) tst_brkm(TBROK|TERRNO, cleanup, "seteuid(1) failed"); TEST(retval = syscall(__NR_get_robust_list, 1, (struct robust_list_head *)&head, &len_ptr));Quoted 2 lines
We set the euid to an unprivileged user, and expect to FAIL with EPERM, without this patch, it FAIL as we expected, but with it, this call succeed.
This relates to a question I asked - I believe in this thread, maybe in another thread - about
ptrace_may_access. That code goes back further than our git history, and for so long has usedcurrent->uidand ->gid, not euid and gid, for permission checks. I asked if that's what we really want, but at the same am not sure we want to change something that's been like that for so long.
Quoted 3 lines
Quoted 1 line
But that's why it succeeded - you changed your euid, not your uid.
Yeah, I known what I'm doing.
Didn't mean to offend :)
Quoted 3 lines
I just wonder which is the right thing.
Should we check euid or uid ? You mean that checking uid instead of checking euid for a long time, right?
Yup, and I agree it seems wrong.
-serge
Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoted 47 lines · Serge Hallyn
Quoted 46 lines · Wanlong Gao
Quoted 45 lines · Serge Hallyn
Quoted 34 lines · Wanlong Gao
Quoted 14 lines · tip-bot for Kees Cook
Commit-ID: bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Gitweb: http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Author: Kees Cook <[email protected]> AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200futex: Do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Quoted 6 lines
Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.I'm not sure this change prevents the unprivileged process. Please refer to LTP test, recently I saw that this change broke the following test.
if (seteuid(1) == -1) tst_brkm(TBROK|TERRNO, cleanup, "seteuid(1) failed"); TEST(retval = syscall(__NR_get_robust_list, 1, (struct robust_list_head *)&head, &len_ptr));Quoted 2 lines
We set the euid to an unprivileged user, and expect to FAIL with EPERM, without this patch, it FAIL as we expected, but with it, this call succeed.
This relates to a question I asked - I believe in this thread, maybe in another thread - about
ptrace_may_access. That code goes back further than our git history, and for so long has usedcurrent->uidand ->gid, not euid and gid, for permission checks. I asked if that's what we really want, but at the same am not sure we want to change something that's been like that for so long.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
But that's why it succeeded - you changed your euid, not your uid.
Yeah, I known what I'm doing.
Didn't mean to offend :)
Sorry for my poor words, I didn't mean that, either. ;)
Quoted 6 lines
Quoted 4 lines
I just wonder which is the right thing.
Should we check euid or uid ? You mean that checking uid instead of checking euid for a long time, right?Yup, and I agree it seems wrong.
Are there any other places where also switch checking uid instead of euid ? In this place, anyway, this syscall is already marked as deprecated.
Thanks,
Wanlong Gao
Quoted 3 lines
-serge
Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoted 57 lines · Wanlong Gao
Quoted 47 lines · Serge Hallyn
Quoted 46 lines · Wanlong Gao
Quoted 45 lines · Serge Hallyn
Quoted 34 lines · Wanlong Gao
Quoted 14 lines · tip-bot for Kees Cook
Commit-ID: bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Gitweb: http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8 Author: Kees Cook <[email protected]> AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 29 Mar 2012 11:37:17 +0200futex: Do not leak robust list to unprivileged process
It was possible to extract the robust list head address from a setuid process if it had used
set_robust_list(), allowing an ASLR info leak. This changes the permission checks to be the same as those used for similar info that comes out of /proc.Quoted 6 lines
Running a setuid program that uses robust futexes would have had:
cred->euid!=pcred->euid
cred->euid==pcred->uid
so the old permissions check would allow it. I'm not aware of any setuid programs that use robust futexes, so this is just a preventative measure.I'm not sure this change prevents the unprivileged process. Please refer to LTP test, recently I saw that this change broke the following test.
if (seteuid(1) == -1) tst_brkm(TBROK|TERRNO, cleanup, "seteuid(1) failed"); TEST(retval = syscall(__NR_get_robust_list, 1, (struct robust_list_head *)&head, &len_ptr));Quoted 2 lines
We set the euid to an unprivileged user, and expect to FAIL with EPERM, without this patch, it FAIL as we expected, but with it, this call succeed.
This relates to a question I asked - I believe in this thread, maybe in another thread - about
ptrace_may_access. That code goes back further than our git history, and for so long has usedcurrent->uidand ->gid, not euid and gid, for permission checks. I asked if that's what we really want, but at the same am not sure we want to change something that's been like that for so long.Quoted 5 lines
Quoted 3 lines
Quoted 1 line
But that's why it succeeded - you changed your euid, not your uid.
Yeah, I known what I'm doing.
Didn't mean to offend :)
Sorry for my poor words, I didn't mean that, either. ;)
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I just wonder which is the right thing.
Should we check euid or uid ? You mean that checking uid instead of checking euid for a long time, right?Yup, and I agree it seems wrong.
Are there any other places where also switch checking uid instead of euid ? In this place, anyway, this syscall is already marked as deprecated.
This isn't just this syscall, though, it's ptrace_may_access() which is used in quite a few places (20 at quick glance).
-serge