Skip to content

Commit 3ba3458

Browse files
Jakub Sitnickidavem330
Jakub Sitnicki
authored andcommitted
ipv6: Count in extension headers in skb->network_header
When sending a UDPv6 message longer than MTU, account for the length of fragmentable IPv6 extension headers in skb->network_header offset. Same as we do in alloc_new_skb path in __ip6_append_data(). This ensures that later on __ip6_make_skb() will make space in headroom for fragmentable extension headers: /* move skb->data to ip header from ext header */ if (skb->data < skb_network_header(skb)) __skb_pull(skb, skb_network_offset(skb)); Prevents a splat due to skb_under_panic: skbuff: skb_under_panic: text:ffffffff8143397b len:2126 put:14 \ head:ffff880005bacf50 data:ffff880005bacf4a tail:0x48 end:0xc0 dev:lo ------------[ cut here ]------------ kernel BUG at net/core/skbuff.c:104! invalid opcode: 0000 [#1] KASAN CPU: 0 PID: 160 Comm: reproducer Not tainted 4.6.0-rc2 #65 [...] Call Trace: [<ffffffff813eb7b9>] skb_push+0x79/0x80 [<ffffffff8143397b>] eth_header+0x2b/0x100 [<ffffffff8141e0d0>] neigh_resolve_output+0x210/0x310 [<ffffffff814eab77>] ip6_finish_output2+0x4a7/0x7c0 [<ffffffff814efe3a>] ip6_output+0x16a/0x280 [<ffffffff815440c1>] ip6_local_out+0xb1/0xf0 [<ffffffff814f1115>] ip6_send_skb+0x45/0xd0 [<ffffffff81518836>] udp_v6_send_skb+0x246/0x5d0 [<ffffffff8151985e>] udpv6_sendmsg+0xa6e/0x1090 [...] Reported-by: Ji Jianwen <[email protected]> Signed-off-by: Jakub Sitnicki <[email protected]> Acked-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 579ba85 commit 3ba3458

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/ipv6/ip6_output.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
10901090
int getfrag(void *from, char *to, int offset, int len,
10911091
int odd, struct sk_buff *skb),
10921092
void *from, int length, int hh_len, int fragheaderlen,
1093-
int transhdrlen, int mtu, unsigned int flags,
1094-
const struct flowi6 *fl6)
1093+
int exthdrlen, int transhdrlen, int mtu,
1094+
unsigned int flags, const struct flowi6 *fl6)
10951095

10961096
{
10971097
struct sk_buff *skb;
@@ -1116,7 +1116,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
11161116
skb_put(skb, fragheaderlen + transhdrlen);
11171117

11181118
/* initialize network header pointer */
1119-
skb_reset_network_header(skb);
1119+
skb_set_network_header(skb, exthdrlen);
11201120

11211121
/* initialize protocol header pointer */
11221122
skb->transport_header = skb->network_header + fragheaderlen;
@@ -1358,7 +1358,7 @@ static int __ip6_append_data(struct sock *sk,
13581358
(rt->dst.dev->features & NETIF_F_UFO) &&
13591359
(sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) {
13601360
err = ip6_ufo_append_data(sk, queue, getfrag, from, length,
1361-
hh_len, fragheaderlen,
1361+
hh_len, fragheaderlen, exthdrlen,
13621362
transhdrlen, mtu, flags, fl6);
13631363
if (err)
13641364
goto error;

0 commit comments

Comments
 (0)