Commit 315bc349 authored by Alexander Duyck's avatar Alexander Duyck Committed by Stefan Bader

net: Do not allocate page fragments that are not skb aligned

BugLink: https://bugs.launchpad.net/bugs/1818815

[ Upstream commit 3bed3cc4 ]

This patch addresses the fact that there are drivers, specifically tun,
that will call into the network page fragment allocators with buffer sizes
that are not cache aligned. Doing this could result in data alignment
and DMA performance issues as these fragment pools are also shared with the
skb allocator and any other devices that will use napi_alloc_frags or
netdev_alloc_frags.

Fixes: ffde7328 ("net: Split netdev_alloc_frag into __alloc_page_frag and add __napi_alloc_frag")
Reported-by: default avatarJann Horn <jannh@google.com>
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 7040b116
...@@ -382,6 +382,8 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask) ...@@ -382,6 +382,8 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
*/ */
void *netdev_alloc_frag(unsigned int fragsz) void *netdev_alloc_frag(unsigned int fragsz)
{ {
fragsz = SKB_DATA_ALIGN(fragsz);
return __netdev_alloc_frag(fragsz, GFP_ATOMIC | __GFP_COLD); return __netdev_alloc_frag(fragsz, GFP_ATOMIC | __GFP_COLD);
} }
EXPORT_SYMBOL(netdev_alloc_frag); EXPORT_SYMBOL(netdev_alloc_frag);
...@@ -395,6 +397,8 @@ static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask) ...@@ -395,6 +397,8 @@ static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
void *napi_alloc_frag(unsigned int fragsz) void *napi_alloc_frag(unsigned int fragsz)
{ {
fragsz = SKB_DATA_ALIGN(fragsz);
return __napi_alloc_frag(fragsz, GFP_ATOMIC | __GFP_COLD); return __napi_alloc_frag(fragsz, GFP_ATOMIC | __GFP_COLD);
} }
EXPORT_SYMBOL(napi_alloc_frag); EXPORT_SYMBOL(napi_alloc_frag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment