mbox series

[bpf,v2,0/7] Misc fixes for bpf

Message ID 20241021014004.1647816-1-houtao@huaweicloud.com (mailing list archive)
Headers show
Series Misc fixes for bpf | expand

Message

Hou Tao Oct. 21, 2024, 1:39 a.m. UTC
From: Hou Tao <houtao1@huawei.com>

Hi,

The patch set is just a bundle of fixes. Patch #1 fixes the out-of-bound
for sockmap link fdinfo. Patch #2 adds a static assertion to guarantee
such out-of-bound access will never happen again. Patch #3 fixes the
kmemleak report when parsing the mount options for bpffs. Patch #4~#7
fix issues related to bits iterator.

Please check the individual patches for more details. And comments are
always welcome.

v2:
 * patch #1: update tools/include/uapi/linux/bpf.h as well (Alexei)
 * patch #2: new patch. Add a static assertion for bpf_link_type_strs[] (Andrii)
 * patch #4: doesn't set nr_bits to zero in bpf_iter_bits_next (Andrii)
 * patch #5: use 512 as the maximal value of nr_words
 * patch #6: change the type of both bits and bits_copy to u64 (Andrii)

v1: https://lore.kernel.org/bpf/20241008091718.3797027-1-houtao@huaweicloud.com/

Hou Tao (7):
  bpf: Add the missing BPF_LINK_TYPE invocation for sockmap
  bpf: Add assertion for the size of bpf_link_type_strs[]
  bpf: Preserve param->string when parsing mount options
  bpf: Free dynamically allocated bits in bpf_iter_bits_destroy()
  bpf: Check the validity of nr_words in bpf_iter_bits_new()
  bpf: Use __u64 to save the bits in bits iterator
  selftests/bpf: Test multiplication overflow of nr_bits in bits_iter

 include/linux/bpf_types.h                     |  7 +--
 include/uapi/linux/bpf.h                      |  3 ++
 kernel/bpf/helpers.c                          | 45 +++++++++++++++----
 kernel/bpf/inode.c                            |  5 ++-
 kernel/bpf/syscall.c                          |  2 +
 tools/include/uapi/linux/bpf.h                |  3 ++
 .../selftests/bpf/progs/verifier_bits_iter.c  | 14 ++++++
 7 files changed, 63 insertions(+), 16 deletions(-)

Comments

Andrii Nakryiko Oct. 21, 2024, 11:11 p.m. UTC | #1
On Sun, Oct 20, 2024 at 6:28 PM Hou Tao <houtao@huaweicloud.com> wrote:
>
> From: Hou Tao <houtao1@huawei.com>
>
> Hi,
>
> The patch set is just a bundle of fixes. Patch #1 fixes the out-of-bound
> for sockmap link fdinfo. Patch #2 adds a static assertion to guarantee
> such out-of-bound access will never happen again. Patch #3 fixes the
> kmemleak report when parsing the mount options for bpffs. Patch #4~#7
> fix issues related to bits iterator.
>
> Please check the individual patches for more details. And comments are
> always welcome.
>
> v2:
>  * patch #1: update tools/include/uapi/linux/bpf.h as well (Alexei)
>  * patch #2: new patch. Add a static assertion for bpf_link_type_strs[] (Andrii)
>  * patch #4: doesn't set nr_bits to zero in bpf_iter_bits_next (Andrii)
>  * patch #5: use 512 as the maximal value of nr_words
>  * patch #6: change the type of both bits and bits_copy to u64 (Andrii)
>
> v1: https://lore.kernel.org/bpf/20241008091718.3797027-1-houtao@huaweicloud.com/
>
You have three separate groups of fixes, please send them separately
so they can be landed separately and tested separately:

> Hou Tao (7):
>   bpf: Add the missing BPF_LINK_TYPE invocation for sockmap
>   bpf: Add assertion for the size of bpf_link_type_strs[]

first, link type fixes

>   bpf: Preserve param->string when parsing mount options

parsing fix

>   bpf: Free dynamically allocated bits in bpf_iter_bits_destroy()
>   bpf: Check the validity of nr_words in bpf_iter_bits_new()
>   bpf: Use __u64 to save the bits in bits iterator
>   selftests/bpf: Test multiplication overflow of nr_bits in bits_iter

bits iter fixes

>
>  include/linux/bpf_types.h                     |  7 +--
>  include/uapi/linux/bpf.h                      |  3 ++
>  kernel/bpf/helpers.c                          | 45 +++++++++++++++----
>  kernel/bpf/inode.c                            |  5 ++-
>  kernel/bpf/syscall.c                          |  2 +
>  tools/include/uapi/linux/bpf.h                |  3 ++
>  .../selftests/bpf/progs/verifier_bits_iter.c  | 14 ++++++
>  7 files changed, 63 insertions(+), 16 deletions(-)
>
> --
> 2.29.2
>
Hou Tao Oct. 22, 2024, 7:37 a.m. UTC | #2
Hi Andrii,

On 10/22/2024 7:11 AM, Andrii Nakryiko wrote:
> On Sun, Oct 20, 2024 at 6:28 PM Hou Tao <houtao@huaweicloud.com> wrote:
>> From: Hou Tao <houtao1@huawei.com>
>>
>> Hi,
>>
>> The patch set is just a bundle of fixes. Patch #1 fixes the out-of-bound
>> for sockmap link fdinfo. Patch #2 adds a static assertion to guarantee
>> such out-of-bound access will never happen again. Patch #3 fixes the
>> kmemleak report when parsing the mount options for bpffs. Patch #4~#7
>> fix issues related to bits iterator.
>>
>> Please check the individual patches for more details. And comments are
>> always welcome.
>>
>> v2:
>>  * patch #1: update tools/include/uapi/linux/bpf.h as well (Alexei)
>>  * patch #2: new patch. Add a static assertion for bpf_link_type_strs[] (Andrii)
>>  * patch #4: doesn't set nr_bits to zero in bpf_iter_bits_next (Andrii)
>>  * patch #5: use 512 as the maximal value of nr_words
>>  * patch #6: change the type of both bits and bits_copy to u64 (Andrii)
>>
>> v1: https://lore.kernel.org/bpf/20241008091718.3797027-1-houtao@huaweicloud.com/
>>
> You have three separate groups of fixes, please send them separately
> so they can be landed separately and tested separately:
>
>> Hou Tao (7):
>>   bpf: Add the missing BPF_LINK_TYPE invocation for sockmap
>>   bpf: Add assertion for the size of bpf_link_type_strs[]
> first, link type fixes
>
>>   bpf: Preserve param->string when parsing mount options
> parsing fix
>
>>   bpf: Free dynamically allocated bits in bpf_iter_bits_destroy()
>>   bpf: Check the validity of nr_words in bpf_iter_bits_new()
>>   bpf: Use __u64 to save the bits in bits iterator
>>   selftests/bpf: Test multiplication overflow of nr_bits in bits_iter
> bits iter fixes

Thanks for the suggestion. Will do in v3.