🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12533

[PATCH bpf-next v3 3/8] selftests/bpf: Add negative test for sockmap update from non-sockmap iter

#12533
From: Michal Luczaj
Date: Sat, 07 Nov 2026 17:58
44 lines
10226 bytes
Iterator-context sockmap updates are now restricted to iter/sockmap. Add a
test that attempts an update from iter/unix and expects it to fail.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 .../testing/selftests/bpf/progs/verifier_sockmap_mutate.c  | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_sockmap_mutate.c b/tools/testing/selftests/bpf/progs/verifier_sockmap_mutate.c
index 20332a731d4e..1516fe1524bb 100644
--- a/tools/testing/selftests/bpf/progs/verifier_sockmap_mutate.c
+++ b/tools/testing/selftests/bpf/progs/verifier_sockmap_mutate.c
@@ -19,6 +19,12 @@ struct bpf_iter__sockmap {
 	};
 } __attribute__((preserve_access_index));
 
+struct bpf_iter__unix {
+	union {
+		struct sock *unix_sk;
+	};
+} __attribute__((preserve_access_index));
+
 struct {
 	__uint(type, BPF_MAP_TYPE_SOCKHASH);
 	__uint(max_entries, 1);
@@ -113,6 +119,14 @@ int test_trace_iter(struct bpf_iter__sockmap *ctx)
 	return 0;
 }
 
+SEC("iter/unix")
+__failure __msg("cannot update sockmap in this context")
+int test_trace_iter_unix(struct bpf_iter__unix *ctx)
+{
+	test_sockmap_mutate(ctx->unix_sk);
+	return 0;
+}
+
 SEC("raw_tp/kfree")
 __failure __msg("cannot update sockmap in this context")
 int test_raw_tp_delete(const void *ctx __always_unused)

-- 
2.56.0
Technical Details
Message-ID: <20261107-sockmap-update-limit-iter-v3-3-7c0bad1ad036@rbox.co>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358456-linux-kernel-netdev=dewy.ru
References: <20261107-sockmap-update-limit-iter-v3-0-7c0bad1ad036@rbox.co>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358456-linux-kernel-netdev=dewy.ru
From: mhal@rbox.co (Michal Luczaj)
Newsgroups: linux.kernel.netdev
Subject: [PATCH bpf-next v3 3/8] selftests/bpf: Add negative test for
 sockmap update from non-sockmap iter
Date: Sat, 07 Nov 2026 18:58:25 +0100
Organization: Usenet Network
Message-ID: <20261107-sockmap-update-limit-iter-v3-3-7c0bad1ad036@rbox.co>
References: <20261107-sockmap-update-limit-iter-v3-0-7c0bad1ad036@rbox.co>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="4158768"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cOEJZzc6aR2e1Ii5ydQbX8tF7rA= sha256:4Pzno5vBiXB7k7512Qyf77rCRJlaiGSarvsrF8J81sQ=
	sha1:oUulMkgBNyJUI7b64TeZ6Mxb838= sha256:7nV9OKqkuojHJqLux0VieYxsrIEhbo+ZoIPA9Asc2Ow=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 98EE211346C; Sat,  7 Nov 2026 21:01:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=rbox.co
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id V8zhY9M_7-5y;
	Sat,  7 Nov 2026 21:01:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358456-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=rbox.co
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 0C9B711346A; Sat,  7 Nov 2026 21:01:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 1EC5784EF4; Sat,  7 Nov 2026 18:00:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794074393;
	b=Ykb5BllUcrn338yG1PL8OaygwWh3tWiHf0TYyiM4QLz1cwA3esN1V65SEJQq2HaRCP41
	 9xviLK18Khpf7fOdMZS1uozBGhw65iltBPjYPB3Oymf8thLV21nVPcbtvW0LWHBYM11iN
	 PibDaj7X88UfLDSS7jEM2HAgqj25DNKl4NmYvsTuPRj7fLH1Izhu0Qu8H0MOEqhT5o6Xy
	 PACWmZekaBtgU1LobOLqBSgWWfOCUc5RQBps9Fc9PGBJuv/LVTFvpZR+Mvk5I7o0C5TDs
	 ugHwZ+Y8oHXRaBzTutxA0bCifjzDfcQog+el9feePgOm18Q4JNJDLgwMWHSBFClP8OA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794074393;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received:
	 Received:From:Date:Subject:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:Message-Id:References:
	 In-Reply-To:To:Cc:X-Mailer;
	bh=+cJ3MC7LUXBbC4N5bF/0Djg1Hg9lFmBTuLmxj+Rq3SI=;
	b=uEBVyHf8DSBHlgDS+QhcvFEwiY6lL6KD7Cg/4uUydHhxneqvX/ClA1UVBgXObvLfy+1y
	 Qz+7CYuuSrhRvC0BzHgAJkSh6QmY0zgGrkgatA+oEwdbGj1F8Z0BH/mYYcTQPVPZxwaa0
	 eDj49AvNfvbAy1NExl5viexO+dMBuDTE/GN0mUrf3zE+Rcnna7ru0F87NbZQvI6a8Wi65
	 DJcAaJjYXMI5CJ7EmVaNcnoDR7ZEr0Hk7KrSu7t4CU07/u+xmjnSgjI430TwrHcQVYBLz
	 Ex9mJV38xRUdQgij/ZoXDREWWkIRbW/6tfsJXetYu6WfTmzmvcn2ZQWO5jpU4BsmMCA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=rbox.co header.i=@rbox.co header.a=rsa-sha256 header.s=selector1 header.b=wpYScCIz;
	dmarc=pass header.from=rbox.co;
	spf=pass smtp.mailfrom=rbox.co;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E91F606D80D;
	Sat,  7 Nov 2026 17:59:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=rbox.co header.i=@rbox.co header.a=rsa-sha256 header.s=selector1 header.b=wpYScCIz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.226.149.38
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794074387;
	b=W6P2RXI4PFC82B7BjRIQoHvo5A0AnUA6dQNeVpI1fbkDmdBsO8VcDQt6K3BICUWiy7QK
	 h1PWlnb4mlWGDn8Ea7+AAZ3VxDOgKON3pVnEQe4CZc7AMQNiKsomr38Y3xH8scu9+YhGE
	 M1omEx+x0IqdPiWOcWWU8VzRvPTRL8vBEoDo2uAfKARYcm5BNsUfonQzmulbfBT+2TFzB
	 p7PNCZStdz7dF6Njq9H9m3bibW/QvRfeatLWqXSfC+keL4959gKIEqQq8A26FXBWdQO32
	 S2fO6RJCKu1qbueksQni9w3njD5f33wZuN7OT9ubVzmzEGud17U2BMn94c8XYnF2fZA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794074387;
	h=DMARC-Filter:Received:DKIM-Signature:Received:Received:From:Date:
	 Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer;
	bh=+cJ3MC7LUXBbC4N5bF/0Djg1Hg9lFmBTuLmxj+Rq3SI=;
	b=y4w4ZSRgTT9K/GZFSwPWyHyDLHWyRdJRIDXcYeG3yAZ74JoAqrTm5xDY+j6fikp41h4A
	 uvS9D8KSR/XWIZaJcB6vnA9PeTWGD+zbWXlgnBWK51BJVSazG2kzz/r2P59g6nxWaRvYW
	 1Z73NjXouTlj30UPYJPvpTfC+TaAy9nSgM5EUnmg4wicCmBH28jqR5iLrX6qVi753YPw3
	 MOs8H6XLS19HcYQfZX19kLRu9XQBjf1GFjC9bfiL1BV50vkFEXHub3Dzw26hht8uPuXfi
	 Lzz5kgg2WRhBxMrrxK4a3aOFF3QiLO2rcJ9RsCRIZPSNDw4qkptAFke5LVDOooQBaFw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=rbox.co;
	spf=pass smtp.mailfrom=rbox.co;
	dkim=pass header.d=rbox.co header.i=@rbox.co header.a=rsa-sha256 header.s=selector1 header.b=wpYScCIz;
	arc=none smtp.remote-ip=185.226.149.38
X-Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78B60606A33E;
	Sat,  7 Nov 2026 17:59:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 78B60606A33E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rbox.co
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rbox.co
X-Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com)
	by mailtransmit05.runbox.com with esmtps  (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
	(Exim 4.93)
	(envelope-from <mhal@rbox.co>)
	id 1xPkhM-007oTx-S6; Sat, 07 Nov 2026 18:59:28 +0100
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rbox.co;
	s=selector1; h=Cc:To:In-Reply-To:References:Message-Id:
	Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From;
	bh=+cJ3MC7LUXBbC4N5bF/0Djg1Hg9lFmBTuLmxj+Rq3SI=; b=wpYScCIzPC97U4nSU5l2hXFrnK
	okbOpkoNYSPUm7S23aDRjtE6AaJzWO5f65ERMT5E5JTGw+xKtFNAAcJdxSmGLpwrIVOjOYnMogf73
	q9TLrqKY3HIOPSbi+1WWvYHM0a2/MswqKtwY/h+0aHPy7dtLZaioF9SN7p3KR4kYFOUCLopJdfoNp
	f0Wc4/X2Wtys2nhkTRCE+laTyEniv9qfqQwt/nmak/DyyoBnNOs6t7uQHG/ruKU4DCLgp1VNCdIJ5
	tczqFqPrs6l3kblhBrrrOYWJxEuWu8LGYTG82/29PQtUuaL4pCpISaTpcXfje5JrJok3HXpa83EJZ
	Fxubv+fg==;
X-Received: from [10.9.9.74] (helo=submission03.runbox)
	by mailtransmit03.runbox with esmtp (Exim 4.86_2)
	(envelope-from <mhal@rbox.co>)
	id 1xPkhC-0006av-7l; Sat, 07 Nov 2026 18:59:18 +0100
X-Received: by submission03.runbox with esmtpsa  [Authenticated ID (604044)]  (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
	(Exim 4.95)
	id 1xPkh3-007LnK-Ez;
	Sat, 07 Nov 2026 18:59:09 +0100
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261107-sockmap-update-limit-iter-v3-0-7c0bad1ad036@rbox.co>
X-Cc: Michal Luczaj <mhal@rbox.co>, bpf@vger.kernel.org, 
 linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, 
 netdev@vger.kernel.org, linux-doc@vger.kernel.org
X-Mailer: b4 0.15.2