All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Kees Cook <keescook@chromium.org>
Cc: Djalal Harouni <tixxdz@opendz.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Solar Designer <solar@openwall.com>,
	Vasiliy Kulikov <segoon@openwall.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>
Subject: [kernel-hardening] Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}
Date: Thu, 29 Aug 2013 00:42:26 -0700	[thread overview]
Message-ID: <87sixt3pul.fsf@xmission.com> (raw)
In-Reply-To: <CAGXu5j+axsd2DPA-QTLSLH32canH4V0FEnW4=wuCqZFa-niKGA@mail.gmail.com> (Kees Cook's message of "Wed, 28 Aug 2013 20:33:20 -0700")

Kees Cook <keescook@chromium.org> writes:

> On Wed, Aug 28, 2013 at 6:08 PM, Eric W. Biederman
> <ebiederm@xmission.com> wrote:
>> Kees Cook <keescook@chromium.org> writes:
>>
>>> On Wed, Aug 28, 2013 at 5:26 PM, Eric W. Biederman
>>> <ebiederm@xmission.com> wrote:
>>>> Can someome please state what they are worried about in simple language
>>>> step by step?
>>>> [...]
>>>> The closest I saw in the thread was people were worried about ASLR being
>>>> defeated.  All I see are kernel addresses and we don't have much if any
>>>> runtime or even load time randomization of where code is located in the
>>>> kernel address map on x86_64.  So I don't understand the concern.
>>>
>>> I showed the output of "syscall", since that contains user-space
>>> addresses and shows a leak of ASLR from a privileged process to an
>>> unprivileged process.
>>>
>>> The flaw as I see it is that an unprivileged process opens
>>> /proc/$priv_pid/syscall and passes it to a setuid process which is
>>> able to read it, and provides those contents to the unprivileged
>>> process.
>>>
>>> The unprivileged process should not be able to the open the file in
>>> the first place.
>>
>> I see so the complaint is that we don't give read permission but we do
>> give open permission.    Which is a variant of: the permissions used to
>> open are not the permission used to access the file.
>>
>> This does seem to be a legitimate concern.
>>
>> I think there are several discussions that have been going on lately
>> with respect to this class of problems in proc files.
>>
>> Given the existence of suid exec we can not in general prevent this
>> class of bugs with a check at open time.
>
> I'm not suggesting removing the read check -- that's certainly needed.
>
>> I believe the solution needs to be to enhance the ptrace_may_access
>> checks to verify that both the creds of the current task and the creds
>> of the opening process would have allowed the access.
>
> As in, DAC perms are insufficient?

As in any checks at open time are insufficient.

Roughly what we need is to use the credentials that are present at open
time (file->f_cred) in the ptrace_may_access call instead of or
in addition to current_cred().

Eric

WARNING: multiple messages have this Message-ID (diff)
From: ebiederm@xmission.com (Eric W. Biederman)
To: Kees Cook <keescook@chromium.org>
Cc: Djalal Harouni <tixxdz@opendz.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Solar Designer <solar@openwall.com>,
	Vasiliy Kulikov <segoon@openwall.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"kernel-hardening\@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>
Subject: Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}
Date: Thu, 29 Aug 2013 00:42:26 -0700	[thread overview]
Message-ID: <87sixt3pul.fsf@xmission.com> (raw)
In-Reply-To: <CAGXu5j+axsd2DPA-QTLSLH32canH4V0FEnW4=wuCqZFa-niKGA@mail.gmail.com> (Kees Cook's message of "Wed, 28 Aug 2013 20:33:20 -0700")

Kees Cook <keescook@chromium.org> writes:

> On Wed, Aug 28, 2013 at 6:08 PM, Eric W. Biederman
> <ebiederm@xmission.com> wrote:
>> Kees Cook <keescook@chromium.org> writes:
>>
>>> On Wed, Aug 28, 2013 at 5:26 PM, Eric W. Biederman
>>> <ebiederm@xmission.com> wrote:
>>>> Can someome please state what they are worried about in simple language
>>>> step by step?
>>>> [...]
>>>> The closest I saw in the thread was people were worried about ASLR being
>>>> defeated.  All I see are kernel addresses and we don't have much if any
>>>> runtime or even load time randomization of where code is located in the
>>>> kernel address map on x86_64.  So I don't understand the concern.
>>>
>>> I showed the output of "syscall", since that contains user-space
>>> addresses and shows a leak of ASLR from a privileged process to an
>>> unprivileged process.
>>>
>>> The flaw as I see it is that an unprivileged process opens
>>> /proc/$priv_pid/syscall and passes it to a setuid process which is
>>> able to read it, and provides those contents to the unprivileged
>>> process.
>>>
>>> The unprivileged process should not be able to the open the file in
>>> the first place.
>>
>> I see so the complaint is that we don't give read permission but we do
>> give open permission.    Which is a variant of: the permissions used to
>> open are not the permission used to access the file.
>>
>> This does seem to be a legitimate concern.
>>
>> I think there are several discussions that have been going on lately
>> with respect to this class of problems in proc files.
>>
>> Given the existence of suid exec we can not in general prevent this
>> class of bugs with a check at open time.
>
> I'm not suggesting removing the read check -- that's certainly needed.
>
>> I believe the solution needs to be to enhance the ptrace_may_access
>> checks to verify that both the creds of the current task and the creds
>> of the opening process would have allowed the access.
>
> As in, DAC perms are insufficient?

As in any checks at open time are insufficient.

Roughly what we need is to use the credentials that are present at open
time (file->f_cred) in the ptrace_may_access call instead of or
in addition to current_cred().

Eric

  reply	other threads:[~2013-08-29  7:42 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-26 16:23 [kernel-hardening] [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality} Djalal Harouni
2013-08-26 16:23 ` Djalal Harouni
2013-08-26 16:24 ` [kernel-hardening] [PATCH 2/2] procfs: restore 0400 permissions on /proc/*/pagemap Djalal Harouni
2013-08-26 16:24   ` Djalal Harouni
2013-08-26 16:50   ` [kernel-hardening] " Eric W. Biederman
2013-08-26 16:50     ` Eric W. Biederman
2013-08-26 16:49 ` [kernel-hardening] Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality} Eric W. Biederman
2013-08-26 16:49   ` Eric W. Biederman
2013-08-26 17:20   ` [kernel-hardening] " Al Viro
2013-08-26 17:20     ` Al Viro
2013-08-27 17:24     ` [kernel-hardening] " Djalal Harouni
2013-08-27 17:24       ` Djalal Harouni
2013-08-28 20:11       ` [kernel-hardening] " Djalal Harouni
2013-08-28 20:11         ` Djalal Harouni
2013-08-28 20:49         ` [kernel-hardening] " Kees Cook
2013-08-28 20:49           ` Kees Cook
2013-08-28 21:11           ` [kernel-hardening] " Djalal Harouni
2013-08-28 21:11             ` Djalal Harouni
2013-08-29  0:26             ` [kernel-hardening] " Eric W. Biederman
2013-08-29  0:26               ` Eric W. Biederman
2013-08-29  0:30               ` [kernel-hardening] " Kees Cook
2013-08-29  0:30                 ` Kees Cook
2013-08-29  1:08                 ` [kernel-hardening] " Eric W. Biederman
2013-08-29  1:08                   ` Eric W. Biederman
2013-08-29  3:33                   ` [kernel-hardening] " Kees Cook
2013-08-29  3:33                     ` Kees Cook
2013-08-29  7:42                     ` Eric W. Biederman [this message]
2013-08-29  7:42                       ` Eric W. Biederman
2013-08-29  9:11               ` [kernel-hardening] " Djalal Harouni
2013-08-29  9:11                 ` Djalal Harouni
2013-08-29 22:14                 ` [kernel-hardening] " Kees Cook
2013-08-29 22:14                   ` Kees Cook
2013-08-31 20:26                   ` [kernel-hardening] " Djalal Harouni
2013-08-31 20:26                     ` Djalal Harouni
2013-09-01  1:44                     ` [kernel-hardening] " Eric W. Biederman
2013-09-01  1:44                       ` Eric W. Biederman
2013-09-01 15:04                       ` [kernel-hardening] " Kees Cook
2013-09-01 15:04                         ` Kees Cook
2013-09-12  1:23                       ` [kernel-hardening] " Djalal Harouni
2013-09-12  1:23                         ` Djalal Harouni
2013-10-04  0:41           ` [kernel-hardening] " Kees Cook
2013-10-04  0:41             ` Kees Cook
2013-10-04  0:53             ` [kernel-hardening] " Ryan Mallon
2013-10-04  0:53               ` Ryan Mallon
2013-08-26 20:34   ` [kernel-hardening] " Djalal Harouni
2013-08-26 20:34     ` Djalal Harouni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sixt3pul.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=segoon@openwall.com \
    --cc=solar@openwall.com \
    --cc=tixxdz@opendz.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.