From: "Mickaël Salaün" <mic@digikod.net>
To: Jann Horn <jannh@google.com>
Cc: "Christian Brauner" <christian.brauner@ubuntu.com>,
"Kees Cook" <keescook@chromium.org>,
"Oleg Nesterov" <oleg@redhat.com>,
"Eric Paris" <eparis@redhat.com>,
"James Morris" <jmorris@namei.org>,
"Serge E . Hallyn" <serge@hallyn.com>,
"Tyler Hicks" <tyhicks@linux.microsoft.com>,
"Will Drewry" <wad@chromium.org>,
"kernel list" <linux-kernel@vger.kernel.org>,
stable <stable@vger.kernel.org>,
"Mickaël Salaün" <mic@linux.microsoft.com>
Subject: Re: [PATCH v1 1/2] ptrace: Set PF_SUPERPRIV when checking capability
Date: Fri, 30 Oct 2020 17:06:39 +0100 [thread overview]
Message-ID: <94a86084-5aab-4a2c-e654-f55130190c1a@digikod.net> (raw)
In-Reply-To: <CAG48ez1LFAKoi-nvipsar2SAH0eNhKkOzWj4Fuf9wNCtpWsH9A@mail.gmail.com>
On 30/10/2020 16:47, Jann Horn wrote:
> On Fri, Oct 30, 2020 at 1:39 PM Mickaël Salaün <mic@digikod.net> wrote:
>> Commit 69f594a38967 ("ptrace: do not audit capability check when outputing
>> /proc/pid/stat") replaced the use of ns_capable() with
>> has_ns_capability{,_noaudit}() which doesn't set PF_SUPERPRIV.
>>
>> Commit 6b3ad6649a4c ("ptrace: reintroduce usage of subjective credentials in
>> ptrace_has_cap()") replaced has_ns_capability{,_noaudit}() with
>> security_capable(), which doesn't set PF_SUPERPRIV neither.
>>
>> Since commit 98f368e9e263 ("kernel: Add noaudit variant of ns_capable()"), a
>> new ns_capable_noaudit() helper is available. Let's use it!
>>
>> As a result, the signature of ptrace_has_cap() is restored to its original one.
>>
>> Cc: Christian Brauner <christian.brauner@ubuntu.com>
>> Cc: Eric Paris <eparis@redhat.com>
>> Cc: Jann Horn <jannh@google.com>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Oleg Nesterov <oleg@redhat.com>
>> Cc: Serge E. Hallyn <serge@hallyn.com>
>> Cc: Tyler Hicks <tyhicks@linux.microsoft.com>
>> Cc: stable@vger.kernel.org
>> Fixes: 6b3ad6649a4c ("ptrace: reintroduce usage of subjective credentials in ptrace_has_cap()")
>> Fixes: 69f594a38967 ("ptrace: do not audit capability check when outputing /proc/pid/stat")
>> Signed-off-by: Mickaël Salaün <mic@linux.microsoft.com>
>
> Yeah... I guess this makes sense. (We'd have to undo or change it if
> we ever end up needing to use a different set of credentials, e.g.
> from ->f_cred, but I guess that's really something we should avoid
> anyway.)
>
> Reviewed-by: Jann Horn <jannh@google.com>
>
> with one nit:
>
>
> [...]
>> /* Returns 0 on success, -errno on denial. */
>> static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
>> {
>> - const struct cred *cred = current_cred(), *tcred;
>> + const struct cred *const cred = current_cred(), *tcred;
>
> This is an unrelated change, and almost no kernel code marks local
> pointer variables as "const". I would drop this change from the patch.
This give guarantee that the cred variable will not be used for
something else than current_cred(), which kinda prove that this patch
doesn't change the behavior of __ptrace_may_access() by not using cred
in ptrace_has_cap(). It doesn't hurt and I think it could be useful to
spot issues when backporting.
>
>> struct mm_struct *mm;
>> kuid_t caller_uid;
>> kgid_t caller_gid;
next prev parent reply other threads:[~2020-10-30 16:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 12:38 [PATCH v1 0/2] Fix misuse of security_capable() Mickaël Salaün
2020-10-30 12:38 ` [PATCH v1 1/2] ptrace: Set PF_SUPERPRIV when checking capability Mickaël Salaün
2020-10-30 15:47 ` Jann Horn
2020-10-30 16:06 ` Mickaël Salaün [this message]
2020-10-30 18:00 ` Jann Horn
2020-10-30 12:38 ` [PATCH v1 2/2] seccomp: " Mickaël Salaün
2020-10-30 15:34 ` Jann Horn
2020-11-17 21:08 ` [PATCH v1 0/2] Fix misuse of security_capable() Kees Cook
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=94a86084-5aab-4a2c-e654-f55130190c1a@digikod.net \
--to=mic@digikod.net \
--cc=christian.brauner@ubuntu.com \
--cc=eparis@redhat.com \
--cc=jannh@google.com \
--cc=jmorris@namei.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mic@linux.microsoft.com \
--cc=oleg@redhat.com \
--cc=serge@hallyn.com \
--cc=stable@vger.kernel.org \
--cc=tyhicks@linux.microsoft.com \
--cc=wad@chromium.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
all inboxes | Powered by JetHome®