Re: [PATCH v22 08/12] landlock: Add syscall implementations

From: Mickaël Salaün
Date: Fri Oct 30 2020 - 08:41:34 EST



On 30/10/2020 04:07, Jann Horn wrote:
> On Thu, Oct 29, 2020 at 12:30 PM Mickaël Salaün <mic@xxxxxxxxxxx> wrote:
>> On 29/10/2020 02:06, Jann Horn wrote:
>>> On Tue, Oct 27, 2020 at 9:04 PM Mickaël Salaün <mic@xxxxxxxxxxx> wrote:
>>>> These 3 system calls are designed to be used by unprivileged processes
>>>> to sandbox themselves:
> [...]
>>>> + /*
>>>> + * Similar checks as for seccomp(2), except that an -EPERM may be
>>>> + * returned.
>>>> + */
>>>> + if (!task_no_new_privs(current)) {
>>>> + err = security_capable(current_cred(), current_user_ns(),
>>>> + CAP_SYS_ADMIN, CAP_OPT_NOAUDIT);
>>>
>>> I think this should be ns_capable_noaudit(current_user_ns(), CAP_SYS_ADMIN)?
>>
>> Right. The main difference is that ns_capable*() set PF_SUPERPRIV in
>> current->flags. I guess seccomp should use ns_capable_noaudit() as well?
>
> Yeah. That seccomp code is from commit e2cfabdfd0756, with commit date
> in April 2012, while ns_capable_noaudit() was introduced in commit
> 98f368e9e263, with commit date in June 2016; the seccomp code predates
> the availability of that API.
>
> Do you want to send a patch to Kees for that, or should I?
>

I found another case of this inconsistency in ptrace. I sent patches:
https://lore.kernel.org/lkml/20201030123849.770769-1-mic@xxxxxxxxxxx/