]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.20/net-do-not-allocate-page-fragments-that-are-not-skb-.patch
patches for 4.20
[thirdparty/kernel/stable-queue.git] / queue-4.20 / net-do-not-allocate-page-fragments-that-are-not-skb-.patch
1 From 3c6d703d0d1e3c1da2770f2c1e69b0ef3af62872 Mon Sep 17 00:00:00 2001
2 From: Alexander Duyck <alexander.h.duyck@linux.intel.com>
3 Date: Fri, 15 Feb 2019 14:44:18 -0800
4 Subject: net: Do not allocate page fragments that are not skb aligned
5
6 [ Upstream commit 3bed3cc4156eedf652b4df72bdb35d4f1a2a739d ]
7
8 This patch addresses the fact that there are drivers, specifically tun,
9 that will call into the network page fragment allocators with buffer sizes
10 that are not cache aligned. Doing this could result in data alignment
11 and DMA performance issues as these fragment pools are also shared with the
12 skb allocator and any other devices that will use napi_alloc_frags or
13 netdev_alloc_frags.
14
15 Fixes: ffde7328a36d ("net: Split netdev_alloc_frag into __alloc_page_frag and add __napi_alloc_frag")
16 Reported-by: Jann Horn <jannh@google.com>
17 Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 ---
21 net/core/skbuff.c | 4 ++++
22 1 file changed, 4 insertions(+)
23
24 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
25 index eebc3106d30ef..fc3d652a2de0c 100644
26 --- a/net/core/skbuff.c
27 +++ b/net/core/skbuff.c
28 @@ -353,6 +353,8 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
29 */
30 void *netdev_alloc_frag(unsigned int fragsz)
31 {
32 + fragsz = SKB_DATA_ALIGN(fragsz);
33 +
34 return __netdev_alloc_frag(fragsz, GFP_ATOMIC);
35 }
36 EXPORT_SYMBOL(netdev_alloc_frag);
37 @@ -366,6 +368,8 @@ static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
38
39 void *napi_alloc_frag(unsigned int fragsz)
40 {
41 + fragsz = SKB_DATA_ALIGN(fragsz);
42 +
43 return __napi_alloc_frag(fragsz, GFP_ATOMIC);
44 }
45 EXPORT_SYMBOL(napi_alloc_frag);
46 --
47 2.19.1
48