mirror of
https://github.com/torvalds/linux
synced 2024-10-07 03:42:55 +00:00
Merge branch 'minor-cleanups-to-skb-frag-ref-unref'
Mina Almasry says: ==================== Minor cleanups to skb frag ref/unref (part) This series is largely motivated by a recent discussion where there was some confusion on how to properly ref/unref pp pages vs non pp pages: https://lore.kernel.org/netdev/CAHS8izOoO-EovwMwAm9tLYetwikNPxC0FKyVGu1TPJWSz4bGoA@mail.gmail.com/T/#t There is some subtely there because pp uses page->pp_ref_count for refcounting, while non-pp uses get_page()/put_page() for ref counting. Getting the refcounting pairs wrong can lead to kernel crash. [...] https://lore.kernel.org/lkml/CAHS8izN436pn3SndrzsCyhmqvJHLyxgCeDpWXA4r1ANt3RCDLQ@mail.gmail.com/T/ ==================== Link: https://lore.kernel.org/r/20240408153000.2152844-1-almasrymina@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
811b836285
|
@ -3522,20 +3522,8 @@ int skb_cow_data_for_xdp(struct page_pool *pool, struct sk_buff **pskb,
|
|||
bool napi_pp_put_page(struct page *page);
|
||||
|
||||
static inline void
|
||||
skb_page_unref(const struct sk_buff *skb, struct page *page)
|
||||
skb_page_unref(struct page *page, bool recycle)
|
||||
{
|
||||
#ifdef CONFIG_PAGE_POOL
|
||||
if (skb->pp_recycle && napi_pp_put_page(page))
|
||||
return;
|
||||
#endif
|
||||
put_page(page);
|
||||
}
|
||||
|
||||
static inline void
|
||||
napi_frag_unref(skb_frag_t *frag, bool recycle)
|
||||
{
|
||||
struct page *page = skb_frag_page(frag);
|
||||
|
||||
#ifdef CONFIG_PAGE_POOL
|
||||
if (recycle && napi_pp_put_page(page))
|
||||
return;
|
||||
|
@ -3553,7 +3541,7 @@ napi_frag_unref(skb_frag_t *frag, bool recycle)
|
|||
*/
|
||||
static inline void __skb_frag_unref(skb_frag_t *frag, bool recycle)
|
||||
{
|
||||
napi_frag_unref(frag, recycle);
|
||||
skb_page_unref(skb_frag_page(frag), recycle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1101,7 +1101,7 @@ static void skb_release_data(struct sk_buff *skb, enum skb_drop_reason reason)
|
|||
}
|
||||
|
||||
for (i = 0; i < shinfo->nr_frags; i++)
|
||||
napi_frag_unref(&shinfo->frags[i], skb->pp_recycle);
|
||||
__skb_frag_unref(&shinfo->frags[i], skb->pp_recycle);
|
||||
|
||||
free_head:
|
||||
if (shinfo->frag_list)
|
||||
|
|
|
@ -114,7 +114,7 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb)
|
|||
*/
|
||||
if (req->src != req->dst)
|
||||
for (sg = sg_next(req->src); sg; sg = sg_next(sg))
|
||||
skb_page_unref(skb, sg_page(sg));
|
||||
skb_page_unref(sg_page(sg), skb->pp_recycle);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_INET_ESPINTCP
|
||||
|
|
|
@ -131,7 +131,7 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb)
|
|||
*/
|
||||
if (req->src != req->dst)
|
||||
for (sg = sg_next(req->src); sg; sg = sg_next(sg))
|
||||
skb_page_unref(skb, sg_page(sg));
|
||||
skb_page_unref(sg_page(sg), skb->pp_recycle);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_INET6_ESPINTCP
|
||||
|
|
Loading…
Reference in a new issue