Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions net/bpf/test_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,11 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb)

if (__skb->gso_segs > GSO_MAX_SEGS)
return -EINVAL;

/* Currently GSO type is zero/unset. If this gets extended with
* a small list of accepted GSO types in future, the filter for
* an unset GSO type in bpf_clone_redirect() can be lifted.
*/
skb_shinfo(skb)->gso_segs = __skb->gso_segs;
skb_shinfo(skb)->gso_size = __skb->gso_size;
skb_shinfo(skb)->hwtstamps.hwtstamp = __skb->hwtstamp;
Expand Down
7 changes: 7 additions & 0 deletions net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,13 @@ BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags)
if (unlikely(flags & (~(BPF_F_INGRESS) | BPF_F_REDIRECT_INTERNAL)))
return -EINVAL;

/* BPF test infra's convert___skb_to_skb() can create type-less
* GSO packets. gso_features_check() will detect this as a bad
* offload. However, lets not leak them out in the first place.
*/
if (unlikely(skb_is_gso(skb) && !skb_shinfo(skb)->gso_type))
return -EBADMSG;

dev = dev_get_by_index_rcu(dev_net(skb->dev), ifindex);
if (unlikely(!dev))
return -EINVAL;
Expand Down
Loading