netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: ovs: prevent underflow in queue_userspace_packet()
@ 2025-01-24 14:49 Dan Carpenter
  2025-01-25  0:42 ` [ovs-dev] " Aaron Conole
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-01-24 14:49 UTC (permalink / raw)
  To: William Tu
  Cc: Pravin B Shelar, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, netdev, dev, linux-kernel,
	kernel-janitors

If "hlen" less than "cutlen" then when we call upcall_msg_size()
the "hlen - cutlen" parameter will be a very high positive
number.

Later in the function we use "skb->len - cutlen" but this change
addresses that potential underflow since skb->len is always going to
be greater than or equal to hlen.

Fixes: f2a4d086ed4c ("openvswitch: Add packet truncation support.")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
From code review not testing.

 net/openvswitch/datapath.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 225f6048867f..bb25a2bbe8a0 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -477,6 +477,11 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 	else
 		hlen = skb->len;
 
+	if (hlen < cutlen) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	len = upcall_msg_size(upcall_info, hlen - cutlen,
 			      OVS_CB(skb)->acts_origlen);
 	user_skb = genlmsg_new(len, GFP_ATOMIC);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-27  8:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24 14:49 [PATCH net] net: ovs: prevent underflow in queue_userspace_packet() Dan Carpenter
2025-01-25  0:42 ` [ovs-dev] " Aaron Conole
2025-01-27  8:08   ` Dan Carpenter

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).