Skip to content

Commit 718ccdb

Browse files
Alexander Duyckgregkh
authored andcommitted
net: Do not allocate page fragments that are not skb aligned
[ Upstream commit 3bed3cc ] 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: ffde732 ("net: Split netdev_alloc_frag into __alloc_page_frag and add __napi_alloc_frag") Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1bdb167 commit 718ccdb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎net/core/skbuff.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
353353
*/
354354
void *netdev_alloc_frag(unsigned int fragsz)
355355
{
356+
fragsz = SKB_DATA_ALIGN(fragsz);
357+
356358
return __netdev_alloc_frag(fragsz, GFP_ATOMIC);
357359
}
358360
EXPORT_SYMBOL(netdev_alloc_frag);
@@ -366,6 +368,8 @@ static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
366368

367369
void *napi_alloc_frag(unsigned int fragsz)
368370
{
371+
fragsz = SKB_DATA_ALIGN(fragsz);
372+
369373
return __napi_alloc_frag(fragsz, GFP_ATOMIC);
370374
}
371375
EXPORT_SYMBOL(napi_alloc_frag);

0 commit comments

Comments
 (0)