Skip to content

Commit 2e06c57

Browse files
walking-machineAlexei Starovoitov
authored andcommitted
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: 3d76a4d ("bpf: XDP metadata RX kfuncs") Reported-by: Stanislav Fomichev <[email protected]> Closes: https://lore.kernel.org/bpf/[email protected]/ Signed-off-by: Larysa Zaremba <[email protected]> Acked-by: Jesper Dangaard Brouer <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 4369016 commit 2e06c57

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/xdp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ __bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *hash,
741741
__diag_pop();
742742

743743
BTF_SET8_START(xdp_metadata_kfunc_ids)
744-
#define XDP_METADATA_KFUNC(_, name) BTF_ID_FLAGS(func, name, 0)
744+
#define XDP_METADATA_KFUNC(_, name) BTF_ID_FLAGS(func, name, KF_TRUSTED_ARGS)
745745
XDP_METADATA_KFUNC_xxx
746746
#undef XDP_METADATA_KFUNC
747747
BTF_SET8_END(xdp_metadata_kfunc_ids)

0 commit comments

Comments
 (0)