Skip to content

Commit fff8803

Browse files
wdebruijdavem330
authored andcommitted
skbuff: only inherit relevant tx_flags
When inheriting tx_flags from one skbuff to another, always apply a mask to avoid overwriting unrelated other bits in the field. The two SKBTX_SHARED_FRAG cases clears all other bits. In practice, tx_flags are zero at this point now. But this is fragile. Timestamp flags are set, for instance, if in tcp_gso_segment, after this clear in skb_segment. The SKBTX_ANY_TSTAMP mask in __skb_tstamp_tx ensures that new skbs do not accidentally inherit flags such as SKBTX_SHARED_FRAG. Signed-off-by: Willem de Bruijn <[email protected]> Acked-by: Soheil Hassas Yeganeh <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 50430d1 commit fff8803

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

net/core/skbuff.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,8 @@ void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
26462646
{
26472647
int pos = skb_headlen(skb);
26482648

2649-
skb_shinfo(skb1)->tx_flags = skb_shinfo(skb)->tx_flags & SKBTX_SHARED_FRAG;
2649+
skb_shinfo(skb1)->tx_flags |= skb_shinfo(skb)->tx_flags &
2650+
SKBTX_SHARED_FRAG;
26502651
if (len < pos) /* Split line is inside header. */
26512652
skb_split_inside_header(skb, skb1, len, pos);
26522653
else /* Second chunk has no header, nothing to copy. */
@@ -3261,8 +3262,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
32613262
skb_copy_from_linear_data_offset(head_skb, offset,
32623263
skb_put(nskb, hsize), hsize);
32633264

3264-
skb_shinfo(nskb)->tx_flags = skb_shinfo(head_skb)->tx_flags &
3265-
SKBTX_SHARED_FRAG;
3265+
skb_shinfo(nskb)->tx_flags |= skb_shinfo(head_skb)->tx_flags &
3266+
SKBTX_SHARED_FRAG;
32663267

32673268
while (pos < offset + len) {
32683269
if (i >= nfrags) {
@@ -3948,7 +3949,8 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
39483949
return;
39493950

39503951
if (tsonly) {
3951-
skb_shinfo(skb)->tx_flags = skb_shinfo(orig_skb)->tx_flags;
3952+
skb_shinfo(skb)->tx_flags |= skb_shinfo(orig_skb)->tx_flags &
3953+
SKBTX_ANY_TSTAMP;
39523954
skb_shinfo(skb)->tskey = skb_shinfo(orig_skb)->tskey;
39533955
}
39543956

0 commit comments

Comments
 (0)