From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D8DC4F93DB; Wed, 30 Sep 2026 16:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790787252; cv=none; b=nNascEnkj47/1SOlQvwLI6OcR4bWM2OMEHn8BMJWxvOksMM2QHlxL6hFepChr+ZoB1dVgTU1yy5mgqlCPq3VrdMK6K9JuirZGM+d2HyZIIb8oYworosab3Jw8WOA5/i3ZAzjMdj1Ikied+hoRxtveFdlF8pYATx9KPb5wSNkkps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790787252; c=relaxed/simple; bh=HZSFWQBtJNSvEnW6OB6PX3UzrVLsmG6GrjcvxvVmdKY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XE6D8PZ71zG/BEQ14EJbpJBUY3C9cgd1ABkGKDGP9D6zkggmMUjY+LAgxCh/Zb+b9AzhbydJgB484mS0Ci76fDB6A5/HSuRzuP42/sK6zv3i4Q1LtAwR1BadZGvt0YQQ65ck8KHUNIA0FOhfiur8TVVImOjsgQfZWGPzSLijzXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XW2kprSg; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XW2kprSg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 042921F000FF; Wed, 30 Sep 2026 16:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790787251; bh=cY2WjVq00chn1kiSQEXwY+iGz5Zy2CIfppN5lbWBayU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XW2kprSgxpwaFfAHTpyVolwEO+2DltXtbiomKrNWy4Go5rFsYlCRw3AmsJlIMnsF2 2qs74oOQGX0zQp53vNNJmibbgAEgkwbL8zkXStemUWUSvk16xWTZhk2YeU+gwYu5ok udnCNK9NxWlwATYQZA5hyycGX1ASLCWseUBiGE/o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, co+ac0a8c41de69121d@bugs.sh, Weiming Shi , Alexei Starovoitov , Sasha Levin Subject: [PATCH 7.2 166/457] bpf: Reject dev-bound-only programs on other devices Date: Wed, 30 Sep 2026 17:24:31 +0200 Message-ID: <20260930152349.634809886@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152346.024115587@linuxfoundation.org> References: <20260930152346.024115587@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi [ Upstream commit 6db1ce73e9853f533eb7f413f14ba00f8ec6f80d ] __bpf_offload_dev_match() falls back to comparing offdev pointers after an exact netdev mismatch. Bound-only programs normally have NULL offdevs, so unrelated netdevs compare equal. A bound-only program on an offload-registered netdev can instead inherit a real offdev and match a sibling port. With CAP_BPF and CAP_NET_ADMIN, a caller can use bpf(BPF_LINK_CREATE) with a different target ifindex to run metadata kfuncs specialized for the bound driver on the target driver's xdp_buff. Running a veth-bound program on tun reads beyond tun's bare stack xdp_buff as a veth_xdp_buff. Oops: general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] RIP: 0010:veth_xdp_rx_timestamp (drivers/net/veth.c:1673) Call Trace: ... tun_build_skb (drivers/net/tun.c:1739) tun_get_user (drivers/net/tun.c:1856) tun_chr_write_iter (drivers/net/tun.c:2091) vfs_write (fs/read_write.c:595 fs/read_write.c:687) ksys_write (fs/read_write.c:739) do_syscall_64 (arch/x86/entry/syscall_64.c:84) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception in interrupt Restrict non-offloaded programs to exact netdev matches and retain the shared-offdev fallback only for genuinely offloaded multi-port programs. Fixes: 2b3486bc2d23 ("bpf: Introduce device-bound XDP programs") Reported-by: Signed-off-by: Weiming Shi Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20260917161335.1020405-2-bestswngs@gmail.com/ Link: https://patch.msgid.link/20260920132303.4109240-3-bestswngs@gmail.com Signed-off-by: Sasha Levin --- kernel/bpf/offload.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index 0d6f5569588c3..d855399812eec 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -698,6 +698,8 @@ static bool __bpf_offload_dev_match(struct bpf_prog *prog, return false; if (offload->netdev == netdev) return true; + if (!bpf_prog_is_offloaded(prog->aux)) + return false; ondev1 = bpf_offload_find_netdev(offload->netdev); ondev2 = bpf_offload_find_netdev(netdev); -- 2.53.0