Commit 1afaf661 authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

bpf: remove type arg from __is_valid_{,xdp_}access

Commit d691f9e8 ("bpf: allow programs to write to certain skb
fields") pushed access type check outside of __is_valid_access()
to have different restrictions for socket filters and tc programs.
type is thus not used anymore within __is_valid_access() and should
be removed as a function argument. Same for __is_valid_xdp_access()
introduced by 6a773a15 ("bpf: add XDP prog type for early driver
filter").
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 70f23a80
...@@ -2748,7 +2748,7 @@ lwt_xmit_func_proto(enum bpf_func_id func_id) ...@@ -2748,7 +2748,7 @@ lwt_xmit_func_proto(enum bpf_func_id func_id)
} }
} }
static bool __is_valid_access(int off, int size, enum bpf_access_type type) static bool __is_valid_access(int off, int size)
{ {
if (off < 0 || off >= sizeof(struct __sk_buff)) if (off < 0 || off >= sizeof(struct __sk_buff))
return false; return false;
...@@ -2782,7 +2782,7 @@ static bool sk_filter_is_valid_access(int off, int size, ...@@ -2782,7 +2782,7 @@ static bool sk_filter_is_valid_access(int off, int size,
} }
} }
return __is_valid_access(off, size, type); return __is_valid_access(off, size);
} }
static bool lwt_is_valid_access(int off, int size, static bool lwt_is_valid_access(int off, int size,
...@@ -2815,7 +2815,7 @@ static bool lwt_is_valid_access(int off, int size, ...@@ -2815,7 +2815,7 @@ static bool lwt_is_valid_access(int off, int size,
break; break;
} }
return __is_valid_access(off, size, type); return __is_valid_access(off, size);
} }
static bool sock_filter_is_valid_access(int off, int size, static bool sock_filter_is_valid_access(int off, int size,
...@@ -2833,11 +2833,9 @@ static bool sock_filter_is_valid_access(int off, int size, ...@@ -2833,11 +2833,9 @@ static bool sock_filter_is_valid_access(int off, int size,
if (off < 0 || off + size > sizeof(struct bpf_sock)) if (off < 0 || off + size > sizeof(struct bpf_sock))
return false; return false;
/* The verifier guarantees that size > 0. */ /* The verifier guarantees that size > 0. */
if (off % size != 0) if (off % size != 0)
return false; return false;
if (size != sizeof(__u32)) if (size != sizeof(__u32))
return false; return false;
...@@ -2910,11 +2908,10 @@ static bool tc_cls_act_is_valid_access(int off, int size, ...@@ -2910,11 +2908,10 @@ static bool tc_cls_act_is_valid_access(int off, int size,
break; break;
} }
return __is_valid_access(off, size, type); return __is_valid_access(off, size);
} }
static bool __is_valid_xdp_access(int off, int size, static bool __is_valid_xdp_access(int off, int size)
enum bpf_access_type type)
{ {
if (off < 0 || off >= sizeof(struct xdp_md)) if (off < 0 || off >= sizeof(struct xdp_md))
return false; return false;
...@@ -2942,7 +2939,7 @@ static bool xdp_is_valid_access(int off, int size, ...@@ -2942,7 +2939,7 @@ static bool xdp_is_valid_access(int off, int size,
break; break;
} }
return __is_valid_xdp_access(off, size, type); return __is_valid_xdp_access(off, size);
} }
void bpf_warn_invalid_xdp_action(u32 act) void bpf_warn_invalid_xdp_action(u32 act)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment