mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 20:33:58 -04:00
UPSTREAM: bpf: Switch to offsetofend in BPF_PROG_TEST_RUN
Switch existing pattern of "offsetof(..., member) + FIELD_SIZEOF(..., member)' to "offsetofend(..., member)" which does exactly what we need without all the copy-paste. Suggested-by: Andrii Nakryiko <andriin@fb.com> Change-Id: I6e9b327aa527c9fa1a36a014a1f4c2c3b94931e9 Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20191210191933.105321-1-sdf@google.com
This commit is contained in:
parent
179b60379c
commit
b836b0e8e8
1 changed files with 4 additions and 8 deletions
|
|
@ -253,22 +253,19 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb)
|
|||
|
||||
/* priority is allowed */
|
||||
|
||||
if (!range_is_zero(__skb, offsetof(struct __sk_buff, priority) +
|
||||
FIELD_SIZEOF(struct __sk_buff, priority),
|
||||
if (!range_is_zero(__skb, offsetofend(struct __sk_buff, priority),
|
||||
offsetof(struct __sk_buff, cb)))
|
||||
return -EINVAL;
|
||||
|
||||
/* cb is allowed */
|
||||
|
||||
if (!range_is_zero(__skb, offsetof(struct __sk_buff, cb) +
|
||||
FIELD_SIZEOF(struct __sk_buff, cb),
|
||||
if (!range_is_zero(__skb, offsetofend(struct __sk_buff, cb),
|
||||
offsetof(struct __sk_buff, tstamp)))
|
||||
return -EINVAL;
|
||||
|
||||
/* tstamp is allowed */
|
||||
|
||||
if (!range_is_zero(__skb, offsetof(struct __sk_buff, tstamp) +
|
||||
FIELD_SIZEOF(struct __sk_buff, tstamp),
|
||||
if (!range_is_zero(__skb, offsetofend(struct __sk_buff, tstamp),
|
||||
sizeof(struct __sk_buff)))
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -438,8 +435,7 @@ static int verify_user_bpf_flow_keys(struct bpf_flow_keys *ctx)
|
|||
|
||||
/* flags is allowed */
|
||||
|
||||
if (!range_is_zero(ctx, offsetof(struct bpf_flow_keys, flags) +
|
||||
FIELD_SIZEOF(struct bpf_flow_keys, flags),
|
||||
if (!range_is_zero(ctx, offsetofend(struct bpf_flow_keys, flags),
|
||||
sizeof(struct bpf_flow_keys)))
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue