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=1796382091; b=ChAnc7XlJ1ZwiTpJbbnOSFpTmKhPBPDiMbby1s9KsfbW+HvHvJGvvfOKvhfB/9QeJNMw h3uko4fy/lk9NXeAj4m5LqI2AEPNtNBpCbyc05jRXAV1yomQXlaBBAaSPlize1mUGQEqH 9P9usN0VsSfoJOdijGjFBHkAnOoHINsHpFe1MGyEvsMNx/4bLwpUYb43S3CNutJQE8JZL hKoKQpXTjU9Llnp/8pdt/WKF9o0SwbDssO7MJP4NnqA9RF4ndzuJA+kaTylDbO5gy3NM5 yd+v9shGaUumE6fyCK5Axs/zphZ9XCEetgeKxPtgiRXRxxee3M5vETghatu5fgM9gag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382091; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=YT6nwosfejUIRFZZNGT9E0J3w3/W6qMsZDZtrlurkSs=; b=jVgIkAIIAibRa4n21rqEWqxhm307aPAfL/cnmSFoNFaNDjQHFyY7VphAXvXH/cNAIkCr D5BK95OckLudBhXeqgK8L3s00UBS/+6FVgXZMXE9d2qCTKRGK8Gd01Of8vgu90zBSgEoY iASl6Wu+R1/lUd9oDctLNYAr/hjmhpWRuT57zgnRh+BDlpyrZxUpZ57Re8XPQRcX8vnFU rThzYYOWHiBAwbK77PdZ/eiSKWsOlwUHOWNlhoTzskbv/spYjKaajKe8hXMGZtns86gn3 9eF0MVu8/yfqM7A1QBDjx+k0Lb+ISdmpCf3IbSsvDWUM8i8RDP2D6s58LVVMQWMPlug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=e3q4Iw7B; 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 0F6E9606A322; Fri, 4 Dec 2026 11:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=e3q4Iw7B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A85D1F000C2; Fri, 4 Dec 2026 11:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382090; bh=YT6nwosfejUIRFZZNGT9E0J3w3/W6qMsZDZtrlurkSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=e3q4Iw7B2ozQeeNoYz9NMYpWiHt0BNf/BRtCCfaQy0RPPEPIzFcXCpazXGGu+tu5Y +gUlwfEByluLImf4V9RVc+I65CDvyU3bDjFEhlrzElUrAD5MIIRSinCcHTNf+XDY24 RQToGo0fthXoKW9qrSO9nK3ICsnzEphogOHV0xt4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.18 303/703] bpf: Do not trust the neighbour of tp_btf/neigh_create Date: Fri, 4 Dec 2026 19:03:22 +0900 Message-ID: <20261204100635.839343826@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit 2c517088d2ef5f9b17fcb2e44a296e36c5a91843 ] ___neigh_create() calls the tracepoint before it tests the result of neigh_alloc(). It is NULL when the table is full. The verifier takes it for a trusted pointer, and a load through it oopses: BUG: kernel NULL pointer dereference, address: 000000000000013c RIP: 0010:bpf_prog_56e3384dcafb1b5b_on_create+0x61/0xc4 Mark it untrusted, loads through it are probed then. PTR_MAYBE_NULL would refuse programs like bpftune, which pass &n->parms to bpf_probe_read_kernel() without a check. The pointer cannot be passed as memory or as a trusted argument any more. Fixes: 838a10bd2ebf ("bpf: Augment raw_tp arguments with PTR_MAYBE_NULL") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261125032938.670542-12-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- kernel/bpf/btf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 64b54b1ee4e15..8da6e7959ce98 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -6740,6 +6740,7 @@ static const struct bpf_raw_tp_null_args raw_tp_null_args[] = { /* iptfs */ { "iptfs_ingress_postq_event", 0x1000 }, /* neigh */ + { "neigh_create", 0x4000 }, { "neigh_update", 0x10 }, /* snd_firewire_lib */ { "amdtp_packet", 0x100 }, @@ -6925,6 +6926,9 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, /* Is the current arg IS_ERR? */ if (raw_tp_null_args[i].mask & (0x2ULL << (arg * 4))) ptr_err_raw_tp = true; + /* It can be NULL, and programs that do not check it have to load */ + if (raw_tp_null_args[i].mask & (0x4ULL << (arg * 4))) + info->reg_type = PTR_TO_BTF_ID | PTR_UNTRUSTED; break; } /* If we don't know NULL-ness specification and the tracepoint -- 2.53.0