On 11/14/23 11:32 AM, Oleg Nesterov wrote:
> Compile tested.
>
> Every lockless usage of next_thread() was wrong, bpf/task_iter.c is
> the last user and is no exception.
It would be great if you can give more information in the commit message
about why the usage of next_thread() is wrong in bpf/task_iter.c.
IIUC, some information is presented in :
https://lore.kernel.org/all/[email protected]/
Also, please add 'bpf' in the subject tag ([PATCH bpf 0/3]) to
make it clear the patch should be applied to bpf tree.
>
> Oleg.
> ---
>
> kernel/bpf/task_iter.c | 29 +++++++++++------------------
> 1 file changed, 11 insertions(+), 18 deletions(-)
>
On 11/15, Yonghong Song wrote:
>
> On 11/14/23 11:32 AM, Oleg Nesterov wrote:
> >Compile tested.
> >
> >Every lockless usage of next_thread() was wrong, bpf/task_iter.c is
> >the last user and is no exception.
>
> It would be great if you can give more information in the commit message
> about why the usage of next_thread() is wrong in bpf/task_iter.c.
I tried to explain the problems in the changelogs:
1/3:
task_group_seq_get_next() can return the group leader twice if it races
with mt-thread exec which changes the group->leader's pid.
2/3:
bpf_iter_task_next() can loop forever, "kit->pos == kit->task" can never
happen if kit->pos execs.
> IIUC, some information is presented in :
> https://lore.kernel.org/all/[email protected]/
Yes, Linus and Eric suggest to simply kill next_thread(). I am not
sure, this needs another discussion.
But as for bpf/task_iter.c... Even _if_ the usage was correct, this
code simply doesn't need the "circular" next_thread(), NULL at the
end simplifies the code.
> Also, please add 'bpf' in the subject tag ([PATCH bpf 0/3]) to
> make it clear the patch should be applied to bpf tree.
OK, will do next time. Or should I resend this series with 'bpf'
in the subject tag?
Thanks,
Oleg.
On 11/16/23 4:54 AM, Oleg Nesterov wrote:
> On 11/15, Yonghong Song wrote:
>> On 11/14/23 11:32 AM, Oleg Nesterov wrote:
>>> Compile tested.
>>>
>>> Every lockless usage of next_thread() was wrong, bpf/task_iter.c is
>>> the last user and is no exception.
>> It would be great if you can give more information in the commit message
>> about why the usage of next_thread() is wrong in bpf/task_iter.c.
> I tried to explain the problems in the changelogs:
>
> 1/3:
> task_group_seq_get_next() can return the group leader twice if it races
> with mt-thread exec which changes the group->leader's pid.
>
> 2/3:
> bpf_iter_task_next() can loop forever, "kit->pos == kit->task" can never
> happen if kit->pos execs.
>
>> IIUC, some information is presented in :
>> https://lore.kernel.org/all/[email protected]/
> Yes, Linus and Eric suggest to simply kill next_thread(). I am not
> sure, this needs another discussion.
>
> But as for bpf/task_iter.c... Even _if_ the usage was correct, this
> code simply doesn't need the "circular" next_thread(), NULL at the
> end simplifies the code.
>
>> Also, please add 'bpf' in the subject tag ([PATCH bpf 0/3]) to
>> make it clear the patch should be applied to bpf tree.
> OK, will do next time. Or should I resend this series with 'bpf'
> in the subject tag?
There is no need then. We can wait for maintainers who may or
may not have additional requests.
>
> Thanks,
>
> Oleg.
>