public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: mptcp@lists.linux.dev, stable@vger.kernel.org,
	gregkh@linuxfoundation.org
Cc: Geliang Tang <tanggeliang@kylinos.cn>,
	sashal@kernel.org, Matthieu Baerts <matttbe@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH 6.6.y 4/6] mptcp: hold pm lock when deleting entry
Date: Mon, 18 Nov 2024 19:27:22 +0100	[thread overview]
Message-ID: <20241118182718.3011097-12-matttbe@kernel.org> (raw)
In-Reply-To: <20241118182718.3011097-8-matttbe@kernel.org>

From: Geliang Tang <tanggeliang@kylinos.cn>

commit f642c5c4d528d11bd78b6c6f84f541cd3c0bea86 upstream.

When traversing userspace_pm_local_addr_list and deleting an entry from
it in mptcp_pm_nl_remove_doit(), msk->pm.lock should be held.

This patch holds this lock before mptcp_userspace_pm_lookup_addr_by_id()
and releases it after list_move() in mptcp_pm_nl_remove_doit().

Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
Cc: stable@vger.kernel.org
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20241112-net-mptcp-misc-6-12-pm-v1-2-b835580cefa8@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_userspace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index e268f61d8eb0..8faf776cb977 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -324,14 +324,17 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
 
 	lock_sock(sk);
 
+	spin_lock_bh(&msk->pm.lock);
 	match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val);
 	if (!match) {
 		GENL_SET_ERR_MSG(info, "address with specified id not found");
+		spin_unlock_bh(&msk->pm.lock);
 		release_sock(sk);
 		goto remove_err;
 	}
 
 	list_move(&match->list, &free_list);
+	spin_unlock_bh(&msk->pm.lock);
 
 	mptcp_pm_remove_addrs(msk, &free_list);
 
-- 
2.45.2


WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 6.6.y 4/6] mptcp: hold pm lock when deleting entry
Date: Tue, 19 Nov 2024 07:30:37 -0500	[thread overview]
Message-ID: <20241118182718.3011097-12-matttbe@kernel.org> (raw)
Message-ID: <20241119123037.IOg-cEhM-XFzMvAPHTN1adacWHWiHqL2AufsQNEuJIE@z> (raw)
In-Reply-To: <20241118182718.3011097-12-matttbe@kernel.org>

[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: f642c5c4d528d11bd78b6c6f84f541cd3c0bea86

WARNING: Author mismatch between patch and upstream commit:
Backport author: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Commit author: Geliang Tang <tanggeliang@kylinos.cn>

Commit in newer trees:

|-----------------|----------------------------------------------|
| 6.11.y          |  Present (different SHA1: ff6abb7bc44a)      |
| 6.6.y           |  Not found                                   |
|-----------------|----------------------------------------------|

Note: The patch differs from the upstream commit:
---
--- -	2024-11-19 01:13:28.589534977 -0500
+++ /tmp/tmp.4bH6oETSx7	2024-11-19 01:13:28.583100037 -0500
@@ -1,3 +1,5 @@
+commit f642c5c4d528d11bd78b6c6f84f541cd3c0bea86 upstream.
+
 When traversing userspace_pm_local_addr_list and deleting an entry from
 it in mptcp_pm_nl_remove_doit(), msk->pm.lock should be held.
 
@@ -11,15 +13,16 @@
 Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
 Link: https://patch.msgid.link/20241112-net-mptcp-misc-6-12-pm-v1-2-b835580cefa8@kernel.org
 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
 ---
  net/mptcp/pm_userspace.c | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
-index 3f888bfe1462e..e35178f5205fa 100644
+index e268f61d8eb0..8faf776cb977 100644
 --- a/net/mptcp/pm_userspace.c
 +++ b/net/mptcp/pm_userspace.c
-@@ -308,14 +308,17 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
+@@ -324,14 +324,17 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
  
  	lock_sock(sk);
  
@@ -29,7 +32,7 @@
  		GENL_SET_ERR_MSG(info, "address with specified id not found");
 +		spin_unlock_bh(&msk->pm.lock);
  		release_sock(sk);
- 		goto out;
+ 		goto remove_err;
  	}
  
  	list_move(&match->list, &free_list);
@@ -37,3 +40,6 @@
  
  	mptcp_pm_remove_addrs(msk, &free_list);
  
+-- 
+2.45.2
+
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y        |  Success    |  Success   |

  parent reply	other threads:[~2024-11-18 18:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-18 18:27 [PATCH 6.6.y 0/6] mptcp: fix recent failed backports Matthieu Baerts (NGI0)
2024-11-18 18:27 ` [PATCH 6.6.y 1/6] mptcp: define more local variables sk Matthieu Baerts (NGI0)
2024-11-19 12:31   ` Sasha Levin
2024-11-18 18:27 ` [PATCH 6.6.y 2/6] mptcp: add userspace_pm_lookup_addr_by_id helper Matthieu Baerts (NGI0)
2024-11-19 12:31   ` Sasha Levin
2024-11-18 18:27 ` [PATCH 6.6.y 3/6] mptcp: update local address flags when setting it Matthieu Baerts (NGI0)
2024-11-19 12:31   ` Sasha Levin
2024-11-18 18:27 ` Matthieu Baerts (NGI0) [this message]
2024-11-19 12:30   ` [PATCH 6.6.y 4/6] mptcp: hold pm lock when deleting entry Sasha Levin
2024-11-18 18:27 ` [PATCH 6.6.y 5/6] mptcp: drop lookup_by_id in lookup_addr Matthieu Baerts (NGI0)
2024-11-19 12:31   ` Sasha Levin
2024-11-18 18:27 ` [PATCH 6.6.y 6/6] mptcp: pm: use _rcu variant under rcu_read_lock Matthieu Baerts (NGI0)
2024-11-19 12:30   ` Sasha Levin
2024-11-19 15:34   ` Matthieu Baerts
2024-11-19 13:02 ` [PATCH 6.6.y 0/6] mptcp: fix recent failed backports Greg KH

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=20241118182718.3011097-12-matttbe@kernel.org \
    --to=matttbe@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tanggeliang@kylinos.cn \
    /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