blob: 331e2a03e8f78d8b3af62ac52dfc14dc012d1190 [file] [log] [blame]
From 5637909d30f522e63b03d2e51845cdd8927919a5 Mon Sep 17 00:00:00 2001
From: Li RongQing <lirongqing@baidu.com>
Date: Fri, 10 Jan 2020 09:04:37 +0800
Subject: [PATCH] bpf: Return -EBADRQC for invalid map type in __bpf_tx_xdp_map
commit 0a29275b6300f39f78a87f2038bbfe5bdbaeca47 upstream.
A negative value should be returned if map->map_type is invalid
although that is impossible now, but if we run into such situation
in future, then xdpbuff could be leaked.
Daniel Borkmann suggested:
-EBADRQC should be returned to stay consistent with generic XDP
for the tracepoint output and not to be confused with -EOPNOTSUPP
from other locations like dev_map_enqueue() when ndo_xdp_xmit is
missing and such.
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/1578618277-18085-1-git-send-email-lirongqing@baidu.com
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/net/core/filter.c b/net/core/filter.c
index 1a4b72e1e7b5..afcaba2e051f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3543,7 +3543,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
return err;
}
default:
- break;
+ return -EBADRQC;
}
return 0;
}
--
2.7.4