]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Revert "mptcp: add needs_id for netlink appending addr"
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Sun, 12 Apr 2026 22:52:06 +0000 (18:52 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Apr 2026 08:33:37 +0000 (10:33 +0200)
[ Upstream commit 8e2760eaab778494fc1fa257031e0e1799647f46 ]

This commit was originally adding the ability to add MPTCP endpoints
with ID 0 by accident. The in-kernel PM, handling MPTCP endpoints at the
net namespace level, is not supposed to handle endpoints with such ID,
because this ID 0 is reserved to the initial subflow, as mentioned in
the MPTCPv1 protocol [1], a per-connection setting.

Note that 'ip mptcp endpoint add id 0' stops early with an error, but
other tools might still request the in-kernel PM to create MPTCP
endpoints with this restricted ID 0.

In other words, it was wrong to call the mptcp_pm_has_addr_attr_id
helper to check whether the address ID attribute is set: if it was set
to 0, a new MPTCP endpoint would be created with ID 0, which is not
expected, and might cause various issues later.

Fixes: 584f38942626 ("mptcp: add needs_id for netlink appending addr")
Cc: stable@vger.kernel.org
Link: https://datatracker.ietf.org/doc/html/rfc8684#section-3.2-9
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20260407-net-mptcp-revert-pm-needs-id-v2-1-7a25cbc324f8@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ adapted changes from pm_kernel.c to pm_netlink.c ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/mptcp/pm_netlink.c

index 634fe0360c496499de0333eb778b8edb69f96e1b..6fb14148a96e0649b8a8b556adb23a7259d4077e 100644 (file)
@@ -972,8 +972,7 @@ static bool address_use_port(struct mptcp_pm_addr_entry *entry)
 }
 
 static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
-                                            struct mptcp_pm_addr_entry *entry,
-                                            bool needs_id)
+                                            struct mptcp_pm_addr_entry *entry)
 {
        struct mptcp_pm_addr_entry *cur;
        unsigned int addr_max;
@@ -1000,7 +999,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
                        goto out;
        }
 
-       if (!entry->addr.id && needs_id) {
+       if (!entry->addr.id) {
 find_next:
                entry->addr.id = find_next_zero_bit(pernet->id_bitmap,
                                                    MAX_ADDR_ID + 1,
@@ -1011,7 +1010,7 @@ find_next:
                }
        }
 
-       if (!entry->addr.id && needs_id)
+       if (!entry->addr.id)
                goto out;
 
        __set_bit(entry->addr.id, pernet->id_bitmap);
@@ -1152,7 +1151,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
        entry->ifindex = 0;
        entry->flags = 0;
        entry->lsk = NULL;
-       ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true);
+       ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
        if (ret < 0)
                kfree(entry);
 
@@ -1374,18 +1373,6 @@ next:
        return 0;
 }
 
-static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,
-                                     struct genl_info *info)
-{
-       struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1];
-
-       if (!nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
-                                        mptcp_pm_addr_policy, info->extack) &&
-           tb[MPTCP_PM_ADDR_ATTR_ID])
-               return true;
-       return false;
-}
-
 static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info)
 {
        struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
@@ -1412,8 +1399,7 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info)
                        return ret;
                }
        }
-       ret = mptcp_pm_nl_append_new_local_addr(pernet, entry,
-                                               !mptcp_pm_has_addr_attr_id(attr, info));
+       ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
        if (ret < 0) {
                GENL_SET_ERR_MSG(info, "too many addresses or duplicate one");
                if (entry->lsk)