|
@@ -1794,7 +1794,7 @@ struct redirect_info {
|
|
|
u32 flags;
|
|
|
struct bpf_map *map;
|
|
|
struct bpf_map *map_to_flush;
|
|
|
- const struct bpf_prog *map_owner;
|
|
|
+ unsigned long map_owner;
|
|
|
};
|
|
|
|
|
|
static DEFINE_PER_CPU(struct redirect_info, redirect_info);
|
|
@@ -2500,11 +2500,17 @@ void xdp_do_flush_map(void)
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(xdp_do_flush_map);
|
|
|
|
|
|
+static inline bool xdp_map_invalid(const struct bpf_prog *xdp_prog,
|
|
|
+ unsigned long aux)
|
|
|
+{
|
|
|
+ return (unsigned long)xdp_prog->aux != aux;
|
|
|
+}
|
|
|
+
|
|
|
static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
|
|
|
struct bpf_prog *xdp_prog)
|
|
|
{
|
|
|
struct redirect_info *ri = this_cpu_ptr(&redirect_info);
|
|
|
- const struct bpf_prog *map_owner = ri->map_owner;
|
|
|
+ unsigned long map_owner = ri->map_owner;
|
|
|
struct bpf_map *map = ri->map;
|
|
|
struct net_device *fwd = NULL;
|
|
|
u32 index = ri->ifindex;
|
|
@@ -2512,9 +2518,9 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
|
|
|
|
|
|
ri->ifindex = 0;
|
|
|
ri->map = NULL;
|
|
|
- ri->map_owner = NULL;
|
|
|
+ ri->map_owner = 0;
|
|
|
|
|
|
- if (unlikely(map_owner != xdp_prog)) {
|
|
|
+ if (unlikely(xdp_map_invalid(xdp_prog, map_owner))) {
|
|
|
err = -EFAULT;
|
|
|
map = NULL;
|
|
|
goto err;
|
|
@@ -2574,7 +2580,7 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb,
|
|
|
struct bpf_prog *xdp_prog)
|
|
|
{
|
|
|
struct redirect_info *ri = this_cpu_ptr(&redirect_info);
|
|
|
- const struct bpf_prog *map_owner = ri->map_owner;
|
|
|
+ unsigned long map_owner = ri->map_owner;
|
|
|
struct bpf_map *map = ri->map;
|
|
|
struct net_device *fwd = NULL;
|
|
|
u32 index = ri->ifindex;
|
|
@@ -2583,10 +2589,10 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb,
|
|
|
|
|
|
ri->ifindex = 0;
|
|
|
ri->map = NULL;
|
|
|
- ri->map_owner = NULL;
|
|
|
+ ri->map_owner = 0;
|
|
|
|
|
|
if (map) {
|
|
|
- if (unlikely(map_owner != xdp_prog)) {
|
|
|
+ if (unlikely(xdp_map_invalid(xdp_prog, map_owner))) {
|
|
|
err = -EFAULT;
|
|
|
map = NULL;
|
|
|
goto err;
|
|
@@ -2632,7 +2638,7 @@ BPF_CALL_2(bpf_xdp_redirect, u32, ifindex, u64, flags)
|
|
|
ri->ifindex = ifindex;
|
|
|
ri->flags = flags;
|
|
|
ri->map = NULL;
|
|
|
- ri->map_owner = NULL;
|
|
|
+ ri->map_owner = 0;
|
|
|
|
|
|
return XDP_REDIRECT;
|
|
|
}
|
|
@@ -2646,7 +2652,7 @@ static const struct bpf_func_proto bpf_xdp_redirect_proto = {
|
|
|
};
|
|
|
|
|
|
BPF_CALL_4(bpf_xdp_redirect_map, struct bpf_map *, map, u32, ifindex, u64, flags,
|
|
|
- const struct bpf_prog *, map_owner)
|
|
|
+ unsigned long, map_owner)
|
|
|
{
|
|
|
struct redirect_info *ri = this_cpu_ptr(&redirect_info);
|
|
|
|