Skip to content

Commit 1afaf66

Browse files
borkmanndavem330
authored andcommitted
bpf: remove type arg from __is_valid_{,xdp_}access
Commit d691f9e ("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 6a773a1 ("bpf: add XDP prog type for early driver filter"). Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 70f23a8 commit 1afaf66

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

net/core/filter.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ lwt_xmit_func_proto(enum bpf_func_id func_id)
27482748
}
27492749
}
27502750

2751-
static bool __is_valid_access(int off, int size, enum bpf_access_type type)
2751+
static bool __is_valid_access(int off, int size)
27522752
{
27532753
if (off < 0 || off >= sizeof(struct __sk_buff))
27542754
return false;
@@ -2782,7 +2782,7 @@ static bool sk_filter_is_valid_access(int off, int size,
27822782
}
27832783
}
27842784

2785-
return __is_valid_access(off, size, type);
2785+
return __is_valid_access(off, size);
27862786
}
27872787

27882788
static bool lwt_is_valid_access(int off, int size,
@@ -2815,7 +2815,7 @@ static bool lwt_is_valid_access(int off, int size,
28152815
break;
28162816
}
28172817

2818-
return __is_valid_access(off, size, type);
2818+
return __is_valid_access(off, size);
28192819
}
28202820

28212821
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,
28332833

28342834
if (off < 0 || off + size > sizeof(struct bpf_sock))
28352835
return false;
2836-
28372836
/* The verifier guarantees that size > 0. */
28382837
if (off % size != 0)
28392838
return false;
2840-
28412839
if (size != sizeof(__u32))
28422840
return false;
28432841

@@ -2910,11 +2908,10 @@ static bool tc_cls_act_is_valid_access(int off, int size,
29102908
break;
29112909
}
29122910

2913-
return __is_valid_access(off, size, type);
2911+
return __is_valid_access(off, size);
29142912
}
29152913

2916-
static bool __is_valid_xdp_access(int off, int size,
2917-
enum bpf_access_type type)
2914+
static bool __is_valid_xdp_access(int off, int size)
29182915
{
29192916
if (off < 0 || off >= sizeof(struct xdp_md))
29202917
return false;
@@ -2942,7 +2939,7 @@ static bool xdp_is_valid_access(int off, int size,
29422939
break;
29432940
}
29442941

2945-
return __is_valid_xdp_access(off, size, type);
2942+
return __is_valid_xdp_access(off, size);
29462943
}
29472944

29482945
void bpf_warn_invalid_xdp_action(u32 act)

0 commit comments

Comments
 (0)