Skip to content

Commit 2ef22bd

Browse files
wdebruijgregkh
authored andcommitted
net: test tailroom before appending to linear skb
[ Upstream commit 113f99c ] Device features may change during transmission. In particular with corking, a device may toggle scatter-gather in between allocating and writing to an skb. Do not unconditionally assume that !NETIF_F_SG at write time implies that the same held at alloc time and thus the skb has sufficient tailroom. This issue predates git history. Fixes: 1da177e ("Linux-2.6.12-rc2") Reported-by: Eric Dumazet <[email protected]> Signed-off-by: Willem de Bruijn <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 97b7270 commit 2ef22bd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/ipv4/ip_output.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,8 @@ static int __ip_append_data(struct sock *sk,
10761076
if (copy > length)
10771077
copy = length;
10781078

1079-
if (!(rt->dst.dev->features&NETIF_F_SG)) {
1079+
if (!(rt->dst.dev->features&NETIF_F_SG) &&
1080+
skb_tailroom(skb) >= copy) {
10801081
unsigned int off;
10811082

10821083
off = skb->len;

net/ipv6/ip6_output.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,8 @@ static int __ip6_append_data(struct sock *sk,
15451545
if (copy > length)
15461546
copy = length;
15471547

1548-
if (!(rt->dst.dev->features&NETIF_F_SG)) {
1548+
if (!(rt->dst.dev->features&NETIF_F_SG) &&
1549+
skb_tailroom(skb) >= copy) {
15491550
unsigned int off;
15501551

15511552
off = skb->len;

0 commit comments

Comments
 (0)