From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A84EC47A0C3; Tue, 16 Jun 2026 16:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781629122; cv=none; b=dxit9i0XJBEQxiQ1iu3S1l7qXAi733hCQpFy6N5rPWUvPN6RUblPhJXREHWWWa5AJwxi3bV3pOIWaX3v50NZmDtX2hTtG26Dc2LvhZP5pkN1G8dm2va7FMkFy4ihpunLWhLgavmvr+bpSE5cOqSNSbsxkDiEipdc+dcv6Kjuv+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781629122; c=relaxed/simple; bh=GELNaBhuWvzosa4uYLQXrCPk1msKPCti0TfBf2N9HWU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Co/tBiqnwXs16bFfJAV+w3uYZQ0tr8ZghbDylEDJG5+1D1GNxbl58RyErBE6ORrTS16L5sYNWbHbmnl+olLCHVfsTyOs4vJmwDuKJUKJ/Uz2KYq7JUf0boM5lrPiz4X6N6Y5+rxFnqxi0znpTMWTsOtYB5/ZG98TGZM8ONjP3CU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=I/rbV5PV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="I/rbV5PV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7C5F1F000E9; Tue, 16 Jun 2026 16:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781629121; bh=txjXTPt3wu3CP0IFC1Ii8XmyIFJZmHFX5/MkQ+vaG2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I/rbV5PVYXHLLAyYcgEaVnVAQ9QPDT1T1HHaAPqO2nviaC1JJKSiJ82LxzsO1Zbjq ethxrYEFt3Jmszu2IBhIaur9TZWMLsQ2UzxnWWlIsUpWHyPmJeK3yCq3d0nKPqfqBG uPa+EsDRDFhxbxe5FsmlpbVe/PsnCbZgnOQepAgU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuniyuki Iwashima , Jakub Sitnicki , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 226/452] net: Annotate sk->sk_write_space() for UDP SOCKMAP. Date: Tue, 16 Jun 2026 20:27:33 +0530 Message-ID: <20260616145129.612066671@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit b748765019fe9e9234660327090fc1a9665cdbdd ] UDP TX skb->destructor() is sock_wfree(), and UDP holds lock_sock() only for UDP_CORK / MSG_MORE sendmsg(). Otherwise, sk->sk_write_space() may be read locklessly while SOCKMAP rewrites sk->sk_write_space(). Let's use WRITE_ONCE() and READ_ONCE() for sk->sk_write_space(). Note that the write side is annotated by commit 2ef2b20cf4e0 ("net: annotate data-races around sk->sk_{data_ready,write_space}"). Fixes: 7b98cd42b049 ("bpf: sockmap: Add UDP support") Signed-off-by: Kuniyuki Iwashima Reviewed-by: Jakub Sitnicki Link: https://patch.msgid.link/20260529193941.3897256-1-kuniyu@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/sock.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 8e4c87a39dc87b..267f771dda1cc2 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2499,8 +2499,12 @@ void sock_wfree(struct sk_buff *skb) bool free; if (!sock_flag(sk, SOCK_USE_WRITE_QUEUE)) { + void (*sk_write_space)(struct sock *sk); + + sk_write_space = READ_ONCE(sk->sk_write_space); + if (sock_flag(sk, SOCK_RCU_FREE) && - sk->sk_write_space == sock_def_write_space) { + sk_write_space == sock_def_write_space) { rcu_read_lock(); free = refcount_sub_and_test(len, &sk->sk_wmem_alloc); sock_def_write_space_wfree(sk); @@ -2515,7 +2519,7 @@ void sock_wfree(struct sk_buff *skb) * after sk_write_space() call */ WARN_ON(refcount_sub_and_test(len - 1, &sk->sk_wmem_alloc)); - sk->sk_write_space(sk); + sk_write_space(sk); len = 1; } /* -- 2.53.0