From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 D2D642045AD for ; Fri, 17 Jul 2026 15:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303635; cv=none; b=hlMfXFhzI+RbSJlugOBlM60Cff+c0mwYuw7D5RHa0Y9dnGbUcsIWzpNiS5OELXHLy4CrYHFQVlzGYeSk9UMLs0v5S2VOkAAtoxYhp86JMeI5nzdliXi2gn+xkgJl2ocaML9bjg9rMAhGwzfAGGUzQrY8wIwda4g1+lCHifeMfC0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303635; c=relaxed/simple; bh=YF9Knm40lON0FlUgiurO8Nd3SbRk4kttQ+DtP+b13jY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EI6PnRgq6aC7KLb6bKEPCTQBTB7mQtQyqZM+aoN7v6zrneTmrSCmaS3Y2VT4PX9A6BQI0fF1rgeyoBrcUW6GSI/Er7PLdJkOtenjFq8xrUMlcDlNwcFWJxtVyG1RmNLTTWGzpZ9PiYmdeV1NMXB09cXElzX1eOmyA0uIJSxLgfo= 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=ixVOyCd+; arc=none smtp.client-ip=209.85.221.53 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="ixVOyCd+" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-47df440fcd5so4370971f8f.3 for ; Fri, 17 Jul 2026 08:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784303632; x=1784908432; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=KgKTphT/EPBidWmUJpQky4fuu3ayeXNP41GXKcwaXpY=; b=ixVOyCd+G5zisdrc5ETx7nVumKoUjZCxACN6n/wSNEB1YtfxqWczAEduIV05Wjd/DK CM+FYVBml/Rep19+YnwjcZTtghC7xlCrFeI4tQe8h/NnYIPkV9CLyRP5JtslX7g0rv96 rxTY94Z88ZujwGaGJVcJvX99ce1kxwbQDDjOZGB470J+Ev7ayjM4eqXukkbepavFEszc pHDhcMQgIDIHrDT9c7QyyL81iDXuMqp/ZokvlNRXxZ7qYCYodqt54cc8doh23bXcfccx XlGJKa5Za3WV4i9VZJIPlDYJi+IgbSZdnEEwGK0g4CEA8jvADJVnliwisUfBGvu6SBuz Wp/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784303632; x=1784908432; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KgKTphT/EPBidWmUJpQky4fuu3ayeXNP41GXKcwaXpY=; b=DUtFm+NrJCqSnWQrMKVDSy5wAG7PPPGS9Vwy4TILLf5smmOHLtE7qAlCv31l3TD9V8 LgjJx8JJiuVa5i4SEIR8t8cC984o5BvtfeQINA7HoMu9zOvwKrMysHalQS661YmOUC8t okksstXKcVJZQS9Q5y9s/lV/MfTUP2QkoGA4d5GGPnon5DjtX/h4U2Be47kPSrWa/gU3 yTtkTaOYWX/kDAH3AR5FEF4ADiTH34LW+ZbDdyvBy88CldHR2leYbjPgqIPs9ZtTxM0X 3DxJG91HKo52hfAo+tjTEZEI6J9txiytAUnyvHyNQHUGBmQL1tmrzz7iWO1dLWJcmE/t Mm1g== X-Forwarded-Encrypted: i=1; AHgh+RqlwmQAZtpm15Fq4RDdiwz41vukpixWV9/5XMppah1o/kL5FpQ7/m22H7Hr+FUE+PUBCoOR5q4oIWoBuhA=@vger.kernel.org X-Gm-Message-State: AOJu0YxVCsiR2+MqC6mzejNa+uZ3m0H35wejbuR5u4vdp+WZHr24H98S 41QsXCne2dnryGD5RDjRQ5LzQTcssI/lVuJIT3u1jCp45lSgCyJnXEPM X-Gm-Gg: AfdE7ckpQoc416p/OrUC/OmMkRgWbtawVDMyrGHtHVvHCOz6QjmsNOMNpB7gtn44Jvj 9pAwsrc/dvLty3EiPeY9Gi21xfg7HWZvuJJkgToD5d70XwWWcK0y0uNfg18NPMEiYICFiBLYgjB S55ZDS/4Nt4cQLiEj3beCxjF/NlXbmo0qZ/m7jK0H1t4QueeMvrJWw2l1O/VCLjv9/PhzLc5wM6 mWW0ICe53lXTrr+YCMfJUQqOezHLZJksDLVWXWIPVLSymm/j707FbSbkgQbJDCmeivnSvNCuuqV UoFfiUvSH163aqi70dFhI4vothHrdLz3AGbnGHUFSiOIG+3PAQg2XeDvW49thTPRy4+xbur59gQ 9OF05mdtmcZyztgGoTQ5mcOYGb2i/S3aWteWVLopBDGIijtqzpecNNpPI9kobAaROxedOy09Mtc gEx83tVLEo7Mn9+zUij/3kD7cBpaUEJjaIf/U+Z142qGNK3rKwRInIIOqzM7Q+2ECXeg== X-Received: by 2002:a05:6000:2213:b0:47f:59b4:3933 with SMTP id ffacd0b85a97d-47f62330c15mr4105029f8f.42.1784303631863; Fri, 17 Jul 2026 08:53:51 -0700 (PDT) Received: from localhost.localdomain (host86-153-201-25.range86-153.btcentralplus.com. [86.153.201.25]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edcf8dsm5321369f8f.27.2026.07.17.08.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 08:53:51 -0700 (PDT) From: Nnamdi Onyeyiri To: nnamdio@gmail.com Cc: bpf@vger.kernel.org, davem@davemloft.net, edumazet@google.com, horms@kernel.org, jakub@cloudflare.com, jiayuan.chen@linux.dev, john.fastabend@gmail.com, kuba@kernel.org, kuniyu@google.com, ncardwell@google.com, netdev@vger.kernel.org, pabeni@redhat.com, sashiko-reviews@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v5 0/2] bpf, sockmap: handle spurious tcp_msg_wait_data() wakeup Date: Fri, 17 Jul 2026 16:53:46 +0100 Message-ID: <20260717155348.54975-1-nnamdio@gmail.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Spurious wakeups in tcp_msg_wait_data() isn't being handled by tcp_bpf_recvmsg() and tcp_bpf_recvmsg_parser(), leading to unexpected EAGAIN errors returned by recvfrom()/recv(). Adding handling for the wakeup and a selftest. This issue was first discovered in an application that adds sockets to a sockmap as a way to view the received data. No redirects or any other operations are performed. Sashiko has noted a few other pre-existing issues in the same area (https://patch.msgid.link/20260714205118.17DB11F000E9@smtp.kernel.org) that can lead to EAGAIN in tcp_bpf_recvmsg() and tcp_bpf_recvmsg_parser(). A local run of Sashiko also identified a potential issue in tcp_bpf_recvmsg() handling zero-data FIN packets when the MSG_PEEK flag is set. To prevent this patchset from growing too large, I intend to submit follow up patches to address these once this one has been accepted. Changes in v5: - Move selftest from net into bpf/prog_tests/sockmap_basic.c - Link to v4: https://patch.msgid.link/20260715213538.37229-1-nnamdio@gmail.com Changes in v4: - Fix potential data loss in tcp_bpf_recvmsg() when a FIN or RST has been received. - Check the return code of pthread_create() in the selftest. - Fix race caused by using EXPECT macros in a thread in selftest. - Link to v3: https://patch.msgid.link/20260714203927.32289-1-nnamdio@gmail.com Changes in v3: - Added the sockmap_recvfrom selftest. - Link to v2: https://patch.msgid.link/alFRK66z45eDNZA7@localhost.localdomain Changes in v2: - In tcp_bpf_recvmsg, handle signals and the socket closing in the loop. - Fix spurious wakeups when SO_RCVTIMEO has been set on the socket. - Link to v1: https://patch.msgid.link/ak_rR-Skd8Mvn4mH@localhost.localdomain Signed-off-by: Nnamdi Onyeyiri --- Nnamdi Onyeyiri (2): bpf, sockmap: handle spurious tcp_msg_wait_data() wakeup selftest/bpf: added selftest sockmap_basic/sockmap recvfrom eagain net/ipv4/tcp_bpf.c | 69 +++++++++-- .../selftests/bpf/prog_tests/sockmap_basic.c | 115 ++++++++++++++++++ 2 files changed, 175 insertions(+), 9 deletions(-) -- 2.52.0