Message ID | 20231018145244.591454-1-artem.chernyshev@red-soft.ru (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | nfp: bpf: offload: Check prog before dereference | expand |
On Wed, 18 Oct 2023 17:52:44 +0300 Artem Chernyshev wrote: > In nfp_net_bpf_offload() it is possible to dereference a > NULL pointer. And who would call this function with prog = NULL if old_prog is also NULL, exactly?
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/offload.c b/drivers/net/ethernet/netronome/nfp/bpf/offload.c index 9d97cd281f18..925862f7b7d6 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/offload.c +++ b/drivers/net/ethernet/netronome/nfp/bpf/offload.c @@ -598,8 +598,7 @@ int nfp_net_bpf_offload(struct nfp_net *nn, struct bpf_prog *prog, if (old_prog && !prog) return nfp_net_bpf_stop(nn); - err = nfp_net_bpf_load(nn, prog, extack); - if (err) + if (prog && (err = nfp_net_bpf_load(nn, prog, extack))) return err; if (!old_prog)
In nfp_net_bpf_offload() it is possible to dereference a NULL pointer. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> --- drivers/net/ethernet/netronome/nfp/bpf/offload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)