]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
tun: fix tun_napi_alloc_frags() frag allocator
authorEric Dumazet <edumazet@google.com>
Thu, 15 Feb 2018 22:47:15 +0000 (14:47 -0800)
committerSeth Forshee <seth.forshee@canonical.com>
Wed, 28 Feb 2018 14:46:31 +0000 (08:46 -0600)
commitbf0c85204bd04cca87d2afd7f9c95f8946b8c95a
tree7529f3100fe4d94d13cd811e1f6ee4816ecc449e
parent2b60fd4fa978c0152c51d3d48de52f9ef5266af8
tun: fix tun_napi_alloc_frags() frag allocator

BugLink: http://bugs.launchpad.net/bugs/1752119
commit 43a08e0f58b3f236165029710a4e3b303815253b upstream.

<Mark Rutland reported>
    While fuzzing arm64 v4.16-rc1 with Syzkaller, I've been hitting a
    misaligned atomic in __skb_clone:

        atomic_inc(&(skb_shinfo(skb)->dataref));

   where dataref doesn't have the required natural alignment, and the
   atomic operation faults. e.g. i often see it aligned to a single
   byte boundary rather than a four byte boundary.

   AFAICT, the skb_shared_info is misaligned at the instant it's
   allocated in __napi_alloc_skb()  __napi_alloc_skb()
</end of report>

Problem is caused by tun_napi_alloc_frags() using
napi_alloc_frag() with user provided seg sizes,
leading to other users of this API getting unaligned
page fragments.

Since we would like to not necessarily add paddings or alignments to
the frags that tun_napi_alloc_frags() attaches to the skb, switch to
another page frag allocator.

As a bonus skb_page_frag_refill() can use GFP_KERNEL allocations,
meaning that we can not deplete memory reserves as easily.

Fixes: 90e33d459407 ("tun: enable napi_gro_frags() for TUN/TAP driver")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/net/tun.c