From nobody Tue Jun 16 11:19:19 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D529033985A for ; Sat, 18 Apr 2026 18:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776536041; cv=none; b=sPP/I/wUXuirrguxnNZ0Usm7GhHOEu4aGe/vaDs7qcnwuCqR0WmijFOvCeo6dOgpD5e2A+0PSW9PlEXZDZUkxwJladf0v0wYFfukNi5ycHi+GBs6GY04FHJcrfVQMJyeIfatV1/7vUqHSRwdMyxirhQogsvxxFOCKAjtPMy+FQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776536041; c=relaxed/simple; bh=usACHL7JFJ+Iojq2WMGOR+XEp5pZozfvJwRKATA+b/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cT5gBYDVPLXIzOpk9ZTA3Dvuug/vTulY2N1P9lS7iyCbpGD8yOWEcaF9q9Bo8QnXXD7W1dEZSZhH3x0Xok/WOY6YY6X7sdvKZp7CtI3qx3q9IkV+226XKsxKlT9l/fFntg64ZzM9fvZAUlVAk6FZr3GV0cUtAQ/i0gREAGMzwZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IU0QsECp; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IU0QsECp" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-82d0b68837aso1073205b3a.2 for ; Sat, 18 Apr 2026 11:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776536039; x=1777140839; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2qCHQt+5njpxpDnHvEMfTt2VrNOBnIxuj1+x6opPunc=; b=IU0QsECpAAiIVvNubSknYTQ4142KJvFFTxblP+0la2iD2AePiIK+V4TSAgNOx1bihu DWvTfc2YRjcKIGHXV38X78IMzLQfEasQc44j9POU0YSrYO9k1SttNj75r/NNul5sV6JG 8Cr25l4GxFH3lDwAcQB3r8wWxZXTtJG0X3Fura4VMA0FDYsUmE2Pje4HYaIxZ77C627w gNOEXZZP8AtFZD7NM3zjl5WD8KxRdloxDWc652YqVXBkLO+LCRPTIhdTjMZhX4HoEbky oh8eiufk7LQfKLPYs2r2pQP3szqdAnDJbTJb0Xgp+q5jC2Wh9A8tXq/Fm5RXFFBVCUCf U4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776536039; x=1777140839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2qCHQt+5njpxpDnHvEMfTt2VrNOBnIxuj1+x6opPunc=; b=Nc7It45AOSjFY+sCN9q6w15lC0lSplHFE43rZTKy8GL0GgkjCabJSftnH7c5/5BL5H FYOlCRigLa+c2/1GQ82xqgkgUd68tizUem4riMaxPNVASfek6iyYlu4XOUsJ8mA/RegQ FGbvctX+msTeWbMYcEXxRkYuQctboVf0m9dUasXYXKukYUQPq6W/ZylSGTZf61Pd82q1 5U3nnjc3Qp2LdRvNBh0yztU7ZMONYw93brR6dFrwrcO/mVlmd7OygDmuc5VzVdjtgfUp +BLcYLnn1QXj0C1gGOFAe6ya9hkkqtFzmulbkOPcLRLTITNK/SL83EDCd4W+jsUcT8s4 jsPA== X-Forwarded-Encrypted: i=1; AFNElJ8X7ibMwXEMqWnwayutVbaXsPYoSWoAhfpsX1+b6ExGbaTud8/KKTfjFKNUVpZgT71mTM+udlIMlcH88e8=@vger.kernel.org X-Gm-Message-State: AOJu0Yzr9MFT4vF42fSzG2O7WXDtFwErOcHhuhYJArM7PDD+OpbCbaH1 UJVYOwkl/sJGCwn7c8u5dqkf3G0JVwYI4ldt5LG3schH75sUwTYu+SI0 X-Gm-Gg: AeBDiev/JJP8EjIyVsqiq7BCByPNCWszhZEBXbVkf+YZg44BzxNT2zIy5sK1djmtq+i 7fpLuKvUMtR6FO17jcgMieZz+qU9MXsTTlC221/VaQFUY8p2uE9+KVQL5UydBWlCGutTogSVyNY KHj1PDL/Rg+KsKdCIafUOclXvEw2oOym4ufpN4ySIWbHp97krmS9pQESzU5j5Ftc3bJqKxBGuE5 /4mYVZMigXB315oS0hVxaNhsiVaT6QZqapAmn6Ht7U4TPpm+pjxdHQBbcYvJtD3PeUjGiCEc+9s yxS/uStY4m4SFkLRSwib94Q44e25nJkHuHrU/FLJvIqVr2t1zt6TLW8VEHQXUEuHMwv0RXCKuC1 ZXCfxsb0QDbzRFVcQB1aJ/ixhXt9getZLwccXMfn0HUxCoy4MdEb9IU/wQYJBawxeq8/4Rnrh3r VXt/dOJd3AMphfnVB9vEt1BYYJ2IDH3qMh+9t6f3Xnb+i44+pZg70fMIpeOwfCNA== X-Received: by 2002:a05:6a00:3397:b0:82a:6852:559e with SMTP id d2e1a72fcca58-82f8c82165amr8311427b3a.12.1776536039025; Sat, 18 Apr 2026 11:13:59 -0700 (PDT) Received: from DESKTOP-MUHC17F.tail07b66e.ts.net ([188.253.121.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8e9f7735sm5659402b3a.21.2026.04.18.11.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 11:13:58 -0700 (PDT) From: Zhenzhong Wu To: netdev@vger.kernel.org Cc: edumazet@google.com, ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, tamird@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Zhenzhong Wu , stable@vger.kernel.org Subject: [PATCH net v2 1/2] tcp: call sk_data_ready() after listener migration Date: Sun, 19 Apr 2026 02:13:32 +0800 Message-ID: <20260418181333.1713389-2-jt26wzz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260418181333.1713389-1-jt26wzz@gmail.com> References: <20260418181333.1713389-1-jt26wzz@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When inet_csk_listen_stop() migrates an established child socket from a closing listener to another socket in the same SO_REUSEPORT group, the target listener gets a new accept-queue entry via inet_csk_reqsk_queue_add(), but that path never notifies the target listener's waiters. A nonblocking accept() still works because it checks the queue directly, but poll()/epoll_wait() waiters and blocking accept() callers can also remain asleep indefinitely. Call READ_ONCE(nsk->sk_data_ready)(nsk) after a successful migration in inet_csk_listen_stop(). However, after inet_csk_reqsk_queue_add() succeeds, the ref acquired in reuseport_migrate_sock() is effectively transferred to nreq->rsk_listener. Another CPU can then dequeue nreq via accept() or listener shutdown, hit reqsk_put(), and drop that listener ref. Since listeners are SOCK_RCU_FREE, wrap the post-queue_add() dereferences of nsk in rcu_read_lock()/rcu_read_unlock(), which also covers the existing sock_net(nsk) access in that path. The reqsk_timer_handler() path does not need the same changes for two reasons: half-open requests become readable only after the final ACK, where tcp_child_process() already wakes the listener; and once nreq is visible via inet_ehash_insert(), the success path no longer touches nsk directly. Fixes: 54b92e841937 ("tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in = accept queues.") Cc: stable@vger.kernel.org Suggested-by: Eric Dumazet Signed-off-by: Zhenzhong Wu --- net/ipv4/inet_connection_sock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_soc= k.c index 4ac3ae1bc..928654c34 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1479,16 +1479,19 @@ void inet_csk_listen_stop(struct sock *sk) if (nreq) { refcount_set(&nreq->rsk_refcnt, 1); =20 + rcu_read_lock(); if (inet_csk_reqsk_queue_add(nsk, nreq, child)) { __NET_INC_STATS(sock_net(nsk), LINUX_MIB_TCPMIGRATEREQSUCCESS); reqsk_migrate_reset(req); + READ_ONCE(nsk->sk_data_ready)(nsk); } else { __NET_INC_STATS(sock_net(nsk), LINUX_MIB_TCPMIGRATEREQFAILURE); reqsk_migrate_reset(nreq); __reqsk_free(nreq); } + rcu_read_unlock(); =20 /* inet_csk_reqsk_queue_add() has already * called inet_child_forget() on failure case. --=20 2.43.0 From nobody Tue Jun 16 11:19:19 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17D9A3375CB for ; Sat, 18 Apr 2026 18:14:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776536046; cv=none; b=Xjz4dgnp2/lW8Hrfp3U1CUVSe382pyZLi7F7i7ge02FemX/OmmAZvYdKNN5ZIOycMMmDEEC7qWaz4MwZfRucMd6lPouI9CIjQ+3pSwzHVjHZMtRlRnPqzofyPGJ9aTBly6qShYFK5eyKnHgBQ7jaw5JHlMbTA2E+6c5dH4R4d5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776536046; c=relaxed/simple; bh=7RBn27jm2AVfQcHGM0Run5F5ojS7pQWf7fH3/FxJq4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZG+RsdsOsgmP89Y5bHlDxp3PU/zIHrSuscM175IWAj/95pBI06Y4D97LkIZLfgk0RznWXCO7bzet9cANZQFLvLLt9NCInKjj3INQ7bRGVmluw2lH1D17W2bxrl4nHiadTHjssEhX2bJY6vhcoFFeije6XBeq34LDcAv5Nn4ATSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eALkrFDr; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eALkrFDr" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-82f1bfc9b8fso742517b3a.1 for ; Sat, 18 Apr 2026 11:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776536044; x=1777140844; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kEq5CzQFwtAXQUDE7BtOjkL3C6G38PVDQBhAKTNWHjg=; b=eALkrFDrAHvlzw/c96wLEydh0GLNFhsEgQGrlraVxNIpyhKmp5Fpp1HMnk0KKfOYar JGKusaA17cJdbHEQzA3wK2QiiwwA785o6hIv8Uin/hqLXbTHDa0/0FD5UT0SyAhe+0Af 3dow/EBliWkLfRdZnywsnUiIZ0OTAQokGpUihUdSwzWr4Y/CUM1oWow83us3Y1YwrKRT GFbW8TXEOzob0UOmwmZ67/1+7TecuXQxK6QgNhP5Uw5FjZUURDvdkWQ2w9lExyFYKLgl +oT3DztYSiWmWViHF3+h+khG7RwgCreu7rWrNsD5O4O34b8BRr5y08SBkdbFt1n/dNCb QKVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776536044; x=1777140844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kEq5CzQFwtAXQUDE7BtOjkL3C6G38PVDQBhAKTNWHjg=; b=CaXKoafNf5Lv9BwQKStO+hjnDV0SWGQ8VMW3a3mqH6qb+tp5VBi3O7706fYoqfIiGl +q0Pb5jezJI65Tqt8lDEvQbONnhA5ezs9SOqnfNy9UoXAufxoTq1ggTGW6vSxO8KEFQQ lvJhi04pNmhteY7QD6+hqpx/2B3lHHx27ioiL4qil3GNc4bjfgjTrbJePbgTJYx+L4p7 Bk/AGgapjLXqE4HAvLsntVmlTxvUngoH3ZYD84Y7QRquw43W0Hp5GgZm9kb28wicP+cw SppCUYAlQqk2nmUdl1iAkBSk5gkw43wvb8YYAuW142w3u4RXXSXlVLp3fQqjk7WITLfV dfbg== X-Forwarded-Encrypted: i=1; AFNElJ/NsmhFIZDlojN0VTQqqaELoFJVxf5pVL+aF2nxMGtsKmkxuB1keTDvLD2E3MtkMMFD1aDtBSN7NuSFHR0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2kFh3T/D3hWf7MRA58Yntzxfhwla1uFQLViqQgxEDbu4F5sUf a9iDPK4IxzOOd2v0ndHrqndYYFxsCC3qykVmT7U6x6CeYlhcrb3HJlov X-Gm-Gg: AeBDiesiUZz7xg3SaZs6BxvR4ECzLFCPgPFlqw9HRgFZ/E8YHn9gTA1Ihks8jsbce2/ 9vPwe02X4jpIH6e1eS5ZKcLL6k/arYqY6JikaFG9psSVT8TRl72SLrl/iXYFXYHDdVc3uccRxWb PKvi+ezjFgxZFTlheq7rDo+wvYsgF9/nwa5M1ms6EFH1lxXEdqZLVbvCsElOZI5FvQOszq01gRp fpQC2lu2D/D/0JTFKIEEpfujrCgps+K4wWHLTIJfTUiSpgGEwjDQ7kl+BI5tVhgjdxq3zRf8+MP WawvDnFj0tqUlIWa69dvqqKLxpBlecc8udHocXQ74TL14Db6T4RTOasazf2aL4haCZwY3soWD45 sgG0H0n7N6mE11EGQOk+LHCCzgdDFTwytWr8nKKN2c8Ab0CJL9id7jUax4bWBmUNW552y8fDVvh s1hWmX3pc+Gp4bjwi/suRVr6lVOKiqvgYuFfGBae4nkiKpT6DKO6lBQ4+BWDJCwQ== X-Received: by 2002:a05:6a00:14c2:b0:82f:8332:4933 with SMTP id d2e1a72fcca58-82f8c7dd158mr7842814b3a.3.1776536044462; Sat, 18 Apr 2026 11:14:04 -0700 (PDT) Received: from DESKTOP-MUHC17F.tail07b66e.ts.net ([188.253.121.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8e9f7735sm5659402b3a.21.2026.04.18.11.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 11:14:03 -0700 (PDT) From: Zhenzhong Wu To: netdev@vger.kernel.org Cc: edumazet@google.com, ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, tamird@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Zhenzhong Wu Subject: [PATCH net v2 2/2] selftests/bpf: check epoll readiness after reuseport migration Date: Sun, 19 Apr 2026 02:13:33 +0800 Message-ID: <20260418181333.1713389-3-jt26wzz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260418181333.1713389-1-jt26wzz@gmail.com> References: <20260418181333.1713389-1-jt26wzz@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After migrate_dance() moves established children to the target listener, add it to an epoll set and verify that epoll_wait(..., 0) reports it ready before accept(). This adds epoll coverage for the TCP_ESTABLISHED reuseport migration case in migrate_reuseport. Keep the check limited to TCP_ESTABLISHED cases. TCP_SYN_RECV and TCP_NEW_SYN_RECV still depend on asynchronous handshake completion, so a zero-timeout epoll_wait() would race there. Signed-off-by: Zhenzhong Wu --- .../bpf/prog_tests/migrate_reuseport.c | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c b/t= ools/testing/selftests/bpf/prog_tests/migrate_reuseport.c index 653b0a20f..580a53424 100644 --- a/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c @@ -18,13 +18,16 @@ * 9. call shutdown() for the second server * and migrate the requests in the accept queue * to the last server socket. - * 10. call accept() for the last server socket. + * 10. for TCP_ESTABLISHED cases, call epoll_wait(..., 0) + * for the last server socket. + * 11. call accept() for the last server socket. * * Author: Kuniyuki Iwashima */ =20 #include #include +#include =20 #include "test_progs.h" #include "test_migrate_reuseport.skel.h" @@ -522,6 +525,33 @@ static void run_test(struct migrate_reuseport_test_cas= e *test_case, goto close_clients; } =20 + /* Only TCP_ESTABLISHED has already-migrated accept-queue entries + * here. Later states still depend on follow-up handshake work. + */ + if (test_case->state =3D=3D BPF_TCP_ESTABLISHED) { + struct epoll_event ev =3D { + .events =3D EPOLLIN, + }; + int epfd; + int nfds; + + epfd =3D epoll_create1(EPOLL_CLOEXEC); + if (!ASSERT_NEQ(epfd, -1, "epoll_create1")) + goto close_clients; + + ev.data.fd =3D test_case->servers[MIGRATED_TO]; + if (!ASSERT_OK(epoll_ctl(epfd, EPOLL_CTL_ADD, + test_case->servers[MIGRATED_TO], &ev), + "epoll_ctl")) + goto close_epfd; + + nfds =3D epoll_wait(epfd, &ev, 1, 0); + ASSERT_EQ(nfds, 1, "epoll_wait"); + +close_epfd: + close(epfd); + } + count_requests(test_case, skel); =20 close_clients: --=20 2.43.0