]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
xdp: use trusted arguments in XDP hints kfuncs
authorLarysa Zaremba <larysa.zaremba@intel.com>
Tue, 11 Jul 2023 10:59:26 +0000 (12:59 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 12 Jul 2023 03:04:50 +0000 (20:04 -0700)
commit2e06c57d66d3f6c26faa5f5b479fb3add34ce85a
treed70babf18e228ab93441c2fccbb916e6caf85e17
parent4369016497319a9635702da010d02af1ebb1849d
xdp: use trusted arguments in XDP hints kfuncs

Currently, verifier does not reject XDP programs that pass NULL pointer to
hints functions. At the same time, this case is not handled in any driver
implementation (including veth). For example, changing

bpf_xdp_metadata_rx_timestamp(ctx, &timestamp);

to

bpf_xdp_metadata_rx_timestamp(ctx, NULL);

in xdp_metadata test successfully crashes the system.

Add KF_TRUSTED_ARGS flag to hints kfunc definitions, so driver code
does not have to worry about getting invalid pointers.

Fixes: 3d76a4d3d4e5 ("bpf: XDP metadata RX kfuncs")
Reported-by: Stanislav Fomichev <sdf@google.com>
Closes: https://lore.kernel.org/bpf/ZKWo0BbpLfkZHbyE@google.com/
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/20230711105930.29170-1-larysa.zaremba@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/core/xdp.c