From: no-reply@sashiko.virtuozzo.com
To: Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 5/9] ms/mptcp: grafting MPJ subflow earlier
Date: Thu, 19 Nov 2026 04:59:12 +0000 [thread overview]
Message-ID: <010701a1f22c4f68-027f024d-5dd4-414d-9e97-8bbbc20b0c0d-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261119044702.1218722-6-eva.kurchatova@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: early MPJ graft leaves join_list subflow with stale
sk_socket/sk_wq after close()
--
commit c62554dd87cdc961afc2cec2473eafa18b00fb88
Author: Paolo Abeni <pabeni@redhat.com>
ms/mptcp: grafting MPJ subflow earlier
This commit moves the grafting of MPJ subflows to the msk socket from
__mptcp_finish_join() to mptcp_finish_join(). The graft now happens under
the msk data lock through a new helper, mptcp_sock_check_graft(), instead
of under the msk socket lock.
Link: https://patch.msgid.link/20251121-net-next-mptcp-memcg-backlog-imp-v1-3-1f34b6c1e0b1@kernel.org
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 26e608355663..d91d6a5a3fd2 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
[ ... ]
> @@ -3797,11 +3807,17 @@ bool mptcp_finish_join(struct sock *ssk)
> if (ret) {
> sock_hold(ssk);
> list_add_tail(&subflow->node, &msk->conn_list);
> + mptcp_sock_check_graft(parent, ssk);
> }
> } else {
> sock_hold(ssk);
> list_add_tail(&subflow->node, &msk->join_list);
> __set_bit(MPTCP_FLUSH_JOIN_LIST, &msk->cb_flags);
> +
> + /* In case of later failures, __mptcp_flush_join_list() will
> + * properly orphan the ssk via mptcp_close_ssk().
> + */
> + mptcp_sock_check_graft(parent, ssk);
> }
> mptcp_data_unlock(parent);
[Severity: Medium]
Can this leave a stale sk_socket and sk_wq on a join_list subflow after
close()? Before this patch the graft ran in __mptcp_finish_join() under the
msk socket lock and only if msk->sk_socket was still non-NULL, so it could
not happen after sock_orphan(). Now the graft runs under the data lock
only, and close() does not take that lock around the orphan loop.
CPU0 (close) CPU1 (<softirq>)
mptcp_close()
lock_sock(sk)
__mptcp_close()
mptcp_finish_join()
sock_owned_by_user() -> join_list
mptcp_sock_check_graft()
ssk->sk_socket/sk_wq = msk's
orphan loop (conn_list only)
sock_orphan(sk)
release_sock()
__mptcp_flush_join_list()
__mptcp_finish_join() fails
mptcp_subflow_reset(ssk)
later subflow callback
uses ssk->sk_wq <-- use-after-free
The orphan loop in __mptcp_close() uses mptcp_for_each_subflow(), which
walks conn_list and never visits join_list, so it never clears
ssk->sk_socket and ssk->sk_wq for this subflow. The same happens if
mptcp_sock_check_graft() samples sk_socket just before sock_orphan() but
calls mptcp_sock_graft() after it, since the pointer is used after
sk_callback_lock is dropped with nothing pinning it.
The new comment says __mptcp_flush_join_list() will orphan the ssk on
failure. The failure path only calls mptcp_subflow_reset() and does not
clear sk_socket or sk_wq. Would it make sense to clear them in that path,
or to make the graft check against close() under a lock that close() also
holds?
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261119044702.1218722-1-eva.kurchatova@virtuozzo.com?part=5
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-19 5:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 4:35 [Devel] [PATCH hci-8.2 0/9] ms/mptcp: backport fixes for dropped stream segments Eva Kurchatova
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 1/9] ms/tcp: Save lock_sock() for memcg in inet_csk_accept() Eva Kurchatova
2026-11-19 4:53 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 2/9] ms/mptcp: Fix up subflow's memcg when CONFIG_SOCK_CGROUP_DATA=n Eva Kurchatova
2026-11-19 4:52 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 3/9] ms/net: factor-out _sk_charge() helper Eva Kurchatova
2026-11-19 4:53 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 4/9] ms/mptcp: factor-out cgroup data inherit helper Eva Kurchatova
2026-11-19 4:54 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 5/9] ms/mptcp: grafting MPJ subflow earlier Eva Kurchatova
2026-11-19 4:59 ` no-reply [this message]
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 6/9] ms/mptcp: fix memcg accounting for passive sockets Eva Kurchatova
2026-11-19 4:58 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 7/9] ms/mptcp: handle first subflow closing consistently Eva Kurchatova
2026-11-19 4:59 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 8/9] ms/mptcp: borrow forward memory from subflow Eva Kurchatova
2026-11-19 5:03 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 4:35 ` [Devel] [PATCH hci-8.2 9/9] ms/mptcp: reclaim forward-allocated memory on RX path errors Eva Kurchatova
2026-11-19 5:01 ` no-reply
2026-11-19 17:08 ` Konstantin Khorenko
2026-11-19 17:08 ` [Devel] [PATCH hci-8.2 0/9] ms/mptcp: backport fixes for dropped stream segments Konstantin Khorenko
2026-11-19 17:08 ` Konstantin Khorenko
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=010701a1f22c4f68-027f024d-5dd4-414d-9e97-8bbbc20b0c0d-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=devel@openvz.org \
--cc=eva.kurchatova@virtuozzo.com \
--cc=khorenko@virtuozzo.com \
--cc=vladimir.riabchun@virtuozzo.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.