bpf: Do not follow __iomem pointers
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | compiler_types: Emit a BTF type tag for __iomeminclude/ | +1 | 0 replies | |
| 2/3 | bpf: Treat __iomem pointers as scalarskernel/ | +15 | 1 reply | |
| 3/3 | selftests/bpf: Test loads through __iomem pointerstools/ tools/ tools/ | +119 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf-next v1 0/3] bpf: Do not follow __iomem pointers
A BPF tracing program can read a device register with a plain field walk, for example mdev->common->device_status through a
struct virtio_pci_common_cfg __iomem *. The load is a PROBE_MEM load of a mapped address, so it does not fault and reads the register. Such a read can have side effects. This came up in the discussion of [1].
Patch 1 gives __iomem a BTF type tag, as __user, __percpu and __rcu have. Patch 2 makes the verifier hand out a scalar for a struct member, function argument or return value with that tag, so a program cannot load through it. Patch 3 adds selftests.
[1]: https://lore.kernel.org/bpf/[email protected]/
Kumar Kartikeya Dwivedi (3):
compiler_types: Emit a BTF type tag for __iomem
bpf: Treat __iomem pointers as scalars selftests/bpf: Test loads through __iomem pointers
include/linux/compiler_types.h | 2 +- kernel/bpf/btf.c | 15 +++++ .../selftests/bpf/prog_tests/btf_tag.c | 55 +++++++++++++++++++ .../selftests/bpf/progs/btf_type_tag_iomem.c | 49 +++++++++++++++++ .../selftests/bpf/test_kmods/bpf_testmod.c | 15 +++++ 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/bpf/progs/btf_type_tag_iomem.c
base-commit: 71ad211eb086d0f8fc7ae595a37943bed58cad6f
Signature · 1 line
2.53.1-Meta