lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <21b618d5-7f6c-4b06-81be-eea6cbac5ba6@oracle.com>
Date: Thu, 4 Sep 2025 08:26:30 -0600
From: Tom Hromatka <tom.hromatka@...cle.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: Kees Cook <kees@...nel.org>, Andy Lutomirski <luto@...capital.net>,
        Will Drewry <wad@...omium.org>, Sargun Dhillon <sargun@...gun.me>,
        Jonathan Corbet <corbet@....net>, Shuah Khan <shuah@...nel.org>,
        Christian Brauner <brauner@...nel.org>,
        "open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        "open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>,
        bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH] seccomp: Add SECCOMP_CLONE_FILTER operation

On 9/3/25 4:44 PM, Alexei Starovoitov wrote:
> On Wed, Sep 3, 2025 at 1:52 PM Tom Hromatka <tom.hromatka@...cle.com> wrote:
>>
>> On 9/3/25 2:45 PM, Alexei Starovoitov wrote:
>>> On Wed, Sep 3, 2025 at 1:38 PM Tom Hromatka <tom.hromatka@...cle.com> wrote:
>>>>
>>>> +
>>>> +       spin_lock_irq(&current->sighand->siglock);
>>>> +       spin_lock_irq(&task->sighand->siglock);
>>>> +
>>>> +       if (atomic_read(&task->seccomp.filter_count) == 0) {
>>>> +               spin_unlock_irq(&task->sighand->siglock);
>>>> +               spin_unlock_irq(&current->sighand->siglock);
>>>
>>> did you copy this pattern from somewhere ?
>>> It's obviously buggy.
>>
>> I tried to mimic the logic in copy_seccomp() in kernel/fork.c,
>> but as you point out, I probably messed it up :).
>>
>> Do you have recommendations for a better design pattern?
> 
> Several things look wrong here.
> Double _irq() is one obvious bug.

This snippet addresses the double irq issue.  I also added a
check to make sure that task != current.  (A user shouldn't
do that but who knows what they'll actually do.)

         if (task == current) {
                 put_task_struct(task);
                 return -EINVAL;
         }

         spin_lock_irq(&current->sighand->siglock);
         spin_lock(&task->sighand->siglock);

         if (atomic_read(&task->seccomp.filter_count) == 0) {
                 spin_unlock(&task->sighand->siglock);
                 spin_unlock_irq(&current->sighand->siglock);
                 put_task_struct(task);
                 return -EINVAL;
         }

         get_seccomp_filter(task);
         current->seccomp = task->seccomp;

         spin_unlock(&task->sighand->siglock);

         set_task_syscall_work(current, SECCOMP);

         spin_unlock_irq(&current->sighand->siglock);

Let me know if there are other fixes I need to add.

Thanks so much!

Tom

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ