From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796089921; b=BFIa82BPnk0UXC12dXCtfSSFz4Qu3XMkdqPqzmr+kxYhUb0/fLY52onwzyDcGWP2lzFA H5OB+3p1hXK0oV7vmLLkFFJcVv27rbsBdARzaf2bbAKQ/6AQ1cciwTo5eHSgtiBJuoG4C DpYh4G2iyjkI0dXAVj/KPZL3mhxigtmF7IDWDvvUdN251Sa/4bv6GAdSpa/5uBOg6V+mH MEp2xfZTKb7gKqoYKIBtiHSmIVekX3fx/SYSCJw2UIgPO0VahY2qhdFNVTAxWoIRnJFRS TqoopAG+OXQlROR3TpARrMz97A7MzeGjUTEFFBSPgeOEK4nRrvK8g63WLMpY27nbCLw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796089921; h=Received:DKIM-Signature:Received:Received:X-ME-Sender: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer: MIME-Version:X-ThreadId:Date:From:To:Cc:Message-Id:In-Reply-To: References:Subject:Content-Type:Content-Transfer-Encoding; bh=poXvkgfwIVQq6SifDT3YpC21hbFXA1v+6PbPPn5KARA=; b=HswMGsFLDkFrD401aESF2ebxFpBmUe13HzqnJlPgnvc9Is+7Dj5mawU24sQRdmQpIKlj 83jGCSMOFzOByZvldqNoyuUp6PSRBjZLpyL+GypJnWdZ7XGRl83Hk2RkCVq6DDVRcOBKy DSVvYGKHNYKQ2vKoFJ3yNTg8zdy/rvvFUITwFMwjhvuwFTLZ6vT8r0RkyhE8qLKCtbYtM 5lb4VmrN1u6CgkXOR11jxBIE/pEyTtIonr+1aXMgTuRAu3N4eJSg9RrRbwt3PASIX98gl 5WBO7OQJ05itdG6GALpsacJNFg5ORYsca4igNpCLlalVpVsakEMjvDH5DFPDPE3r7qg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UODRugv1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40387606A320 for ; Tue, 1 Dec 2026 01:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UODRugv1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69AFC1F000C1; Tue, 1 Dec 2026 01:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796089920; bh=poXvkgfwIVQq6SifDT3YpC21hbFXA1v+6PbPPn5KARA=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=UODRugv1TEZqpwuuJ6FORwdl10BZIlmxogn133ELr2THbmH4twceFE9t1cxF1IYbm 7EWOBS4eT4AicAzIHrEDMdiLOJ4CuLGH9LRCuihilDy043/ukH+3bVc5+YX7cu8sJK OoRWLwe/iHgPtjFsf+zf3NKL83KC80DMy6yIgW424nm5xylYUL1OGOaalY5WKWhTp6 mbA/nHoqfEmOF1zLamjIZstC4u6BPxBz5VDQfHXIBpakpuXtGv0GFacpEoHqGyCK5h y42UOmBOHREOvPR0EqxCBrjuL7IAx/NdrqXhsGXQPpCBtOiPSNxV8IBiGC82CslKNe 6z8IzcQaYbIMg== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id 5A29DF40066; Mon, 30 Nov 2026 20:51:59 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-01.internal (MEProxy); Mon, 30 Nov 2026 20:51:59 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTF6ZmCU+cUS4Q3Bu9uE36/Y2VinXUYknSoyIwYfhgXYfpEY6+OvmPJy+xcypbWS1l hA09ksVEy8JzntRqltXV0pT08TWUdDcGWJhnW8CZtXU8m6IbFtQpNPJ5lvN8fwYGCzM7XR DD6ypWtO5YE8I5YkyehILD+O0hMy5LZo/wf7uHWBERDzKRCWn9POu56/oCA//R9e2O9129 PLypd0zgzz31P9KW6hBZmSxkjfTWrRzShJmxsJMktdJPlbOeemknkIurhyD/kol9YEnB/s AhvlU22q2z2K4aCSz/NsVGDGiU/L5OIf5YYOcDpxiH75fvsUOzeenQ7H800AdjYq6XBOU6 /UW13nJfr/gCx5AmpmtRNEvtO0s6UzR1aBreaQBsSzXlPYo2UGnSjgDPBTTlby5/BjxN+y ych6f8AcxbYivIQGGG0kep8qHSnO1GBQX5V1+uwgJAxwr0a1LXJSUAExEiUmMMB6Hm1p5N aVExP+LSucA2EPUIS8iPxAzPgXWxybO64kXd+HBVlZ6SdlcaEOmsuqvagyNxAuJqd6uoTV JC6HRvqwMGHg+5/sLg50sngAOpHAUmJjN+qJSuN1YyrM56LH5LKgrnxsyPVajtSuuHIALN pWJ6e9xufSB7n8qRNrsy30LonTIu0e6yQxJ/925A9dHHgf1tb6y8GkFwnbfg X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 3B577700065; Mon, 30 Nov 2026 20:51:59 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-ThreadId: ASYrBEqabBfs Date: Mon, 30 Nov 2026 17:51:38 -0800 From: "Andy Lutomirski" To: "Kumar Kartikeya Dwivedi" , bpf@vger.kernel.org Cc: "Alexei Starovoitov" , "Andrii Nakryiko" , "Daniel Borkmann" , "Eduard Zingerman" , "Emil Tsalapatis" , "Ihor Solodrai" , kkd@meta.com, kernel-team@meta.com, "Dave Hansen" , "Peter Zijlstra (Intel)" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Puranjay Mohan" , "the arch/x86 maintainers" , "Linux Kernel Mailing List" Message-Id: In-Reply-To: <52249df7401e63679e1ec5c416ef9b12d3ad318c.1795834380.git.memxor@gmail.com> References: <52249df7401e63679e1ec5c416ef9b12d3ad318c.1795834380.git.memxor@gmail.com> Subject: Re: [PATCH bpf-next v1 2/3] bpf: Treat __iomem pointers as scalars Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, Nov 27, 2026, at 6:53 PM, Kumar Kartikeya Dwivedi wrote: > A BPF program can read a device register with a plain field walk. Given > > struct virtio_pci_modern_device { > struct virtio_pci_common_cfg __iomem *common; > void __iomem *device; > ... > u8 __iomem *isr; > > all of mdev->common->device_status, *mdev->isr and > *(u8 *)(mdev->device + 4) load today. The verifier turns the first pointer > into a pointer to the struct and the other two into untrusted memory, and > each load becomes a PROBE_MEM load. The address is mapped, so the load does > not fault and reads the register. Such a read can have side effects: the > virtio ISR above is cleared by reading it. > > These pointers now have the "iomem" BTF type tag. When a struct member, a > function argument or a return value has it, give the program a scalar. A > scalar cannot be followed, so the three loads above are rejected with > "R1 invalid mem access 'scalar'". The value of the pointer can still be > read. > > Programs that load through such a pointer today stop loading. This looks entirely reasonable, with the caveat that it should reject a reasonably large class of problematic programs but does not reject *all* problematic programs. I don't think it can be the basis of a sound static is-a-pointer-in-bounds verification. --Andy