mbox series

[bpf,v3,0/5] Fixes for bits iterator

Message ID 20241025013233.804027-1-houtao@huaweicloud.com (mailing list archive)
Headers show
Series Fixes for bits iterator | expand

Message

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

Hi,

The patch set fixes some issues for bits iterator. Patch #1 fixes the
kmemleak problem of bits iterator. Patch #2~#3 fix the overflow problem
of nr_bits. Patch #4 fixes the potential stack corruption when bits
iterator is used on 32-bit host. Patch #5 adds more test cases for bits
iterator.

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

---
v3:
  * split the bits-iterator related patches from "Misc fixes for bpf"
    patch set
  * patch #1: use "!nr_bits || bits >= nr_bits" to stop the iteration
  * patch #2: add a new helper for the overflow problem
  * patch #3: decrease the limitation from 512 to 511 and check whether
    nr_bytes is too large for bpf memory allocator explicitly
  * patch #5: add two more test cases for bit iterator

v2: http://lore.kernel.org/bpf/d49fa2f4-f743-c763-7579-c3cab4dd88cb@huaweicloud.com

Hou Tao (5):
  bpf: Free dynamically allocated bits in bpf_iter_bits_destroy()
  bpf: Add bpf_mem_alloc_check_size() helper
  bpf: Check the validity of nr_words in bpf_iter_bits_new()
  bpf: Use __u64 to save the bits in bits iterator
  selftests/bpf: Add three test cases for bits_iter

 include/linux/bpf_mem_alloc.h                 |  3 +
 kernel/bpf/helpers.c                          | 62 +++++++++++++++----
 kernel/bpf/memalloc.c                         | 14 ++++-
 .../selftests/bpf/progs/verifier_bits_iter.c  | 61 +++++++++++++++++-
 4 files changed, 123 insertions(+), 17 deletions(-)