Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
futex: do not leak robust list to unprivileged process
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 40 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kees Cook  
View profile  
 More options Mar 19 2012, 7:40 pm
Newsgroups: linux.kernel
From: Kees Cook <keesc...@chromium.org>
Date: Tue, 20 Mar 2012 00:40:01 +0100
Local: Mon, Mar 19 2012 7:40 pm
Subject: [PATCH] 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.)

Signed-off-by: Kees Cook <keesc...@chromium.org>
---
 kernel/futex.c        |   36 +++++++++++++-----------------------
 kernel/futex_compat.c |   36 +++++++++++++-----------------------
 2 files changed, 26 insertions(+), 46 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 1614be2..439440d 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -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);
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index 5f9e689..a9642d5 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -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);
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Serge Hallyn  
View profile  
 More options Mar 20 2012, 9:40 am
Newsgroups: linux.kernel
From: Serge Hallyn <serge.hal...@canonical.com>
Date: Tue, 20 Mar 2012 14:40:03 +0100
Local: Tues, Mar 20 2012 9:40 am
Subject: Re: [PATCH] futex: do not leak robust list to unprivileged process
Quoting Kees Cook (keesc...@chromium.org):

> 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 <keesc...@chromium.org>

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)

Acked-by: Serge Hallyn <serge.hal...@canonical.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Gleixner  
View profile  
 More options Mar 20 2012, 1:10 pm
Newsgroups: linux.kernel
From: Thomas Gleixner <t...@linutronix.de>
Date: Tue, 20 Mar 2012 18:10:02 +0100
Local: Tues, Mar 20 2012 1:10 pm
Subject: Re: [PATCH] futex: do not leak robust list to unprivileged process

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kees Cook  
View profile  
 More options Mar 20 2012, 1:20 pm
Newsgroups: linux.kernel
From: Kees Cook <keesc...@chromium.org>
Date: Tue, 20 Mar 2012 18:20:02 +0100
Local: Tues, Mar 20 2012 1:20 pm
Subject: Re: [PATCH] futex: do not leak robust list to unprivileged process

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

--
Kees Cook
ChromeOS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ingo Molnar  
View profile  
 More options Mar 20 2012, 1:30 pm
Newsgroups: linux.kernel
From: Ingo Molnar <mi...@kernel.org>
Date: Tue, 20 Mar 2012 18:30:02 +0100
Local: Tues, Mar 20 2012 1:30 pm
Subject: Re: [PATCH] futex: do not leak robust list to unprivileged process

* Kees Cook <keesc...@chromium.org> wrote:

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Gleixner  
View profile  
 More options Mar 22 2012, 7:50 pm
Newsgroups: linux.kernel
From: Thomas Gleixner <t...@linutronix.de>
Date: Fri, 23 Mar 2012 00:50:02 +0100
Local: Thurs, Mar 22 2012 7:50 pm
Subject: Re: [PATCH] futex: do not leak robust list to unprivileged process

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "futex: mark get_robust_list as deprecated" by Kees Cook
Kees Cook  
View profile  
 More options Mar 23 2012, 2:20 pm
Newsgroups: linux.kernel
From: Kees Cook <keesc...@chromium.org>
Date: Fri, 23 Mar 2012 19:20:02 +0100
Local: Fri, Mar 23 2012 2:20 pm
Subject: [PATCH] futex: mark get_robust_list as deprecated
Notify get_robust_list users that the syscall is going away.

Suggested-by: Thomas Gleixner <t...@linutronix.de>
Signed-off-by: Kees Cook <keesc...@chromium.org>
---
 kernel/futex.c        |    2 ++
 kernel/futex_compat.c |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 439440d..545d7a3 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -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;
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index a9642d5..83e368b 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -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;
--
1.7.0.4

--
Kees Cook
ChromeOS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Gleixner  
View profile  
 More options Mar 23 2012, 2:30 pm
Newsgroups: linux.kernel
From: Thomas Gleixner <t...@linutronix.de>
Date: Fri, 23 Mar 2012 19:30:02 +0100
Local: Fri, Mar 23 2012 2:30 pm
Subject: Re: [PATCH] futex: mark get_robust_list as deprecated

On Fri, 23 Mar 2012, Kees Cook wrote:
> Notify get_robust_list users 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kees Cook  
View profile  
 More options Mar 23 2012, 3:10 pm
Newsgroups: linux.kernel
From: Kees Cook <keesc...@chromium.org>
Date: Fri, 23 Mar 2012 20:10:02 +0100
Local: Fri, Mar 23 2012 3:10 pm
Subject: Re: [PATCH] futex: mark get_robust_list as deprecated

On Fri, Mar 23, 2012 at 11:27 AM, Thomas Gleixner <t...@linutronix.de> wrote:
> On Fri, 23 Mar 2012, Kees Cook wrote:

>> Notify get_robust_list users that the syscall is going away.

> That want's an entry in Documentation/feature-removal-schedule.txt as
> well.

Ah! Yes, I will send a v2.

> That's on top of your previous one, right ?

Yup. :)

-Kees

--
Kees Cook
ChromeOS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kees Cook  
View profile  
 More options Mar 23 2012, 3:30 pm
Newsgroups: linux.kernel
From: Kees Cook <keesc...@chromium.org>
Date: Fri, 23 Mar 2012 20:30:02 +0100
Local: Fri, Mar 23 2012 3:30 pm
Subject: [PATCH v2] futex: mark get_robust_list as deprecated
Notify get_robust_list users that the syscall is going away.

Suggested-by: Thomas Gleixner <t...@linutronix.de>
Signed-off-by: Kees Cook <keesc...@chromium.org>
---
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(-)

diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 4bfd982..e3bf119 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -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 <amw...@redhat.com>
+
+----------------------------
+
+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 <keesc...@chromium.org>
diff --git a/kernel/futex.c b/kernel/futex.c
index d701be5..e2b0fb9 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -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;
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index a9642d5..83e368b 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -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;
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric W. Biederman  
View profile  
 More options Mar 23 2012, 6:10 pm
Newsgroups: linux.kernel
From: ebied...@xmission.com (Eric W. Biederman)
Date: Fri, 23 Mar 2012 23:10:02 +0100
Local: Fri, Mar 23 2012 6:10 pm
Subject: Re: [PATCH v2] futex: mark get_robust_list as deprecated

Kees Cook <keesc...@chromium.org> writes:
> Notify get_robust_list users 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kees Cook  
View profile  
 More options Mar 23 2012, 6:20 pm
Newsgroups: linux.kernel
From: Kees Cook <keesc...@chromium.org>
Date: Fri, 23 Mar 2012 23:20:01 +0100
Local: Fri, Mar 23 2012 6:20 pm
Subject: Re: [PATCH v2] futex: mark get_robust_list as deprecated
On Fri, Mar 23, 2012 at 3:06 PM, Eric W. Biederman

<ebied...@xmission.com> wrote:
> Kees Cook <keesc...@chromium.org> writes:

>> Notify get_robust_list users 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

--
Kees Cook
ChromeOS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Boyer  
View profile  
 More options Mar 27 2012, 2:10 pm
Newsgroups: linux.kernel
From: Josh Boyer <jwbo...@gmail.com>
Date: Tue, 27 Mar 2012 20:10:02 +0200
Local: Tues, Mar 27 2012 2:10 pm
Subject: Re: [PATCH v2] futex: mark get_robust_list as deprecated

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Zijlstra  
View profile  
 More options Mar 27 2012, 3:20 pm
Newsgroups: linux.kernel
From: Peter Zijlstra <a.p.zijls...@chello.nl>
Date: Tue, 27 Mar 2012 21:20:03 +0200
Local: Tues, Mar 27 2012 3:20 pm
Subject: Re: [PATCH v2] futex: mark get_robust_list as deprecated

On Tue, 2012-03-27 at 14:05 -0400, Josh Boyer wrote:

> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "futex: do not leak robust list to unprivileged process" by Kees Cook
Kees Cook  
View profile  
 More options Mar 28 2012, 2:40 pm
Newsgroups: linux.kernel
From: Kees Cook <keesc...@chromium.org>
Date: Wed, 28 Mar 2012 20:40:02 +0200
Local: Wed, Mar 28 2012 2:40 pm
Subject: Re: [PATCH] futex: do not leak robust list to unprivileged process

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

--
Kees Cook
ChromeOS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Gleixner  
View profile  
 More options Mar 28 2012, 5:30 pm
Newsgroups: linux.kernel
From: Thomas Gleixner <t...@linutronix.de>
Date: Wed, 28 Mar 2012 23:30:02 +0200
Local: Wed, Mar 28 2012 5:30 pm
Subject: Re: [PATCH] futex: do not leak robust list to unprivileged process

It's on my list for tomorrow.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "futex: Mark get_robust_list as deprecated" by tip-bot for Kees Cook
tip-bot for Kees Cook  
View profile  
 More options Mar 29 2012, 6:00 am
Newsgroups: linux.kernel
From: tip-bot for Kees Cook <keesc...@chromium.org>
Date: Thu, 29 Mar 2012 12:00:02 +0200
Local: Thurs, Mar 29 2012 6:00 am
Subject: [tip:core/locking] futex: Mark get_robust_list as deprecated
Commit-ID:  ec0c4274e33c0373e476b73e01995c53128f1257
Gitweb:     http://git.kernel.org/tip/ec0c4274e33c0373e476b73e01995c53128f1257
Author:     Kees Cook <keesc...@chromium.org>
AuthorDate: Fri, 23 Mar 2012 12:08:55 -0700
Committer:  Thomas Gleixner <t...@linutronix.de>
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.

Suggested-by: Thomas Gleixner <t...@linutronix.de>
Signed-off-by: Kees Cook <keesc...@chromium.org>
Cc: Randy Dunlap <rdun...@xenotime.net>
Cc: Darren Hart <dvh...@linux.intel.com>
Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
Cc: Jiri Kosina <jkos...@suse.cz>
Cc: Eric W. Biederman <ebied...@xmission.com>
Cc: David Howells <dhowe...@redhat.com>
Cc: Serge E. Hallyn <serge.hal...@canonical.com>
Cc: kernel-harden...@lists.openwall.com
Cc: spen...@grsecurity.net
Link: http://lkml.kernel.org/r/20120323190855.GA27...@www.outflux.net
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
---
 Documentation/feature-removal-schedule.txt |   10 ++++++++++
 kernel/futex.c                             |    2 ++
 kernel/futex_compat.c                      |    2 ++
 3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 0cad480..c1be806 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -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 <amw...@redhat.com>
+
+----------------------------
+
+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 <keesc...@chromium.org>
diff --git a/kernel/futex.c b/kernel/futex.c
index d701be5..e2b0fb9 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -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;
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index a9642d5..83e368b 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "futex: Do not leak robust list to unprivileged process" by tip-bot for Kees Cook
tip-bot for Kees Cook  
View profile  
 More options Mar 29 2012, 6:00 am
Newsgroups: linux.kernel
From: tip-bot for Kees Cook <keesc...@chromium.org>
Date: Thu, 29 Mar 2012 12:00:03 +0200
Local: Thurs, Mar 29 2012 6:00 am
Subject: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Commit-ID:  bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8
Gitweb:     http://git.kernel.org/tip/bdbb776f882f5ad431aa1e694c69c1c3d6a4a5b8
Author:     Kees Cook <keesc...@chromium.org>
AuthorDate: Mon, 19 Mar 2012 16:12:53 -0700
Committer:  Thomas Gleixner <t...@linutronix.de>
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.)

Signed-off-by: Kees Cook <keesc...@chromium.org>
Cc: Darren Hart <dvh...@linux.intel.com>
Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
Cc: Jiri Kosina <jkos...@suse.cz>
Cc: Eric W. Biederman <ebied...@xmission.com>
Cc: David Howells <dhowe...@redhat.com>
Cc: Serge E. Hallyn <serge.hal...@canonical.com>
Cc: kernel-harden...@lists.openwall.com
Cc: spen...@grsecurity.net
Link: http://lkml.kernel.org/r/20120319231253.GA20...@www.outflux.net
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
---
 kernel/futex.c        |   36 +++++++++++++-----------------------
 kernel/futex_compat.c |   36 +++++++++++++-----------------------
 2 files changed, 26 insertions(+), 46 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 72efa1e..d701be5 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -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);
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index 5f9e689..a9642d5 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "futex: mark get_robust_list as deprecated" by Matt Helsley
Matt Helsley  
View profile  
 More options Mar 30 2012, 1:10 am
Newsgroups: linux.kernel
From: Matt Helsley <matth...@us.ibm.com>
Date: Fri, 30 Mar 2012 07:10:02 +0200
Local: Fri, Mar 30 2012 1:10 am
Subject: Re: [PATCH v2] futex: mark get_robust_list as deprecated

On Fri, Mar 23, 2012 at 03:06:02PM -0700, Eric W. Biederman wrote:
> Kees Cook <keesc...@chromium.org> writes:

> > Notify get_robust_list users 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.

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pavel Emelyanov  
View profile  
 More options Mar 30 2012, 2:20 am
Newsgroups: linux.kernel
From: Pavel Emelyanov <xe...@parallels.com>
Date: Fri, 30 Mar 2012 08:20:01 +0200
Local: Fri, Mar 30 2012 2:20 am
Subject: Re: [PATCH v2] futex: mark get_robust_list as deprecated
On 03/30/2012 09:05 AM, Matt Helsley wrote:

> On Fri, Mar 23, 2012 at 03:06:02PM -0700, Eric W. Biederman wrote:
>> Kees Cook <keesc...@chromium.org> writes:

>>> Notify get_robust_list users 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.

Nope, we don't need this syscall, thanks for notifying!

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gene Cooperman  
View profile  
 More options Mar 30 2012, 7:40 pm
Newsgroups: linux.kernel
From: Gene Cooperman <g...@ccs.neu.edu>
Date: Sat, 31 Mar 2012 01:40:01 +0200
Local: Fri, Mar 30 2012 7:40 pm
Subject: 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "futex: Do not leak robust list to unprivileged process" by Wanlong Gao
Wanlong Gao  
View profile  
 More options Jun 18 2012, 9:50 pm
Newsgroups: linux.kernel
From: Wanlong Gao <gaowanl...@cn.fujitsu.com>
Date: Tue, 19 Jun 2012 03:50:01 +0200
Local: Mon, Jun 18 2012 9:50 pm
Subject: Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
On 03/29/2012 05:55 PM, tip-bot for Kees Cook wrote:

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.

https://github.com/linux-test-project/ltp/blob/master/testcases/kerne...
                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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Serge Hallyn  
View profile  
 More options Jun 18 2012, 10:30 pm
Newsgroups: linux.kernel
From: Serge Hallyn <serge.hal...@canonical.com>
Date: Tue, 19 Jun 2012 04:30:02 +0200
Local: Mon, Jun 18 2012 10:30 pm
Subject: Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoting Wanlong Gao (gaowanl...@cn.fujitsu.com):

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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wanlong Gao  
View profile  
 More options Jun 18 2012, 10:40 pm
Newsgroups: linux.kernel
From: Wanlong Gao <gaowanl...@cn.fujitsu.com>
Date: Tue, 19 Jun 2012 04:40:02 +0200
Local: Mon, Jun 18 2012 10:40 pm
Subject: Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
On 06/19/2012 10:24 AM, Serge Hallyn wrote:

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Serge Hallyn  
View profile  
 More options Jun 18 2012, 11:20 pm
Newsgroups: linux.kernel
From: Serge Hallyn <serge.hal...@canonical.com>
Date: Tue, 19 Jun 2012 05:20:02 +0200
Local: Mon, Jun 18 2012 11:20 pm
Subject: Re: [tip:core/locking] futex: Do not leak robust list to unprivileged process
Quoting Wanlong Gao (gaowanl...@cn.fujitsu.com):

Didn't mean to offend :)

> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 40   Newer >
« Back to Discussions « Newer topic     Older topic »