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]
Date:   Sun, 13 Dec 2020 23:00:09 -0800
From:   Yonghong Song <yhs@...com>
To:     Jonathan Lemon <jonathan.lemon@...il.com>,
        Andrii Nakryiko <andrii.nakryiko@...il.com>
CC:     Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        bpf <bpf@...r.kernel.org>, Kernel Team <kernel-team@...com>
Subject: Re: [PATCH 1/1 v3 bpf-next] bpf: increment and use correct thread
 iterator



On 12/11/20 3:01 PM, Jonathan Lemon wrote:
> On Fri, Dec 11, 2020 at 12:23:34PM -0800, Andrii Nakryiko wrote:
>>> @@ -164,7 +164,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)
>>>                  curr_files = get_files_struct(curr_task);
>>>                  if (!curr_files) {
>>>                          put_task_struct(curr_task);
>>> -                       curr_tid = ++(info->tid);
>>> +                       curr_tid = curr_tid + 1;
>>
>> Yonghong might know definitively, but it seems like we need to update
>> info->tid here as well:
>>
>> info->tid = curr_tid;
>>
>> If the search eventually yields no task, then info->tid will stay at
>> some potentially much smaller value, and we'll keep re-searching tasks
>> from the same TID on each subsequent read (if user keeps reading the
>> file). So corner case, but good to have covered.
> 
> That applies earlier as well:
> 
>                  curr_task = task_seq_get_next(ns, &curr_tid, true);
>                  if (!curr_task) {
>                          info->task = NULL;
>                          info->files = NULL;
>                          return NULL;
>                  }
> 
> The logic seems to be "if task == NULL, then return NULL and stop".
> Is the seq_iterator allowed to continue/restart if seq_next returns NULL?

If seq_next() returns NULL, bpf_seq_read() will end and the control
will return to user space. There are two cases here:
    - there are something in the buffer and user will get non-zero-length
      return data and after this typically user will call read() syscall
      again. In such cases case, the search will be from last info->tid.
    - the buffer is empty and user will get a "0" return value for read()
      system. Typically, user will not call read() syscall any more.
      But if it does, the search will start from last info->tid.

Agree with Andrii, in general, this should not be a big problem.
But it is good to get this fixed too.

> --
> Jonathan
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ