🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9422

[PATCH RFC v2 3/4] selftests/bpf: Add negative test for sockmap update from non-sockmap iter

#9422
From: Michal Luczaj
Date: Mon, 02 Nov 2026 01:16
44 lines
10191 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: <20261102-sockmap-update-limit-iter-v2-3-e96a63c43b39@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-354413-linux-kernel-netdev=dewy.ru
References: <20261102-sockmap-update-limit-iter-v2-0-e96a63c43b39@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-354413-linux-kernel-netdev=dewy.ru
From: mhal@rbox.co (Michal Luczaj)
Newsgroups: linux.kernel.netdev
Subject: [PATCH RFC v2 3/4] selftests/bpf: Add negative test for sockmap
 update from non-sockmap iter
Date: Mon, 02 Nov 2026 02:16:00 +0100
Organization: Usenet Network
Message-ID: <20261102-sockmap-update-limit-iter-v2-3-e96a63c43b39@rbox.co>
References: <20261102-sockmap-update-limit-iter-v2-0-e96a63c43b39@rbox.co>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2817649"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IpD/cpNBVL677Zp8etQkDZDQLhY= sha256:EYRdI4gP7eNQWMICl0HyGwuv59gb5MH/ucq9NIPi+aE=
	sha1:py8+7R5rFDauNLCQRFoSlNZUeQg= sha256:I1z6CYfmx37pxUWpwgk7WxiLIClD/cNjjfTHBl2RPWI=
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 814801123EC; Mon,  2 Nov 2026 04:20:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-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 yquJU6Nasxop;
	Mon,  2 Nov 2026 04:20:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354413-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8F04D1123E7; Mon,  2 Nov 2026 04:20:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C3405332E3; Mon,  2 Nov 2026 01:18:29 +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=1793582308;
	b=xy+7YKBwAcTdsEBpBYbZYkkczaF8YC9UEDatiRzFibrgQMypr9AO7r9zdW0XixpQuhJj
	 dibWjupnVQdMixlRv/epTsG3Dvn8Lrx3PLVGQNa6YbrFmUs5zT6fApWVkPJVfN9OfZ3r+
	 XPSL274j0e8ZAjdGADVroM0GwUpElaYi6S643AlxGrD8bf2sxMHZSnOiKYHe8KDvX0Rqc
	 UDbtsFLe3QIhGyzPo/f8ZDs8aXo2fEbtDk44ICvhIaoefD1H9qP0+/i1M/EUZuSmW/Nyc
	 yey5jGQUdJaPHmrvNV1u12p227iUFPka9rm2B8V2By6V2HjaiPqpwor5iW6WaLSPGwg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793582308;
	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=rXa5x7rVAupo/aTD+X4X3TDpM/vutfSSz7XzdNPlashKy3Pjj7Tqp/P5Ezxfr/oQth+2
	 g6fX+CKX8v0wgCP33u3W31HZ36bYQbwMMFfTXjPEDaQ2aLnKGiq+iZkwxPmp4PLAIgNqN
	 7lxCBKaC/Ml2exnOXUh++npOuKcZAu2o4In/Lo5hRfQ07sNJ0MUcCCK4y9uC1DRQQwDun
	 qcQko7j4ACdSVqbFGeSdmnR9FIYSN7BkLMRIBfGL8iBpLBuhperV1WY7tKhYS3+kl+ZuT
	 fLa3EbTHd0K8LBv/76Yr6IwJzvzwbbvSeYfR/3ijwutm5VZ51i7gdQ5kF3WdfmMdIwA==
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=c2PXHs8K;
	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 CFDF360A2606;
	Mon,  2 Nov 2026 01:18:28 +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=c2PXHs8K
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=1793582305;
	b=VK4+Zj8UFtdvcVH/5aGsV1dh6CXtoiJwlEPJtyYep4Xkb8XR2ebKLPiR7pQfn2vjG62O
	 piQTYj6E+ntVSBdtPtGsH6gPKw66xsM9FlS8I/SnEjPcSrAGUDRBbRPyUcaVGzOxTR+cc
	 9RgEwZmhHCk3tj9GW8NhnvFmJVI347j3Y+nb7NPx0Vp2wh1ql3a2uKkIZZcz/hIzeiAfP
	 hojEGhGOnmIzb+xjlM6gB+e2h6kAOZPD5/USX6tN/9bIqMPlHxToPHjVbRJFuQ3QUYrjd
	 /rRQHndHmV3sSAFMnIyRI56CxdbBSng6aFNHdYaD3e1T2qTZTS+UOugoPsHh3sNbWDQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793582305;
	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=TrkgeKUVMr8D0h/8Omph1Ml4YWkcoluN01uP/AikJStnsDUCa2ddoR9TCjLFeFnuy1LF
	 qrjEjI84ITVmKuc39ILjcgMNe1GSvf8nhbkzwcMLuaktrsSbheB4a9elB3rwVEmdoLpGq
	 TmjL1/vd9orhh/F8GIH0XFjzaHBjNHwpDQyAepW3wLK8budcYYyz+DmqcgntLMtJEoH6l
	 QHTmDboPT0FnTJ0sNc5kARfM5H4C5SwQO8pdEYM+MlECYb555OYIibp/xaxXoqg2qLeHZ
	 na9yyFat0k1w6Jq3+iuT0irOJbw9QeDV2EbqRbJ2IbIMlGVLEGlnJqJAfRHpx+Mub7A==
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=c2PXHs8K;
	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 3BF00606A33A;
	Mon,  2 Nov 2026 01:18:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3BF00606A33A
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 mailtransmit02.runbox ([10.9.9.162] 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 1xNggX-00AGXe-6y; Mon, 02 Nov 2026 02:18:05 +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=c2PXHs8KRsgW9UWcr2KfQHUaQE
	NNuvf3fwHRDgFlsPa01PTWBxCE9iCcqTLOjl5pGwfKFCufXOtSMCcu+ZUbGAX5bET2OkvXaQMFJAf
	NpU+jSHm5V2jwdapglOjf/F3mM3N1sUFbgOTi2raWCk3W+VryXuMz+XjvgCdGr4tuaeZo4t/wigaX
	PG7tm/p2XKpb1NvH/9oGvtM3Ux8wO4nbDpXNBcy41tMtKICFKvHapzDaGO2+gs5tbCxrnBd94aI3u
	vZ3ugY739fK39fwMGQN7bG5uvHfk9U4hGiWazMVNDTvT/NqL2djYvYzWO13CGWKe3KtatmxIMRAB9
	dhcXKSjA==;
X-Received: from [10.9.9.72] (helo=submission01.runbox)
	by mailtransmit02.runbox with esmtp (Exim 4.86_2)
	(envelope-from <mhal@rbox.co>)
	id 1xNggR-0005s7-B4; Mon, 02 Nov 2026 02:17:59 +0100
X-Received: by submission01.runbox with esmtpsa  [Authenticated ID (604044)]  (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
	(Exim 4.95)
	id 1xNggL-008JiF-Id;
	Mon, 02 Nov 2026 02:17:53 +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: <20261102-sockmap-update-limit-iter-v2-0-e96a63c43b39@rbox.co>
X-Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, 
 linux-kernel@vger.kernel.org, Michal Luczaj <mhal@rbox.co>, 
 netdev@vger.kernel.org
X-Mailer: b4 0.15.2