From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 C01983AFD00 for ; Mon, 8 Jun 2026 08:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908774; cv=none; b=O0ykkPffq08dBF4r82aXFu0nRF8yIPUWmvghNV70255nu9E1ChC6GhC7jkPWjVP+N/i8hQic8bJUuJ/8fhuT9nNcR4G7I2BUPKHLM38joYVSAF9fcCISesIe7JurpAflXh0sCWJETEA+Onv9eDT80v0Hh+cgviWkdqF2rRJZw3Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908774; c=relaxed/simple; bh=71kngNLglTQFWzZYkjVAWT0fHT+5MJVHKiuaOh/1EgQ=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OpXBqGra/YPitRJsM442VemQBTYFZG6Guea/NhecxeRmUT9MPWsUZlcqhuMTKTJoaUmS9vH3JkWQI6G5xifdDoN/RF0q7gFNPZIUwnauo/W1UpAHptJVJQUfVjaq9CgbyFqG98YraZA4FnTl+iY5dxfWgASXj1O7EHZJPszuuRM= 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=IOFTK4Ag; arc=none smtp.client-ip=209.85.221.45 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="IOFTK4Ag" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-45eeba68948so2788248f8f.1 for ; Mon, 08 Jun 2026 01:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780908771; x=1781513571; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=RAmzFalsZ1626ri7eqynS376s1QmdxkNtdz+K5A5+m4=; b=IOFTK4Ag/Fh423MXLErk25yqTc/H6GVAub/458cV/r+cGCGj/fTnQdeEqQyJvwkA7S qRshw+rSQOex2QIdvzssxJ90ysoVDk9cefNRdZenzfK2/5sLUen7O4nfwScdtz81DmOA DqMhOHQfju0U4/4y5Ct/FDrffrqw69KGj+kQNpU/GhgcKTLi7/B/ZPqUrXZbG2Iz/C7X nQnLHM7xIsc5MdXMzmYkdSJpMxbHR3t8bGt0AksjW7aH2HeXSyadL2ZcE5MGrL0oS0Ma 3U2ug8NRcoJMgO3RdrMwVPpzzIrUFgXo/vwqTS1xDZx/1Ulfy1WZtLoSemz84aLsictQ aWIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780908771; x=1781513571; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RAmzFalsZ1626ri7eqynS376s1QmdxkNtdz+K5A5+m4=; b=suEfrRsk6gVpkxrUGGyLjx+c23c0hSNTec2RAiM4bshwheSgaRb1/rUQYWrZYXs6du VHgKVLWFegGd0VPOJMxUPOWX/9HvY/T215iEFkaNVRGNiiCt0oiv26aVf7wddN3OYaM3 x4DX2Ho0f+GDtpaenN+JnsTo8M2TIFcfsSJv+1pmePvg1opmW2s6h+jawATF7j9aBd8q 2hYV3RG8LyWxBexec1xM4mfa7p3m+IOHMiAXxGZB06t+xpI+lxylT+aSVhvNvZ9WzJQJ ZoTHgldWyxjpnQxogbrKCSJEYPboAxNXckIKQh5jZrylXxA/tCB0DQuHm0F1O+iq3Rrg rEuQ== X-Forwarded-Encrypted: i=1; AFNElJ9DM74KYrg7arjpkA7qBVxGSXlTGr5uG8p+JNYRZZGEqkVo5SaUXJRR0X4vMswJqLLK0IB1AqAW9v0tErY=@vger.kernel.org X-Gm-Message-State: AOJu0YyB3Yi9uLKcqA7211OuX5TlV+qdjfgR+vfCOM45hRadJhphKsXi HzMKqk8REr4h+sXDac/4ZFoVLdqKhTEPH9f+cTJ5rJVtllgHsMgHtlB/ X-Gm-Gg: Acq92OGfFI5oJTMddSkYQ4TxjM92hUuQy4eOqTh7M0sOryvb26cxuwPDW2owMqPWWKk SkARHRpZmBheAcf+Mdsg/7vJBXgHzuRMFA6qr9Vpg8DLhq814xYMBAnPu+CCgubGptTiiD8LTtl twcSjgVnXwRVS/v3Y9kctQWCLqF0cSKt5aUKhmHe8Gt3zp02i36B39Jj67hVohJ1gGzqBQotIDq 7+INwmNGbcvTyqdBKfdYMRDQ1Uu7J4l2L/DvssbyvxuKE0qMRp+ZCMchmIe4o7razZODu2nV3i1 b/F8kfjP14G8Lseo3RUXM2ctdR7ICKrYneLUevTKkPSGEEfRyVzm8vnihOADkAKumItRY7fdraP 5tEC+tio9WnMqKHKlZkDf1J4byFYtbAFolaz2R7T+t/XDC3VDWUdpg8wVFF912FXIbyVNHjxwpV emGMmlcAKv/sDcUcu0IEW8mw== X-Received: by 2002:a05:600c:83c3:b0:48f:d612:3c59 with SMTP id 5b1f17b1804b1-490c25a21a9mr267462155e9.9.1780908771176; Mon, 08 Jun 2026 01:52:51 -0700 (PDT) Received: from krava ([176.74.159.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc413adbsm378495555e9.15.2026.06.08.01.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 01:52:50 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Mon, 8 Jun 2026 10:52:47 +0200 To: Nuoqi Gui Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Daniel Xu , Eduard Zingerman , John Fastabend , Martin KaFai Lau , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Shuah Khan , Ihor Solodrai , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH bpf v2 0/2] Keep dynamic inner array lookups nullable Message-ID: References: <20260607-f01-v2-v2-0-da48453146e8@mails.tsinghua.edu.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260607-f01-v2-v2-0-da48453146e8@mails.tsinghua.edu.cn> On Sun, Jun 07, 2026 at 09:24:12PM +0800, Nuoqi Gui wrote: > An ARRAY_OF_MAPS can use an array created with BPF_F_INNER_MAP as its > inner map template. The flag allows a concrete inner array with a > different max_entries value to replace the template. > > The verifier currently uses the template's max_entries to elide > nullness for a constant-key lookup through the inner map pointer. At > runtime, the lookup uses the concrete inner array's max_entries instead. > The verifier can therefore accept an unchecked dereference even though > the runtime helper returns NULL. > > Patch 1 keeps lookups through BPF_F_INNER_MAP array templates nullable. > Patch 2 adds a verifier regression test for the unchecked dereference. > > Before the fix, the regression program is accepted and the runtime > reproducer triggers a NULL dereference. With the fix, both programs are > rejected with an invalid map_value_or_null access. > > Tested by compiling kernel/bpf/verifier.o and > verifier_map_in_map.bpf.o, and by running the regression program and > runtime reproducer in QEMU before and after the fix. > > Signed-off-by: Nuoqi Gui > --- > v1->v2: > - Update the can_elide_value_nullness() comment to match the changed > parameter (const struct bpf_map *map). Acked-by: Jiri Olsa jirka > > v1: https://patch.msgid.link/20260604151153.2488051-1-gnq25@mails.tsinghua.edu.cn > > To: Alexei Starovoitov > To: Daniel Borkmann > To: Andrii Nakryiko > Cc: Daniel Xu > Cc: Eduard Zingerman > Cc: John Fastabend > Cc: Martin KaFai Lau > Cc: Kumar Kartikeya Dwivedi > Cc: Song Liu > Cc: Yonghong Song > Cc: Jiri Olsa > Cc: Shuah Khan > Cc: Ihor Solodrai > Cc: bpf@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-kselftest@vger.kernel.org > > --- > Nuoqi Gui (2): > bpf: Keep dynamic inner array lookups nullable > selftests/bpf: Cover dynamic inner array lookup nullability > > kernel/bpf/verifier.c | 15 ++++---- > .../selftests/bpf/progs/verifier_map_in_map.c | 40 ++++++++++++++++++++++ > 2 files changed, 49 insertions(+), 6 deletions(-) > --- > base-commit: e7ae89a0c97ce2b68b0983cd01eda67cf373517d > change-id: 20260606-f01-v2-324fb92185a2 > > Best regards, > -- > Nuoqi Gui >