From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v3 06/10] ms/tcp: ipv6: free ireq->ipv6_opt after an RCU grace period
Date: Thu, 26 Nov 2026 08:11:06 +0200 [thread overview]
Message-ID: <20261126062617.2133758-8-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261126062617.2133758-2-eva.kurchatova@virtuozzo.com>
From: Eric Dumazet <edumazet@kernel.org>
ireq->ipv6_opt is only set by calipso_req_setattr(), when a CALIPSO
NetLabel mapping is configured.
Request socket migration (net.ipv4.tcp_migrate_req=1, or a
BPF_SK_REUSEPORT_SELECT_OR_MIGRATE program) clones the request
socket with inet_reqsk_clone(), so that the old request socket and
its clone share the same ipv6_opt, then reqsk_migrate_reset() clears
the pointer in the old one.
Another cpu holding a reference on the old request socket can still
be using these options, sending a SYNACK from tcp_v6_send_synack()
or creating a child in tcp_v6_syn_recv_sock(), when the clone
is freed. tcp_v6_reqsk_destructor() frees ipv6_opt with a plain
kfree(), leading to a use-after-free.
Both readers already run under RCU, like their IPv4 counterparts.
Use kfree_rcu() in tcp_v6_reqsk_destructor(), as commit e3f33b0a1d89
("ipv4: free inet_opt and ireq_opt after an RCU grace period") did
for ireq_opt.
Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/netdev/179369559062.488856.15441115725436277776@kernel.org/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Tested-by: Linkui Xiao <xiaolinkui@kylinos.cn>
Link: https://patch.msgid.link/20261103090011.4128420-1-edumazet@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit fafbc4051123d5459ea6950899cec08ed946e278)
https://virtuozzo.atlassian.net/browse/VSTOR-156045
Feature: fix ms/net
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
---
net/ipv6/tcp_ipv6.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index aec76c54327c..c0dbcab756f3 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -575,7 +575,7 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,
static void tcp_v6_reqsk_destructor(struct request_sock *req)
{
- kfree(inet_rsk(req)->ipv6_opt);
+ kfree_rcu(inet_rsk(req)->ipv6_opt, rcu);
consume_skb(inet_rsk(req)->pktopts);
}
--
2.56.1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-26 6:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 6:11 [Devel] [PATCH hci-8.2 v3 00/10] ms/net: backport request migration RCU fixes and lockless refcount ordering Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 01/10] ms/tcp: Fix potential UAF in reqsk_timer_handler() Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 02/10] ms/tcp: Fix imbalanced icsk_accept_queue count Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 03/10] ms/inet: reject unhashed sockets during established lookups Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 04/10] ms/net: restore refcount ordering for lockless socket access Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 05/10] ms/tcp: ipv6: do not read ireq->pktopts from tcp_v6_send_synack() Eva Kurchatova
2026-11-26 6:11 ` Eva Kurchatova [this message]
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 07/10] ms/tcp: free saved_syn after an RCU grace period Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 08/10] ms/tcp: Pass req->rsk_listener to inet_csk_reqsk_queue_drop() in tcp_check_req() Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 09/10] ms/tcp: fastopen: note that a child socket was created Eva Kurchatova
2026-11-26 6:11 ` [Devel] [PATCH hci-8.2 v3 10/10] ms/tcp: fix request_sock use-after-free during Fast Open accept() Eva Kurchatova
2026-11-30 15:50 ` [Devel] [PATCH hci-8.2 v3 00/10] ms/net: backport request migration RCU fixes and lockless refcount ordering Konstantin Khorenko
2026-11-30 15:51 ` 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=20261126062617.2133758-8-eva.kurchatova@virtuozzo.com \
--to=eva.kurchatova@virtuozzo.com \
--cc=devel@openvz.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox