From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: Oleg Nesterov <oleg@tv-sign.ru>, Jann Horn <jannh@google.com>,
Ted Estes <ted@softwarecrafters.com>
Cc: Jann Horn <jann@thejh.net>, Pavel Emelyanov <xemul@openvz.org>,
Andrew Morton <akpm@linux-foundation.org>,
Michael Kerrisk <mtk.manpages@gmail.com>,
Kees Cook <keescook@chromium.org>,
linux-man <linux-man@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Darren Hart <dvhart@infradead.org>
Subject: Re: [Bug 210655] ptrace.2: documentation is incorrect about access checking threads in same thread group
Date: Wed, 16 Dec 2020 10:22:09 +0100 [thread overview]
Message-ID: <1abbf267-d522-0586-e5a5-c71f4d7b0fa4@gmail.com> (raw)
In-Reply-To: <CAG48ez2g=U-H56g6VebQCiSXGg+bVvhBA5yfwymNxVYAGEJJcA@mail.gmail.com>
[CC += Thomas, Ingo, Peter, Darren]
Hi Oleg,
On 12/16/20 3:33 AM, Jann Horn wrote:
> On Wed, Dec 16, 2020 at 3:21 AM Ted Estes <ted@softwarecrafters.com> wrote:
>> On 12/15/2020 6:01 PM, Jann Horn wrote:
>>> On Wed, Dec 16, 2020 at 12:25 AM Alejandro Colomar (man-pages)
>>> <alx.manpages@gmail.com> wrote:
>>>> On 12/16/20 12:23 AM, Alejandro Colomar (man-pages) wrote:
>>>>> On 12/16/20 12:07 AM, Jann Horn wrote:
>>>>>> As the comment explains, you can't actually *attach*
>>>>>> to another task in the same thread group; but that's
>>>>>> not because of the ptrace-style access check rules,
>>>>>> but because specifically *attaching* to another task
>>>>>> in the same thread group doesn't work.
>>> As I said, attaching indeed doesn't work. But that's not what "Ptrace
>>> access mode checking" means. As the first sentence of that section
>>> says:
>>>
>>> | Various parts of the kernel-user-space API (not just ptrace()
>>> | operations), require so-called "ptrace access mode" checks,
>>> | whose outcome determines whether an operation is
>>> | permitted (or, in a few cases, causes a "read" operation
>>> | to return sanitized data).
>>>
>>> You can find these places by grepping for \bptrace_may_access\b -
>>> operations like e.g. the get_robust_list() syscall will always succeed
>>> when inspecting other tasks in the caller's thread group thanks to
>>> this rule.
>>
>> Ah, yes. I missed that back reference while trying to digest that
>> rather meaty man page. A grep on the man page source tree does show a
>> number of references to "ptrace access mode".
>>
>> That said, the ptrace(2) man page also directly references the ptrace
>> access mode check under both PTRACE_ATTACH and PTACE_SEIZE:
>>
>> | Permission to perform a PTRACE_ATTACH is governed by a ptrace | access
>> mode PTRACE_MODE_ATTACH_REALCREDS check; see below. As confirmed, the
>> "same thread group" rule does not apply to either of those operations. A
>> re-wording of rule 1 similar to this might help avoid confusion: 1. If
>> the calling thread and the target thread are in the same thread group:
>> a. For ptrace() called with PTRACE_ATTACH or PTRACE_SEIZE, access is
>> NEVER allowed. b. For all other so-called "ptrace access mode checks",
>> access is ALWAYS allowed. --Ted
>
> Yeah, maybe. OTOH I'm not sure whether it really makes sense to
> explain this as being part of a security check, or whether it should
> be explained separately as a restriction on PTRACE_ATTACH and
> PTRACE_SEIZE (with a note like "(irrelevant for ptrace attachment)" on
> rule 1). But I don't feel strongly about it either way.
>
As you are the maintainer for ptrace,
could you confirm the above from Jan?
And maybe suggest what you would do with the manual page.
I'd like to get confirmation that there are still other functions that
require "ptrace access mode" other than ptrace() itself, where it's
valid that the calling thread and the target thread are in the same group.
Jann noted get_robust_list() as an example, so I CCed futex maintainers.
Thanks,
Alex
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es
next prev parent reply other threads:[~2020-12-16 9:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 17:01 [Bug 210655] ptrace.2: documentation is incorrect about access checking threads in same thread group Alejandro Colomar (man-pages)
2020-12-15 18:31 ` Ted Estes
2020-12-15 18:34 ` Alejandro Colomar (man-pages)
2020-12-15 22:48 ` Alejandro Colomar (man-pages)
2020-12-16 0:55 ` Linus Torvalds
2020-12-16 7:34 ` Oleg Nesterov
2020-12-15 23:07 ` Jann Horn
2020-12-15 23:23 ` Alejandro Colomar (man-pages)
2020-12-15 23:25 ` Alejandro Colomar (man-pages)
2020-12-16 0:01 ` Jann Horn
2020-12-16 2:21 ` Ted Estes
2020-12-16 2:33 ` Jann Horn
2020-12-16 9:22 ` Alejandro Colomar (man-pages) [this message]
2020-12-17 18:45 ` Eric W. Biederman
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=1abbf267-d522-0586-e5a5-c71f4d7b0fa4@gmail.com \
--to=alx.manpages@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dvhart@infradead.org \
--cc=jann@thejh.net \
--cc=jannh@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mtk.manpages@gmail.com \
--cc=oleg@tv-sign.ru \
--cc=peterz@infradead.org \
--cc=ted@softwarecrafters.com \
--cc=tglx@linutronix.de \
--cc=xemul@openvz.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox