tuntap: properly align skb->head before building skb
Subsystems (3)
PATCH v2 1/1 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.
---
- The patch is needed for -stable.
- Wei, can you try this patch to see if it solves your issue?
--- drivers/net/tun.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/tun.c +1 -0
@@ -1286,6 +1286,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, buflen +=SKB_DATA_ALIGN (len + pad);rcu_read_unlock (); + alloc_frag->offset =ALIGN ((u64 )alloc_frag->offset,SMP_CACHE_BYTES );if (unlikely (!skb_page_frag_refill (buflen, alloc_frag,GFP_KERNEL )))return ERR_PTR (-ENOMEM );
Signature · 1 line
2.7.4
From: Jason Wang <[email protected]>
Date: Fri, 27 Oct 2017 11:05:44 +0800
Quoted 6 lines
An unaligned
alloc_frag->offsetcaused by previous allocation will result an unalignedskb->head. This will lead unalignedskb_shared_infoand then unaligned dataref which requires to be aligned for accessing on some architecture. Fix this by aligningalloc_frag->offsetbefore the frag refilling.
Quoted 8 lines
Fixes 0bbd7dad34f8 ("tun: make tun_build_skb() thread safe")Cc Eric Dumazet <[email protected]>Cc Willem de Bruijn <[email protected]>Cc Wei Wei <[email protected]>Cc Dmitry Vyukov <[email protected]>Cc Mark Rutland <[email protected]>Reported-by Wei Wei <[email protected]>Signed-off-by Jason Wang <[email protected]>
Applied and queued up for -stable, thanks Jason.
With this patch, the crash can’t be reproduced with the syz-repro and crash log0/log1.
The auto-generated reproducers are here:
https://github.com/dotweiba/skb_clone_atomic_inc_bug
Thanks,
Wei
Quoted 21 lines · David Miller
From: Jason Wang <[email protected]>
Date: Fri, 27 Oct 2017 11:05:44 +0800Quoted 6 lines
An unaligned
alloc_frag->offsetcaused by previous allocation will result an unalignedskb->head. This will lead unalignedskb_shared_infoand then unaligned dataref which requires to be aligned for accessing on some architecture. Fix this by aligningalloc_frag->offsetbefore the frag refilling.Quoted 8 lines
Fixes 0bbd7dad34f8 ("tun: make tun_build_skb() thread safe")Cc Eric Dumazet <[email protected]>Cc Willem de Bruijn <[email protected]>Cc Wei Wei <[email protected]>Cc Dmitry Vyukov <[email protected]>Cc Mark Rutland <[email protected]>Reported-by Wei Wei <[email protected]>Signed-off-by Jason Wang <[email protected]>Applied and queued up for -stable, thanks Jason.