]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Undo ptr_to_map_key alu sanitation for now
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 25 Mar 2021 23:41:34 +0000 (00:41 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 25 Mar 2021 23:46:33 +0000 (00:46 +0100)
commitd640ba07f57094b84bf024589245bd9185ab01af
tree97200006ffd0bc26939823b4c5624a612384e2dd
parent03d83c4d72a523db35a1a98ff83b5428d3c8a8fc
bpf: Undo ptr_to_map_key alu sanitation for now

Remove PTR_TO_MAP_KEY for the time being from being sanitized on pointer ALU
through sanitize_ptr_alu() mainly for 3 reasons:

  1) It's currently unused and not available from unprivileged. However that by
     itself is not yet a strong reason to drop the code.

  2) Commit 1ddf7323058b ("bpf: Add bpf_for_each_map_elem() helper") implemented
     the sanitation not fully correct in that unlike stack or map_value pointer
     it doesn't probe whether the access to the map key /after/ the simulated ALU
     operation is still in bounds. This means that the generated mask can truncate
     the offset in the non-speculative domain whereas it should only truncate in
     the speculative domain. The verifier should instead reject such program as
     we do for other types.

  3) Given the recent fixes from 8c1b4125b15a ("bpf: Prohibit alu ops for pointer
     types not defining ptr_limit"), b2631adf4388 ("bpf: Fix off-by-one for area
     size in creating mask to left"), a7dd0407d356 ("bpf: Simplify alu_limit masking
     for pointer arithmetic") as well as 655c072dd1ca ("bpf: Add sanity check for
     upper ptr_limit") the code changed quite a bit and the merge in 38dea5c73602
     broke the PTR_TO_MAP_KEY case due to an incorrect merge conflict.

Remove the relevant pieces for the time being and we can rework the PTR_TO_MAP_KEY
case once everything settles.

Fixes: 38dea5c73602 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
Fixes: 1ddf7323058b ("bpf: Add bpf_for_each_map_elem() helper")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/verifier.c