bpf, tnums: Warn against the usage of tnum_in(tnum_range(), ...)
authorShung-Hsi Yu <shung-hsi.yu@suse.com>
Wed, 31 Aug 2022 03:19:06 +0000 (11:19 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 2 Sep 2022 12:44:54 +0000 (14:44 +0200)
commitdc84dbbcc97bfb47e0f2b175d816e601b2890c91
treea96811c55eb447b29bdc93c127fddc5bf1c82930
parentef331a8d4c0061ea4d353cd0db1c9b33fd45f0f2
bpf, tnums: Warn against the usage of tnum_in(tnum_range(), ...)

Commit a657182a5c51 ("bpf: Don't use tnum_range on array range checking
for poke descriptors") has shown that using tnum_range() as argument to
tnum_in() can lead to misleading code that looks like tight bound check
when in fact the actual allowed range is much wider.

Document such behavior to warn against its usage in general, and suggest
some scenario where result can be trusted.

Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/984b37f9fdf7ac36831d2137415a4a915744c1b6.1661462653.git.daniel@iogearbox.net
Link: https://www.openwall.com/lists/oss-security/2022/08/26/1
Link: https://lore.kernel.org/bpf/20220831031907.16133-3-shung-hsi.yu@suse.com
Link: https://lore.kernel.org/bpf/20220831031907.16133-2-shung-hsi.yu@suse.com
include/linux/tnum.h