From nobody Tue Dec 3 17:11:57 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C161F2E3EB; Mon, 18 Nov 2024 18:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954463; cv=none; b=Zj7LycZFDwKZt+xUkHltr+5fffoFtszIFVOO78/HuzU/i+QwwE8vnyE76gi9C1JDUR/Q+y2KwWo7bnEq5kA+QEvLH0H9M7acVY/rPYExgW0G8BlAdDkDCnd3Vt4AGbS6NHdS5WewT62n6FQlGBkp/Sk7LWpvrV01P92QozH0tEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954463; c=relaxed/simple; bh=Y0tEZ47rOa0qaWge6wWHVvhqklS3+feOuoSFjH3YHic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fo0fWLIanbT7S7yuVbFlvbkpYK7LVLMgl28f3TQqM5JT/mzqvJCZqg8n37eWSS2DP9mdBdva3FtgZnZ8Q/fM4kBuYyt4BGnsn4IL49NfuR1S/cikc1GV0p9xWV5+sY14jR7sTRsIEzVcvNcRwp0MYGD9YUhYjVcxgyv0TH8Y3yI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EuJ4Y+jB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EuJ4Y+jB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AE44C4CED1; Mon, 18 Nov 2024 18:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731954463; bh=Y0tEZ47rOa0qaWge6wWHVvhqklS3+feOuoSFjH3YHic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EuJ4Y+jBX+eJrxCXP2o/cVG1W9UJWswyZ1GrTM1zWfOeweMWrA8eGM8PiyRq6HWil QJdG9xu22C8H+ARDcn7ZumcEDske+llGOMB5B3uXndUcD/rZq2Vk55yicyALt7NXGI 5jQ/GScmbL21iPwUlRCvr/5L6HwNCoocMfxNN/AslG8dOBBT/EqgrvAvtvh05fgFUv WIpbmcPZHHpgDIOcGOfpyqKm1Q9z9XPQwIoxhnSeHANA3nwXxiEIR9PUFceiDDCXtK hMLkN4sWchmTzpwaVNKFtX7I3yeyOjPbjKrvWvtov2MhGU221gdw0y9enHEreHEXao inhZ00vN+SbAg== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Geliang Tang , sashal@kernel.org, Matthieu Baerts , Mat Martineau , Jakub Kicinski Subject: [PATCH 6.6.y 1/6] mptcp: define more local variables sk Date: Mon, 18 Nov 2024 19:27:19 +0100 Message-ID: <20241118182718.3011097-9-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182718.3011097-8-matttbe@kernel.org> References: <20241118182718.3011097-8-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4507; i=matttbe@kernel.org; h=from:subject; bh=fvnyb/aCBAAzm1QXpzp3jY4kD/YgYdySxnjmjGPeXGg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnO4cGxnKzu3GU0FqVj3vA9unaXRURfYxyXZOU9 YyyEEGhQKOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZzuHBgAKCRD2t4JPQmmg c+bKD/445mHZ8186p59b8vfOp7k/qmg5HXD02W5firl9zCxDtjyubjsoYpxLpS7CDdQmHGLO7m2 l5WGC3RGBWy34JL5C1wFz7cvMAUXcF7ThTG6QMa8JiefMTG7BTBn9KyJiICuhq2k1Z3ruzM1ma7 QQ8iV240kwb9TY5lR1Ykw6p7mu5sypzo1HW0PXEmkDBTYpzMNqrRiwQdJa0tRUO51Xn2SrGZoGi 3zp5vhnq5i332fCQeaLkqNL8FZMxSPjn3/FNemucHuS7crY1c73UgzztJ1/blZ5+p7E0b4hFrGA WG3zPegs7HEXANsE4Shih0BRkXb5QROrD1aDP9aV1uqhXU7YYFfnVw8kZyJPUvUK+jgUfkaYZgl lQH79EhXsw+esscZcSZRPu2jMjTWyghr0XuyRRLMl1bEcYNae9v/45r0WxwvqCGRXaem37FPFod eFeQgsrZHKDSohCPb/bCTH7IrPg6mKqpPG58J/yztWs+tPFGLZXfqIjRnUDTmZg2VChmKp6IJVx wwAfDoXOdM6lOiqyfBVoCEJgTdxgF9T3mtcLTiUPIxqbKCpAVUur11KjesI34oC+oZ5gMjdCa1Z Mo7v/xJGnoPQYeLCe0fMXOrL1wcRD6VagqgEHre/b5Ipe0frEtknR6WNxQ079fkKbdo7SNA1P1T YEEH/6Zdi6slJLg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang commit 14cb0e0bf39bd10429ba14e9e2f905f1144226fc upstream. '(struct sock *)msk' is used several times in mptcp_nl_cmd_announce(), mptcp_nl_cmd_remove() or mptcp_userspace_pm_set_flags() in pm_userspace.c, it's worth adding a local variable sk to point it. Reviewed-by: Matthieu Baerts Signed-off-by: Geliang Tang Signed-off-by: Mat Martineau Link: https://lore.kernel.org/r/20231025-send-net-next-20231025-v1-8-db8f25= f798eb@kernel.org Signed-off-by: Jakub Kicinski Stable-dep-of: 06afe09091ee ("mptcp: add userspace_pm_lookup_addr_by_id hel= per") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index e097b6a7b816..eded0f9c0b6f 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -183,6 +183,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct g= enl_info *info) struct mptcp_pm_addr_entry addr_val; struct mptcp_sock *msk; int err =3D -EINVAL; + struct sock *sk; u32 token_val; =20 if (!addr || !token) { @@ -198,6 +199,8 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct g= enl_info *info) return err; } =20 + sk =3D (struct sock *)msk; + if (!mptcp_pm_is_userspace(msk)) { GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); goto announce_err; @@ -221,7 +224,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct g= enl_info *info) goto announce_err; } =20 - lock_sock((struct sock *)msk); + lock_sock(sk); spin_lock_bh(&msk->pm.lock); =20 if (mptcp_pm_alloc_anno_list(msk, &addr_val.addr)) { @@ -231,11 +234,11 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct= genl_info *info) } =20 spin_unlock_bh(&msk->pm.lock); - release_sock((struct sock *)msk); + release_sock(sk); =20 err =3D 0; announce_err: - sock_put((struct sock *)msk); + sock_put(sk); return err; } =20 @@ -282,6 +285,7 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct gen= l_info *info) struct mptcp_sock *msk; LIST_HEAD(free_list); int err =3D -EINVAL; + struct sock *sk; u32 token_val; u8 id_val; =20 @@ -299,6 +303,8 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct gen= l_info *info) return err; } =20 + sk =3D (struct sock *)msk; + if (!mptcp_pm_is_userspace(msk)) { GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); goto remove_err; @@ -309,7 +315,7 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct gen= l_info *info) goto remove_err; } =20 - lock_sock((struct sock *)msk); + lock_sock(sk); =20 list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { if (entry->addr.id =3D=3D id_val) { @@ -320,7 +326,7 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct gen= l_info *info) =20 if (!match) { GENL_SET_ERR_MSG(info, "address with specified id not found"); - release_sock((struct sock *)msk); + release_sock(sk); goto remove_err; } =20 @@ -328,15 +334,15 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct g= enl_info *info) =20 mptcp_pm_remove_addrs(msk, &free_list); =20 - release_sock((struct sock *)msk); + release_sock(sk); =20 list_for_each_entry_safe(match, entry, &free_list, list) { - sock_kfree_s((struct sock *)msk, match, sizeof(*match)); + sock_kfree_s(sk, match, sizeof(*match)); } =20 err =3D 0; remove_err: - sock_put((struct sock *)msk); + sock_put(sk); return err; } =20 @@ -558,6 +564,7 @@ int mptcp_userspace_pm_set_flags(struct net *net, struc= t nlattr *token, { struct mptcp_sock *msk; int ret =3D -EINVAL; + struct sock *sk; u32 token_val; =20 token_val =3D nla_get_u32(token); @@ -566,6 +573,8 @@ int mptcp_userspace_pm_set_flags(struct net *net, struc= t nlattr *token, if (!msk) return ret; =20 + sk =3D (struct sock *)msk; + if (!mptcp_pm_is_userspace(msk)) goto set_flags_err; =20 @@ -573,11 +582,11 @@ int mptcp_userspace_pm_set_flags(struct net *net, str= uct nlattr *token, rem->addr.family =3D=3D AF_UNSPEC) goto set_flags_err; =20 - lock_sock((struct sock *)msk); + lock_sock(sk); ret =3D mptcp_pm_nl_mp_prio_send_ack(msk, &loc->addr, &rem->addr, bkup); - release_sock((struct sock *)msk); + release_sock(sk); =20 set_flags_err: - sock_put((struct sock *)msk); + sock_put(sk); return ret; } --=20 2.45.2 From nobody Tue Dec 3 17:11:57 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 993201DED55; Mon, 18 Nov 2024 18:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954466; cv=none; b=YYbV7nM9saJ+zFnpvL0doITPyuyj1xf4jgLiygxocVR3ltD7oxcJvxLGpsjVp7Lqw4K9Vrj6hPlz8FaSNtcqMmjfs+bboAj7sicA73OOCaa2kPwkgMT/1UnmB8TN1m7RONp2qzfMweGttL2pzsrXEhv2FlI9zH+nXoRm7Y2AOOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954466; c=relaxed/simple; bh=puNfWVMS56Wr5LnT6SuKL2WgxBO/QWVLR6swiJFqYK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fp0CyzvWHxmAIw/2yfHB3CvZ7vmihn0hoJklAdD+ZnqS5hpqusYmiuJb1jgDqrjGfi89GBhqkeNlcLfflpbn54w9jOH2MNh8+MY2YdC/kSIoyHdpqk3KKtwgX7wVEOSYuQFzkm0Arj6HQOjV7Yz397CTFIOBY0gGB6t3sePykmc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P07CW9CR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P07CW9CR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20B65C4CECC; Mon, 18 Nov 2024 18:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731954466; bh=puNfWVMS56Wr5LnT6SuKL2WgxBO/QWVLR6swiJFqYK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P07CW9CROgo5VZJbb6FoM6wXcJTRgcxhAoBxmb53jDkTYwkykIh9KVz71QI8G2jZc 1aQZJnyHWfEV2neo4tObxXG2xrX7sSE1bGdnsctS9XcC84wmnVYuZv92pXZO79oeLc 29pc8npdc9akvLAg4ebJVp5+fve+BJrQF1JL8OnqWW1PE6IBcoW705431yBGf2nuiB ZM3xdjXK9LHSDOGDltDpRI21bw22L71X5CGYfIR7wThaM70UvPRG634VbSnZ8sAaKn ErnTyd6zMMBq0Ifp+/gAsDTw/e4PNMggefFkODOtSAiDOYw4CWHFJpKLnDEiQYqQRm HH/o22U28swPg== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Geliang Tang , sashal@kernel.org, Matthieu Baerts , Mat Martineau , "David S . Miller" Subject: [PATCH 6.6.y 2/6] mptcp: add userspace_pm_lookup_addr_by_id helper Date: Mon, 18 Nov 2024 19:27:20 +0100 Message-ID: <20241118182718.3011097-10-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182718.3011097-8-matttbe@kernel.org> References: <20241118182718.3011097-8-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2833; i=matttbe@kernel.org; h=from:subject; bh=Gez9/8bqtvjqsM0p3HrSnk53UVBnSeuwntb0Sblhfv0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnO4cGQGNcOojrsRT3WhQ0NnOkjOD6CsEaijwri mM9i1AuscaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZzuHBgAKCRD2t4JPQmmg c3cPEADc0D2lGqemrxqcd+siWlBemT8jt4XM/3N+HWwyuehB7HsfNhsIGacYYVrd/7B6l2Jlzxf GfLs7AP1UCMzGdkdkhW1mxXpB/nhzGRVXSiAhC7evxKRB3PbXbUeUg01xyLxmgyDzn0cKEX+K5C DIxBmiQALjAwB0nopw8ceddL06puaXrVDDv8qkwarX8CUR8wOK1y0ILVehwC+W3yE0DNLp73WE9 8fiuJdn9V5wgON9/g8S13jGbfCd0nDPz1UU3abqstluSqqdgBJQ1XilLMLfLP23tpyfcdFdKP3X nPQ90IrhlKe+qfrDV7FZutfQ7kjGsj7y4xshOw6vkoeR3C9rgs67IV2suOlrO88tJK0WMjzVAg0 l+12Vx5UuHiOA8gAtilBKL6SKiUQ/TWeGnRexeljHCkGTzKi2Cr99FUTsD0pHx+4XhP0kGJl7Lc uFEkGkKfTiUF2JkFkxSDpw9uXgSbvMRSxlFk+X7W067UWAJJCs1tTgFnm76uu7RVgaiO6M1h1Dl 9VJYwFY9eZHxaEgmqTxTxqHMMf4DDJF/MMG3iwJHPArRl0G1Sv4W3XtFdV/st2NfszrUoUBHNnh Q79ayzMnK4yT7MQvReT+VTdP1D5cWoQHVEWVT9en1jdK6/lxZvcwo/262vUE0aSzuzJmY3DyHlO PfSBtFQsirdZlUw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang commit 06afe09091ee69dc7ab058b4be9917ae59cc81e5 upstream. Corresponding __lookup_addr_by_id() helper in the in-kernel netlink PM, this patch adds a new helper mptcp_userspace_pm_lookup_addr_by_id() to lookup the address entry with the given id on the userspace pm local address list. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: David S. Miller Stable-dep-of: f642c5c4d528 ("mptcp: hold pm lock when deleting entry") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index eded0f9c0b6f..23e362c11801 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -107,19 +107,26 @@ static int mptcp_userspace_pm_delete_local_addr(struc= t mptcp_sock *msk, return -EINVAL; } =20 +static struct mptcp_pm_addr_entry * +mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int = id) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (entry->addr.id =3D=3D id) + return entry; + } + return NULL; +} + int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex) { - struct mptcp_pm_addr_entry *entry, *match =3D NULL; + struct mptcp_pm_addr_entry *match; =20 spin_lock_bh(&msk->pm.lock); - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (id =3D=3D entry->addr.id) { - match =3D entry; - break; - } - } + match =3D mptcp_userspace_pm_lookup_addr_by_id(msk, id); spin_unlock_bh(&msk->pm.lock); if (match) { *flags =3D match->flags; @@ -280,7 +287,7 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct gen= l_info *info) { struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *id =3D info->attrs[MPTCP_PM_ATTR_LOC_ID]; - struct mptcp_pm_addr_entry *match =3D NULL; + struct mptcp_pm_addr_entry *match; struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; LIST_HEAD(free_list); @@ -317,13 +324,7 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct ge= nl_info *info) =20 lock_sock(sk); =20 - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (entry->addr.id =3D=3D id_val) { - match =3D entry; - break; - } - } - + match =3D mptcp_userspace_pm_lookup_addr_by_id(msk, id_val); if (!match) { GENL_SET_ERR_MSG(info, "address with specified id not found"); release_sock(sk); --=20 2.45.2 From nobody Tue Dec 3 17:11:57 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E19C81DED55; Mon, 18 Nov 2024 18:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954469; cv=none; b=gzp+SbOP/nPcaPezwCNZ9g6qi7/zdlUia5MpkfymztHAbjw+ymYilU3QcXE13U7k27Z7UUexNVUX5/prRpNSAXLnxhjbRKyOUkLDw13J4ak0v46n1FSEETKS8HtZu4VSBXyHmEpPpxnxzYfaDFCOgUv0tw7Pf0VPI2VehqwDj14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954469; c=relaxed/simple; bh=oiVQNKFq0gEyMzWsr5z5leGv6yB3xSPIZROm0rpJ+nY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GgctasONJy3UcLlmdygSz1OdmxVXFyx52+lr7RRTttIK14bNy5q6aHKwvyEBHxZIdmnOd1RSfTjQuAlrcPvqhqajZ/PMfDRbnHEU7VsaG9oY9WSa0h59pIjG7R99wn6DhWKuwIuIWUIWTVzuOpjf1W9qLhQZvohVmMjHlFEpQnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XL51Kp4Q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XL51Kp4Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E249C4CEDA; Mon, 18 Nov 2024 18:27:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731954468; bh=oiVQNKFq0gEyMzWsr5z5leGv6yB3xSPIZROm0rpJ+nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XL51Kp4QoULk+EvhwGla5CxAYb8SgSiT4xD7rRsnhdNpxZeW1G8EtOBs8Nkbzpq4R OF2bd6Si/Pn6j6wOBWwNFqrQkxsY1ZJYdoWoT6si2Zrsgx71WC6jX0pi4lZW/1m3QD u8fB2p8UpBziM4SCxqUWkuEjUz9tY/Pp1jyQ5Ax0Lr7hlWovbH9QmegJ0LyCEVozBs Cr1qHrLTSV2k7sG7HOEN5VRYWleJKja5IMls61LtH8V32tE9d7f/BuM557qJsWQQcy svObap53Gr7pGUrv45ZmuzX4IvlPe8TsOW72cRmB9Da9Jvjc9E7fMipx/STu/6XAVB 8mOrT5CZ3QKKg== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Geliang Tang , sashal@kernel.org, Matthieu Baerts , Jakub Kicinski Subject: [PATCH 6.6.y 3/6] mptcp: update local address flags when setting it Date: Mon, 18 Nov 2024 19:27:21 +0100 Message-ID: <20241118182718.3011097-11-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182718.3011097-8-matttbe@kernel.org> References: <20241118182718.3011097-8-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2411; i=matttbe@kernel.org; h=from:subject; bh=ZEnmqhcd9qYrLaa0Wh2id9efvACa+gyIat1FkDDs3dY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnO4cGh++17SLZNwBDlDwCKZG39FSv28Jh1rk2h r1ZkCdvrxGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZzuHBgAKCRD2t4JPQmmg c4+HEADn7qrsQDN8g7Ezj+z/l00WO+dUQuIdFpW36hEa13OCFuaQTehPtoEMgqgU4/DPbOX6sN5 RZzxXuBL305ZvqsKzw+HfeEA2Q4m6TsrJ55Q6E9TEcQiR8g706UqktbanN1rMK+EW6kDk7mpFbv cbyzDiLD9neDIt1Rw8sfQx5rz+Vq0T8LNpF8fjU/tvBlLaqytpxZ3zJW4ytZHLacpp0i7oGGg90 QIjoVqpiDcU5Z3mv8TVJFV6/tcC3W9W6FXT9eBGT5r9Jv9S4Crw6ifVz+TtmHMGmhV2iD/gjTle JB+hErDPMMryr06aBS/l1gM975BvFTcQM/Y1oBUkk+nIuondZI063zaUfR82mA5jjKPO5UIchN6 2F4bO+C2S5PLYdho6iSEDt0O4jnXuwhz4eHyuX7f1E6jmqr96RLPMEwWPCpx0Emu0n9X6CjWi4t OlVWJfLMi4uDkK7+1pCHEoED1UMxVhXGjUKDRp/Lry4CrRaq2ZWND6aQQItQgUdPVMRYRrHsmWA KjVVev1t0smGPTAEBvUqZYwfVzKnEp9srxVHKjlH40NmfklmsEMZNkb2mZRDtZ1xgH1eiJlxEp8 5SzhsC6wufiqkQucZ/d6mHq+ybGKUlcg/NBBj3htFdy4p1+Fn3BRlXvpo/cejEKTqlNwQxn3+iR cz5W8wdSbV16/lw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang commit e0266319413d5d687ba7b6df7ca99e4b9724a4f2 upstream. Just like in-kernel pm, when userspace pm does set_flags, it needs to send out MP_PRIO signal, and also modify the flags of the corresponding address entry in the local address list. This patch implements the missing logic. Traverse all address entries on userspace_pm_local_addr_list to find the local address entry, if bkup is true, set the flags of this entry with FLAG_BACKUP, otherwise, clear FLAG_BACKUP. Fixes: 892f396c8e68 ("mptcp: netlink: issue MP_PRIO signals from userspace = PMs") Cc: stable@vger.kernel.org Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20241112-net-mptcp-misc-6-12-pm-v1-1-b835580= cefa8@kernel.org Signed-off-by: Jakub Kicinski [ Conflicts in pm_userspace.c, because commit 6a42477fe449 ("mptcp: update set_flags interfaces"), is not in this version, and causes too many conflicts when backporting it. The same code can still be added at the same place, before sending the ACK. ] Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 23e362c11801..e268f61d8eb0 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -563,6 +563,7 @@ int mptcp_userspace_pm_set_flags(struct net *net, struc= t nlattr *token, struct mptcp_pm_addr_entry *loc, struct mptcp_pm_addr_entry *rem, u8 bkup) { + struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; int ret =3D -EINVAL; struct sock *sk; @@ -583,6 +584,17 @@ int mptcp_userspace_pm_set_flags(struct net *net, stru= ct nlattr *token, rem->addr.family =3D=3D AF_UNSPEC) goto set_flags_err; =20 + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (mptcp_addresses_equal(&entry->addr, &loc->addr, false)) { + if (bkup) + entry->flags |=3D MPTCP_PM_ADDR_FLAG_BACKUP; + else + entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_BACKUP; + } + } + spin_unlock_bh(&msk->pm.lock); + lock_sock(sk); ret =3D mptcp_pm_nl_mp_prio_send_ack(msk, &loc->addr, &rem->addr, bkup); release_sock(sk); --=20 2.45.2 From nobody Tue Dec 3 17:11:57 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20CB81DED55; Mon, 18 Nov 2024 18:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954471; cv=none; b=nziq3+FQv01QrdXzUBp0WLWnSLXNnwIjWLoL4vFIcnYd6iYF6igsVS7uzoA2BkidSSJMyU5WYnFKz8bivFYDmKKaP6XOYy/kAmGOAspvTP3Mr6c0racjvqLpd9AfRZz7lQDGlJybYOyD8et89I6w69mVRtHViNSEzi/25J9DU0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954471; c=relaxed/simple; bh=CdJglmChTxPvCtcuBJbIchuWMi7jrzVTg3UuiGg/2/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jHsocjir471dkQYFL/3kPL+6k7gGb486CFytd2HoUrw6jGZnwFHLeUjuE5GUr2vie/7XL27YWjYIn42bOREh46JOSGxqmBbgANWduVifkEtvy6MfXWStA/8VFVEHJyDDtE2J/925JfUb4SFQGtf1VuiqWRHE4/9pzNnIWOn9AOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HjWOkjoI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HjWOkjoI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00FE2C4CED1; Mon, 18 Nov 2024 18:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731954470; bh=CdJglmChTxPvCtcuBJbIchuWMi7jrzVTg3UuiGg/2/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HjWOkjoIHgICTicAbASA4Umx2kDmpfh6tJIFGWipUwIlQwnjlwwUH7bf0sjVaDiJA Hi00cSTuVE3kHv/8Q9k7Gf7G8px/J+pQGBHLzQ4WKV1UsODNPjdKelXb1KZpYRLn1K LnLmj/jRA7jxm5DEha5WG9LPTrvYtBAbhF3f6+WFvdXyFbW9Tt5bYNRVylBIP/Ng1b KeaznYcd02KPDrAljppgf0g5Loozg5fpqn2ZSDApsxPDz5mQP9ce0KKrZZa0q8vZ67 I5ED4XidTpPDF15A69NQCC4qVyoWRJ+ZPtUQ4sUpt9EF/6bdJ0Ne0zRSqKIA1vT02w trLAnJy922JPw== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Geliang Tang , sashal@kernel.org, Matthieu Baerts , Jakub Kicinski Subject: [PATCH 6.6.y 4/6] mptcp: hold pm lock when deleting entry Date: Mon, 18 Nov 2024 19:27:22 +0100 Message-ID: <20241118182718.3011097-12-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182718.3011097-8-matttbe@kernel.org> References: <20241118182718.3011097-8-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1570; i=matttbe@kernel.org; h=from:subject; bh=SMoaqfsurtC6D2JNsiposiESLPMcvY287nxTCPsXang=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnO4cGKsSQS9V78pDIw2VLzAglaaSkLH9/C+Drr LrXPQayRMyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZzuHBgAKCRD2t4JPQmmg czGjEACsPHUH62v014SQaNsBCKF5zRyhMD5aAt6pdj1BSqCugYyovuP6ze02bAf4prc95foW7DB U/jEMbBjyNBFl6duzy53dv6Fw0FfNJR/cT1rTRqMZ/q4jn9M6dgsvgKluvED35dLICdpV9wzgRs xs3Hn5Gvc7Ok7Wo/0ItTFQSASO5z1iUOeW7EG/JFy/4fPljkugK/rI3cgZLgXZEmgPIXoXcfgNS A1SxAaaHs0r0MJI/itmpcwrBQDV2UqUv4UlblBwzp76zqtnn6VvUVlZbtxCvhAfszLuW4uj8oND /EPznlIJepa+EM8IlfN5qDIZK3Xlv4D4T4c5GZeduc7tr/kk6fJ+rUNX9IfqL2weXWTfOs6Txa4 JOGmNlZ9Hy52Nkz6FmxQwCrlKsnK4Xox55/OIgP3WW7XJlAfJdlT4Fw2+MIXCEzMLykFgljt8JX Y0MV78q0mOBDNJ7amS9dk7qmG5ZQHJes+AJYq4sIC2X3ZkcqWskNQ0xmHyIS5t0h3pyXWaXjszl UmT4rSOkIy0kPCdJMkoe9InmfZgvDsYZRc1B7NHm6Eg2Wwy2ORosPP3vfCgj/kIIWZ3mn7ZfUZX 98T8rwSFPsbC8ljNnOejgisSF5dpoHSRxaLSufg/I2Az53KUiTo+XIH7H8MHAZcydjZ0/xVlifn PI/W1G85LMhjcyQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang 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 Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20241112-net-mptcp-misc-6-12-pm-v1-2-b835580= cefa8@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Matthieu Baerts (NGI0) --- 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 g= enl_info *info) =20 lock_sock(sk); =20 + spin_lock_bh(&msk->pm.lock); match =3D 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; } =20 list_move(&match->list, &free_list); + spin_unlock_bh(&msk->pm.lock); =20 mptcp_pm_remove_addrs(msk, &free_list); =20 --=20 2.45.2 From nobody Tue Dec 3 17:11:57 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C5342E3EB; Mon, 18 Nov 2024 18:27:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954473; cv=none; b=VVHkrCT+DtoO26oVQVUK3hL9Nrbh7ecEBszKV4kWAoghzpkaawiPqQx7BvLVhS8VGtsTDBxUoWr71Qwzf0xAh37vXLL0JaCk2abK3gPZuPwpU1IPLuZ7X9MppZuGOwVLdtbdp52i+UF3hi+hhPOCr56RJbnfYurXLRAYRLU6QtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954473; c=relaxed/simple; bh=/3vKm4ylPIZa2+7EkL5cjCgtZjnU/uUqzgWYRCC2N2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ljWqua+5PcRkflPo3Wve74mRxIvyWHn0kFsRLE5QsI7epl0XzSDDrIzR4pEPvuregHDX3vUaz5IOXxL5J+WC9KnKGSFfTZFopg76qmr9L9fX9da5vSr5EJCo3XqVhu92aYpcYO7186Rzt/2TgYY8vQR9Q2fXW0Bp8L3s7YL70W8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SfUMmS2P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SfUMmS2P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56B61C4CED1; Mon, 18 Nov 2024 18:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731954473; bh=/3vKm4ylPIZa2+7EkL5cjCgtZjnU/uUqzgWYRCC2N2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfUMmS2PM+4MsuH4G7QONjucezcUrLwU+kHTNhz/o4QEyRXqiAPj1gjE9pyO1dPSG 4/1jlRVRhJ7V9h5RCGxwPzwXrKa6HSi78OGiiJD29Xp6EJxC1X3Kz3L0if9QgUaHWo 3rLHtporu3jSUJBsGv1BtBgek5A1Qm0eEr/HEJhRVEBR/97om6UopQVpNHG/+ZhBnq ZdF9DqUumDVlUBdFjm96slWRyrQUz2sduDgO02E/mNuHTy+mrRtc383uukE8gSYK7b ftHyVECQ6sn1OmQLrOhQXJE2+r8qlsvYeXlEev84AFrTykJQOZKstJxmwZ+VKK6T0L sSQO7hrcMEfWg== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Geliang Tang , sashal@kernel.org, Matthieu Baerts , Jakub Kicinski Subject: [PATCH 6.6.y 5/6] mptcp: drop lookup_by_id in lookup_addr Date: Mon, 18 Nov 2024 19:27:23 +0100 Message-ID: <20241118182718.3011097-13-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182718.3011097-8-matttbe@kernel.org> References: <20241118182718.3011097-8-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2923; i=matttbe@kernel.org; h=from:subject; bh=hZg08X/uvrihXLRHj7mAWzN7ZcWhonPGmdfxZ8g+tg8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnO4cGcETYB6kQVnX/rRVcS5ysvxTL48mRfMDmH UTbX2JGu0qJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZzuHBgAKCRD2t4JPQmmg c1KXD/9ce6U7OUrs8zuv0YyDSf14DbKZZgaC9UD+OB8eNFoiarcFJbe2zgwUl9cCfm00nxEKoEW AqAl75pWdD6Re5XTgxTOvcohoRYkuhceF0EOcNzyBcS8Zi+jNeBPc2cuUB+bUZuZO2qfhXNheia KQ0lJQpE4h7bqmFEmTxgQNL+QLHzTi3l8UQm06Ybe1GtOmlEyFFf29YOEu5t1TGmMtfzN50upun BLiwQf1PiniayeQ/oGTf2wEoKGvm3UC0jWqGHENG+PeI2F/WikBxXx9bwwc6ilxmqbPs8PcWAKz qZUeUbKGRx+cRfpALlQy9I02ixW4rilWATXJKaHWb17fz4SY8sbFygn2TfTMUBCp2jLkdX8Clyo PnUyILpkxxjfuD8zCR/NQSrBcAHRFWlKQSqVF89jy8VOHW8uO7nr8SDDgK3qwb2rvQZQZBFi8Pj GZKHXcJ09iPovjA2c73p+HV163601TUotHfaDfwJI+pBYweKP+H/STWqZYwOq+BjU0Ew08dpJ0s GLzlNgylOqU0aAkKbktyJW5sVWZJOVV7KdY2t+mrHMI79n/ftszZrJ2hoqDFM3jwRcHh57/hnhZ 9mkbzDAz3eZcy8Qd7F28tfCPeUxN83mkb5ziGNQXANhOSW0L4F2LjmAmWNCL4RqiozOTMiQtDQl ltn67qzb57qfYCQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang commit af250c27ea1c404e210fc3a308b20f772df584d6 upstream. When the lookup_by_id parameter of __lookup_addr() is true, it's the same as __lookup_addr_by_id(), it can be replaced by __lookup_addr_by_id() directly. So drop this parameter, let __lookup_addr() only looks up address on the local address list by comparing addresses in it, not address ids. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://lore.kernel.org/r/20240305-upstream-net-next-20240304-mptcp-m= isc-cleanup-v1-4-c436ba5e569b@kernel.org Signed-off-by: Jakub Kicinski Stable-dep-of: db3eab8110bc ("mptcp: pm: use _rcu variant under rcu_read_lo= ck") [ Conflicts in pm_netlink.c, because commit 6a42477fe449 ("mptcp: update set_flags interfaces") is not in this version, and causes too many conflicts when backporting it. The conflict is easy to resolve: addr is a pointer here here in mptcp_pm_nl_set_flags(), the rest of the code is the same. ] Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d8c47ca86de4..76be4f4412df 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -521,15 +521,12 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsi= gned int id) } =20 static struct mptcp_pm_addr_entry * -__lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *i= nfo, - bool lookup_by_id) +__lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *i= nfo) { struct mptcp_pm_addr_entry *entry; =20 list_for_each_entry(entry, &pernet->local_addr_list, list) { - if ((!lookup_by_id && - mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) || - (lookup_by_id && entry->addr.id =3D=3D info->id)) + if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) return entry; } return NULL; @@ -560,7 +557,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(stru= ct mptcp_sock *msk) =20 mptcp_local_address((struct sock_common *)msk->first, &mpc_addr); rcu_read_lock(); - entry =3D __lookup_addr(pernet, &mpc_addr, false); + entry =3D __lookup_addr(pernet, &mpc_addr); if (entry) { __clear_bit(entry->addr.id, msk->pm.id_avail_bitmap); msk->mpc_endpoint_id =3D entry->addr.id; @@ -2064,7 +2061,8 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mpt= cp_pm_addr_entry *addr, u8 } =20 spin_lock_bh(&pernet->lock); - entry =3D __lookup_addr(pernet, &addr->addr, lookup_by_id); + entry =3D lookup_by_id ? __lookup_addr_by_id(pernet, addr->addr.id) : + __lookup_addr(pernet, &addr->addr); if (!entry) { spin_unlock_bh(&pernet->lock); return -EINVAL; --=20 2.45.2 From nobody Tue Dec 3 17:11:57 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073D42E3EB; Mon, 18 Nov 2024 18:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954476; cv=none; b=cs4Vw+4tMuMOgG7NMeZt21AJ1LePVjP1V5uTLwJ0G/s7aytZtfSLUhV3nPja8WsaIIshkohdUSX0YkYmjyYqvnzolNxq8R0a4YUs9sGckD5/NwuUx8pe7sNAefvWyn1TDuUvL6fIdnp6/8n/8719675/k+YH7NIUwQwGB2z2+VY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731954476; c=relaxed/simple; bh=oUHl9syWz+l50YB6iHaH/W3xamw75kFCBtFIDuz+ldw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PDWE1Hj6RrNRsgK43ZXvLEMXnqCJSNMXUULkppETSHU2wiUfs3jpSE7rjsylrluzW5+vvXe9QtGySENsz2U5F/RC+ycyJk1WrRInCbjjPaAb3mOg9uh9QF7wNcqyQi90rWU//9yMIubS4I2yio6BpFAGaAdbIQU+9KnXdz0x9lQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nq8WJjFm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nq8WJjFm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADCFFC4CECC; Mon, 18 Nov 2024 18:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731954475; bh=oUHl9syWz+l50YB6iHaH/W3xamw75kFCBtFIDuz+ldw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nq8WJjFm/VL11yuPxAiW7/4d/0xhF3JdiM7sAHIuRLG5f+qDH4v59y3zQxUvIr40P /ByJPreyn/XIuPW47+xJPBz0jwO7gUU3fO9f3R/n7day8pezFq2vNq9ddGvJUQmX7f bNQtKLP+9TZCvMnWdRQ6ptg53rOqCz3nOzwXigFh2fv3Y6kNN8sQQQ6ikicdpogP3y VC3YuXtJ5Hp88bJdN7DZe4i/6Hniql6Rp8RssEEmREQ68/0Lwe/4DJsIffFX3u9skR LLWHcvbbKNADS5/7HdilWIxb88LLwpy0jH3XEwTgqnZ8eOJjGTqFbMm3QWpJoP15+F VwvgQ5tJofj0w== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: "Matthieu Baerts (NGI0)" , sashal@kernel.org, Geliang Tang , Jakub Kicinski Subject: [PATCH 6.6.y 6/6] mptcp: pm: use _rcu variant under rcu_read_lock Date: Mon, 18 Nov 2024 19:27:24 +0100 Message-ID: <20241118182718.3011097-14-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182718.3011097-8-matttbe@kernel.org> References: <20241118182718.3011097-8-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1770; i=matttbe@kernel.org; h=from:subject; bh=oUHl9syWz+l50YB6iHaH/W3xamw75kFCBtFIDuz+ldw=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnO4cG8kNSj4r+UMJypWr51PC0SKuCn7EsWI6FZ bjEY7CrvrCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZzuHBgAKCRD2t4JPQmmg cwKFD/0U/S4zOye0ab02Ca9LVqhM2yC/rQEfO3O4WL8s6ekxFQAxyrkt/KUxrM+ntFjLZ0q2ENg 9wazA2pSAMwwwtC7RJ4vuGJ1KWgVHDwuSaCNaffqvWtsq+qbewxTDTUMUsn7zW/d89wLc2bCmqi bQCSemaB5wDuH+BvgfGPAcvjSyfb/va3WiqhhxJT2LNvgbwB9h1UgI0fFv1sgeDwyFRJCzwNRGs X/aTrMJZh+oKvA2DMDV5NirBEM35DQUCPP49YmOBu2RaOxx16YU3dgeej4pyuY5u7V4MHkKNRDk 05TAvnDr4UXFyj/qYL5qq4iZRv8Zh6HyoANA5zn1oKXcCaojdExUyHm7xSlokBlJNrGRkVIEcPP xSP+qwaR27BsKLFAD7xEo5yTG8X7+4f3knB9u21rXq9Mcqz8vJcNcDix9nEXQlS27HqQzjnehP4 owj+HxF/RSi9jRYlW2fCqiIgvdALsLKsKyLf6GQ7kyYwkyBxDGv1/v8nV2e4eogSEenWRps/hVQ y+/aA22kNon3okLHVk7ZCanYtUabtCa2yWwG5YeEMlQwOySCDk/KlNvXXxIGRE1EYgnknuyw5+H 2a5ReYWOcOWC6hzLfr8DEZTK3Qut3xn/CIJRln/jvLWth6INRl0Jym2D+ROTiY84RzvrILDlTu7 kDg+h9yXHQQSedA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit db3eab8110bc0520416101b6a5b52f44a43fb4cf upstream. In mptcp_pm_create_subflow_or_signal_addr(), rcu_read_(un)lock() are used as expected to iterate over the list of local addresses, but list_for_each_entry() was used instead of list_for_each_entry_rcu() in __lookup_addr(). It is important to use this variant which adds the required READ_ONCE() (and diagnostic checks if enabled). Because __lookup_addr() is also used in mptcp_pm_nl_set_flags() where it is called under the pernet->lock and not rcu_read_lock(), an extra condition is then passed to help the diagnostic checks making sure either the associated spin lock or the RCU lock is held. Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available f= or each msk") Cc: stable@vger.kernel.org Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20241112-net-mptcp-misc-6-12-pm-v1-3-b835580= cefa8@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 76be4f4412df..2cf4393e48dc 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -525,7 +525,8 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct= mptcp_addr_info *info) { struct mptcp_pm_addr_entry *entry; =20 - list_for_each_entry(entry, &pernet->local_addr_list, list) { + list_for_each_entry_rcu(entry, &pernet->local_addr_list, list, + lockdep_is_held(&pernet->lock)) { if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) return entry; } --=20 2.45.2