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:
 <AM6PR03MB58485AC0EC31E8DA0D5169FC99532@AM6PR03MB5848.eurprd03.prod.outlook.com>
Date: Wed, 6 Nov 2024 22:46:05 +0000
From: Juntong Deng <juntong.deng@...look.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>,
 Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
 Daniel Borkmann <daniel@...earbox.net>,
 John Fastabend <john.fastabend@...il.com>,
 Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau
 <martin.lau@...ux.dev>, Eddy Z <eddyz87@...il.com>,
 Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
 KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
 Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
 Kumar Kartikeya Dwivedi <memxor@...il.com>, snorcht@...il.com,
 Christian Brauner <brauner@...nel.org>, bpf <bpf@...r.kernel.org>,
 LKML <linux-kernel@...r.kernel.org>,
 Linux-Fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH bpf-next v3 1/4] bpf/crib: Introduce task_file open-coded
 iterator kfuncs

On 2024/11/6 22:13, Alexei Starovoitov wrote:
> On Wed, Nov 6, 2024 at 2:10 PM Andrii Nakryiko
> <andrii.nakryiko@...il.com> wrote:
>>>> +__bpf_kfunc int bpf_iter_task_file_new(struct bpf_iter_task_file *it,
>>>> +               struct task_struct *task)
>>>> +{
>>>> +       struct bpf_iter_task_file_kern *kit = (void *)it;
>>>> +
>>>> +       BUILD_BUG_ON(sizeof(struct bpf_iter_task_file_kern) > sizeof(struct bpf_iter_task_file));
>>>> +       BUILD_BUG_ON(__alignof__(struct bpf_iter_task_file_kern) !=
>>>> +                    __alignof__(struct bpf_iter_task_file));
>>>> +
>>>> +       kit->task = task;
>>>
>>> This is broken, since task refcnt can drop while iter is running.
>>
>> I noticed this as well, but I thought that given KF_TRUSTED_ARGS we
>> should have a guarantee that the task survives the iteration? Am I
>> mistaken?
> 
> KF_TRUSTED_ARGS will only guarantee that the task is valid when it's
> passed into this kfunc. Right after the prog can call
> bpf_task_release() to release the ref and kit->task will become
> dangling.
> If this object was RCU protected we could have marked this iter
> as KF_RCU_PROTECTED, then the verifier would make sure that
> RCU unlock doesn't happen between iter_new and iter_destroy.

Thanks for pointing this out.

I will fix it in the next version of the patch series.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ