From: Tom Hromatka <tom.hromatka@oracle.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Kees Cook <kees@kernel.org>,
Andy Lutomirski <luto@amacapital.net>,
Will Drewry <wad@chromium.org>, Sargun Dhillon <sargun@sargun.me>,
Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org>,
Christian Brauner <brauner@kernel.org>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH] seccomp: Add SECCOMP_CLONE_FILTER operation
Date: Thu, 4 Sep 2025 08:26:30 -0600 [thread overview]
Message-ID: <21b618d5-7f6c-4b06-81be-eea6cbac5ba6@oracle.com> (raw)
In-Reply-To: <CAADnVQJSgcAjEnU-A9bF6-9MQRFvbHqRsCCY7a0Y6bhVGtcGpA@mail.gmail.com>
On 9/3/25 4:44 PM, Alexei Starovoitov wrote:
> On Wed, Sep 3, 2025 at 1:52 PM Tom Hromatka <tom.hromatka@oracle.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@oracle.com> wrote:
>>>>
>>>> +
>>>> + spin_lock_irq(¤t->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(¤t->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(¤t->sighand->siglock);
spin_lock(&task->sighand->siglock);
if (atomic_read(&task->seccomp.filter_count) == 0) {
spin_unlock(&task->sighand->siglock);
spin_unlock_irq(¤t->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(¤t->sighand->siglock);
Let me know if there are other fixes I need to add.
Thanks so much!
Tom
next prev parent reply other threads:[~2025-09-04 14:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 20:38 Tom Hromatka
2025-09-03 20:45 ` Alexei Starovoitov
2025-09-03 20:51 ` Tom Hromatka
2025-09-03 22:44 ` Alexei Starovoitov
2025-09-04 12:08 ` Tom Hromatka
2025-09-04 14:26 ` Tom Hromatka [this message]
2025-09-04 14:54 ` Al Viro
2025-09-04 18:10 ` Tom Hromatka
2025-09-04 11:53 ` kernel test robot
2025-09-04 16:26 ` Kees Cook
2025-09-04 18:19 ` Tom Hromatka
2025-09-04 17:51 ` Al Viro
2025-09-05 21:03 ` YiFei Zhu
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=21b618d5-7f6c-4b06-81be-eea6cbac5ba6@oracle.com \
--to=tom.hromatka@oracle.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=corbet@lwn.net \
--cc=kees@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=sargun@sargun.me \
--cc=shuah@kernel.org \
--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®