Skip to content

Commit 9366922

Browse files
matttbePaolo Abeni
authored andcommitted
mptcp: pm: fix ID 0 endp usage after multiple re-creations
'local_addr_used' and 'add_addr_accepted' are decremented for addresses not related to the initial subflow (ID0), because the source and destination addresses of the initial subflows are known from the beginning: they don't count as "additional local address being used" or "ADD_ADDR being accepted". It is then required not to increment them when the entrypoint used by the initial subflow is removed and re-added during a connection. Without this modification, this entrypoint cannot be removed and re-added more than once. Reported-by: Arınç ÜNAL <arinc.unal@arinc9.com> Closes: multipath-tcp/mptcp_net-next#512 Fixes: 3ad14f5 ("mptcp: more accurate MPC endpoint tracking") Reported-by: syzbot+455d38ecd5f655fc45cf@syzkaller.appspotmail.com Closes: https://lore.kernel.org/00000000000049861306209237f4@google.com Cc: stable@vger.kernel.org Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com> Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 58e1b66 commit 9366922

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

net/mptcp/pm_netlink.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,13 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
615615

616616
fullmesh = !!(local.flags & MPTCP_PM_ADDR_FLAG_FULLMESH);
617617

618-
msk->pm.local_addr_used++;
619618
__clear_bit(local.addr.id, msk->pm.id_avail_bitmap);
620619

621620
/* Special case for ID0: set the correct ID */
622621
if (local.addr.id == msk->mpc_endpoint_id)
623622
local.addr.id = 0;
623+
else /* local_addr_used is not decr for ID 0 */
624+
msk->pm.local_addr_used++;
624625

625626
nr = fill_remote_addresses_vec(msk, &local.addr, fullmesh, addrs);
626627
if (nr == 0)
@@ -750,7 +751,9 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
750751
spin_lock_bh(&msk->pm.lock);
751752

752753
if (sf_created) {
753-
msk->pm.add_addr_accepted++;
754+
/* add_addr_accepted is not decr for ID 0 */
755+
if (remote.id)
756+
msk->pm.add_addr_accepted++;
754757
if (msk->pm.add_addr_accepted >= add_addr_accept_max ||
755758
msk->pm.subflows >= subflows_max)
756759
WRITE_ONCE(msk->pm.accept_addr, false);

0 commit comments

Comments
 (0)