Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Eelco Chaudron <echaudro@redhat.com>
To: stable@vger.kernel.org
Cc: aconole@redhat.com, echaudro@redhat.com, i.maximets@ovn.org
Subject: [PATCH 5.4.y] openvswitch: Fix unsafe attribute parsing in output_userspace()
Date: Mon, 12 May 2025 10:46:22 +0200	[thread overview]
Message-ID: <b047b86872e58e15c3b8d3ba394fa1aef4b557ea.1747039582.git.echaudro@redhat.com> (raw)
In-Reply-To: <2025050913-rubble-confirm-99ee@gregkh>

This patch replaces the manual Netlink attribute iteration in
output_userspace() with nla_for_each_nested(), which ensures that only
well-formed attributes are processed.

Fixes: ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
Link: https://patch.msgid.link/0bd65949df61591d9171c0dc13e42cea8941da10.1746541734.git.echaudro@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 6beb6835c1fbb3f676aebb51a5fee6b77fed9308)

---
The patch did not apply cleanly due to a previously applied style
fix that corrected indentation in the original for loop. This
patch has been adjusted accordingly to account for that change.
---
 net/openvswitch/actions.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 815a55fa7356..5af7fe6312cf 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -967,8 +967,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
 	upcall.cmd = OVS_PACKET_CMD_ACTION;
 	upcall.mru = OVS_CB(skb)->mru;
 
-	for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
-		 a = nla_next(a, &rem)) {
+	nla_for_each_nested(a, attr, rem) {
 		switch (nla_type(a)) {
 		case OVS_USERSPACE_ATTR_USERDATA:
 			upcall.userdata = a;
-- 
2.47.1


  reply	other threads:[~2025-05-12  8:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09  8:56 FAILED: patch "[PATCH] openvswitch: Fix unsafe attribute parsing in" failed to apply to 5.4-stable tree gregkh
2025-05-12  8:46 ` Eelco Chaudron [this message]
2025-05-12 21:52   ` [PATCH 5.4.y] openvswitch: Fix unsafe attribute parsing in output_userspace() Sasha Levin
2025-05-13  6:49     ` Eelco Chaudron
2025-05-12  8:50 ` FAILED: patch "[PATCH] openvswitch: Fix unsafe attribute parsing in" failed to apply to 5.4-stable tree Eelco Chaudron

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=b047b86872e58e15c3b8d3ba394fa1aef4b557ea.1747039582.git.echaudro@redhat.com \
    --to=echaudro@redhat.com \
    --cc=aconole@redhat.com \
    --cc=i.maximets@ovn.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