From: Mina Almasry Date: Thu, 19 Jun 2025 17:52:38 +0000 (+0000) Subject: netmem: fix skb_frag_address_safe with unreadable skbs X-Git-Tag: v6.16.2~253 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cbdc9ea044156b669f59c0ac0b7cf1c62a189a96;p=thirdparty%2Fkernel%2Fstable.git netmem: fix skb_frag_address_safe with unreadable skbs [ Upstream commit 4672aec56d2e8edabcb74c3e2320301d106a377e ] skb_frag_address_safe() needs a check that the skb_frag_page exists check similar to skb_frag_address(). Cc: ap420073@gmail.com Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev Link: https://patch.msgid.link/20250619175239.3039329-1-almasrymina@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 37f5c6099b1fb..67a906702830c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3688,7 +3688,13 @@ static inline void *skb_frag_address(const skb_frag_t *frag) */ static inline void *skb_frag_address_safe(const skb_frag_t *frag) { - void *ptr = page_address(skb_frag_page(frag)); + struct page *page = skb_frag_page(frag); + void *ptr; + + if (!page) + return NULL; + + ptr = page_address(page); if (unlikely(!ptr)) return NULL;