[PATCH net-next v2] netmem: fix skb_frag_address_safe with unreadable skbs

From: Mina Almasry
Date: Thu Jun 19 2025 - 13:53:06 EST


skb_frag_address_safe() needs a check that the
skb_frag_page exists check similar to skb_frag_address().

Cc: ap420073@xxxxxxxxx

Signed-off-by: Mina Almasry <almasrymina@xxxxxxxxxx>
Acked-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>

---

v2: https://lore.kernel.org/netdev/20250617210950.1338107-1-almasrymina@xxxxxxxxxx/

- Move to net-next
- save return value of skb_frag_page
---
include/linux/skbuff.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9508968cb300..4f6dcb37bae8 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3665,7 +3665,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;


base-commit: afc783fa0aab9cc093fbb04871bfda406480cf8d
--
2.50.0.rc2.701.gf1e915cc24-goog