From: Sherry Yang <sherry.yang@oracle.com>
To: stable@vger.kernel.org
Cc: sashal@kernel.org, kuba@kernel.org, gregkh@linuxfoundation.org,
roopa@nvidia.com, nikolay@nvidia.com, davem@davemloft.net,
bridge@lists.linux-foundation.org, netdev@vger.kernel.org,
sherry.yang@oracle.com
Subject: [PATCH 5.15.y 1/2] net: add pskb_may_pull_reason() helper
Date: Fri, 4 Oct 2024 10:03:27 -0700 [thread overview]
Message-ID: <20241004170328.10819-2-sherry.yang@oracle.com> (raw)
In-Reply-To: <20241004170328.10819-1-sherry.yang@oracle.com>
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit 1fb2d41501f38192d8a19da585cd441cf8845697 ]
pskb_may_pull() can fail for two different reasons.
Provide pskb_may_pull_reason() helper to distinguish
between these reasons.
It returns:
SKB_NOT_DROPPED_YET : Success
SKB_DROP_REASON_PKT_TOO_SMALL : packet too small
SKB_DROP_REASON_NOMEM : skb->head could not be resized
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 8bd67ebb50c0 ("net: bridge: xmit: make sure we have at least eth header len bytes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
[Sherry: bp to 5.15.y. Minor conflicts due to missing commit
d427c8999b07 ("net-next: skbuff: refactor pskb_pull") which is not
necessary in 5.15.y. Ignore context change.
Signed-off-by: Sherry Yang <sherry.yang@oracle.com>
---
include/linux/skbuff.h | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b230c422dc3b..f92e8fe4f5eb 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2465,13 +2465,24 @@ static inline void *pskb_pull(struct sk_buff *skb, unsigned int len)
return unlikely(len > skb->len) ? NULL : __pskb_pull(skb, len);
}
-static inline bool pskb_may_pull(struct sk_buff *skb, unsigned int len)
+static inline enum skb_drop_reason
+pskb_may_pull_reason(struct sk_buff *skb, unsigned int len)
{
if (likely(len <= skb_headlen(skb)))
- return true;
+ return SKB_NOT_DROPPED_YET;
+
if (unlikely(len > skb->len))
- return false;
- return __pskb_pull_tail(skb, len - skb_headlen(skb)) != NULL;
+ return SKB_DROP_REASON_PKT_TOO_SMALL;
+
+ if (unlikely(!__pskb_pull_tail(skb, len - skb_headlen(skb))))
+ return SKB_DROP_REASON_NOMEM;
+
+ return SKB_NOT_DROPPED_YET;
+}
+
+static inline bool pskb_may_pull(struct sk_buff *skb, unsigned int len)
+{
+ return pskb_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET;
}
void skb_condense(struct sk_buff *skb);
--
2.46.0
next prev parent reply other threads:[~2024-10-04 17:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 17:03 [PATCH 5.15.y 0/2] Backport fix for CVE-2024-38538 Sherry Yang
2024-10-04 17:03 ` Sherry Yang [this message]
2024-10-08 10:36 ` [PATCH 5.15.y 1/2] net: add pskb_may_pull_reason() helper Greg KH
2024-10-08 17:11 ` Sherry Yang
2024-10-04 17:03 ` [PATCH 5.15.y 2/2] net: bridge: xmit: make sure we have at least eth header len bytes Sherry Yang
2024-10-29 21:14 ` [PATCH 5.15.y] " Randy.MacLeod
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241004170328.10819-2-sherry.yang@oracle.com \
--to=sherry.yang@oracle.com \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=roopa@nvidia.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).