Skip to content

Commit 63b9ab6

Browse files
jasowangdavem330
authored andcommitted
tuntap: properly align skb->head before building skb
An unaligned alloc_frag->offset caused by previous allocation will result an unaligned skb->head. This will lead unaligned skb_shared_info and then unaligned dataref which requires to be aligned for accessing on some architecture. Fix this by aligning alloc_frag->offset before the frag refilling. Fixes: 0bbd7da ("tun: make tun_build_skb() thread safe") Cc: Eric Dumazet <edumazet@google.com> Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Cc: Wei Wei <dotweiba@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Mark Rutland <mark.rutland@arm.com> Reported-by: Wei Wei <dotweiba@gmail.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8ab190f commit 63b9ab6

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/net/tun.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
12861286
buflen += SKB_DATA_ALIGN(len + pad);
12871287
rcu_read_unlock();
12881288

1289+
alloc_frag->offset = ALIGN((u64)alloc_frag->offset, SMP_CACHE_BYTES);
12891290
if (unlikely(!skb_page_frag_refill(buflen, alloc_frag, GFP_KERNEL)))
12901291
return ERR_PTR(-ENOMEM);
12911292

0 commit comments

Comments
 (0)