bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/8] Fixes for bad PTR_TO_BTF_ID offset
@ 2022-03-04  0:05 Kumar Kartikeya Dwivedi
  2022-03-04  0:05 ` [PATCH bpf-next v3 1/8] bpf: Add check_func_arg_reg_off function Kumar Kartikeya Dwivedi
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2022-03-04  0:05 UTC (permalink / raw)
  To: bpf; +Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko

This set fixes a bug related to bad var_off being permitted for kfunc call in
case of PTR_TO_BTF_ID, consolidates offset checks for all register types allowed
as helper or kfunc arguments into a common shared helper, and introduces a
couple of other checks to harden the kfunc release logic and prevent future
bugs. Some selftests are also included that fail in absence of these fixes,
serving as demonstration of the issues being fixed.

Changelog:
----------
v2 -> v3:
v2: https://lore.kernel.org/bpf/20220303045029.2645297-1-memxor@gmail.com

 * Add my SoB to __diag for clang patch (Nathan)

v1 -> v2:
v1: https://lore.kernel.org/bpf/20220301065745.1634848-1-memxor@gmail.com

 * Put reg->off check for release kfunc inside check_func_arg_reg_off,
   make the check a bit more readable
 * Squash verifier selftests errstr update into patch 3 for bisect (Alexei)
 * Include fix from Nathan for clang warning about missing prototypes
 * Add unified __diag_ingore_all that works for both GCC/LLVM (Alexei)

Older discussion:
Link: https://lore.kernel.org/bpf/20220219113744.1852259-1-memxor@gmail.com

Kumar Kartikeya Dwivedi (7):
  bpf: Add check_func_arg_reg_off function
  bpf: Fix PTR_TO_BTF_ID var_off check
  bpf: Disallow negative offset in check_ptr_off_reg
  bpf: Harden register offset checks for release helpers and kfuncs
  compiler_types.h: Add unified __diag_ignore_all for GCC/LLVM
  bpf: Replace __diag_ignore with unified __diag_ignore_all
  selftests/bpf: Add tests for kfunc register offset checks

Nathan Chancellor (1):
  compiler-clang.h: Add __diag infrastructure for clang

 include/linux/bpf_verifier.h                  |  4 +
 include/linux/compiler-clang.h                | 25 +++++
 include/linux/compiler-gcc.h                  |  3 +
 include/linux/compiler_types.h                |  4 +
 kernel/bpf/btf.c                              | 20 ++--
 kernel/bpf/verifier.c                         | 94 +++++++++++++------
 net/bpf/test_run.c                            | 15 ++-
 net/netfilter/nf_conntrack_bpf.c              |  5 +-
 .../selftests/bpf/verifier/bounds_deduction.c |  2 +-
 tools/testing/selftests/bpf/verifier/calls.c  | 83 ++++++++++++++++
 tools/testing/selftests/bpf/verifier/ctx.c    |  8 +-
 11 files changed, 220 insertions(+), 43 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-03-04 22:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04  0:05 [PATCH bpf-next v3 0/8] Fixes for bad PTR_TO_BTF_ID offset Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 1/8] bpf: Add check_func_arg_reg_off function Kumar Kartikeya Dwivedi
2022-03-04 20:15   ` Martin KaFai Lau
2022-03-04 20:54     ` Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 2/8] bpf: Fix PTR_TO_BTF_ID var_off check Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 3/8] bpf: Disallow negative offset in check_ptr_off_reg Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 4/8] bpf: Harden register offset checks for release helpers and kfuncs Kumar Kartikeya Dwivedi
2022-03-04 20:28   ` Martin KaFai Lau
2022-03-04 20:48     ` Kumar Kartikeya Dwivedi
2022-03-04 21:43       ` Martin KaFai Lau
2022-03-04 21:55         ` Kumar Kartikeya Dwivedi
2022-03-04 22:18           ` Martin KaFai Lau
2022-03-04 22:45             ` Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 5/8] compiler-clang.h: Add __diag infrastructure for clang Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 6/8] compiler_types.h: Add unified __diag_ignore_all for GCC/LLVM Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 7/8] bpf: Replace __diag_ignore with unified __diag_ignore_all Kumar Kartikeya Dwivedi
2022-03-04  0:05 ` [PATCH bpf-next v3 8/8] selftests/bpf: Add tests for kfunc register offset checks Kumar Kartikeya Dwivedi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).