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 C305635201C; Tue, 21 Jul 2026 20:46:13 +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=1784666774; cv=none; b=Bgu8sAh++j99NfqUyiQ4zFpQFE59s2U3IxaHlz3kArO17b7lTq7urBRDKh9UYJ/SqMNgRDWBCz/4X6B8OFvGItYHg9Da7Rok9ArPwz7xeabNd2SFbW3vjWgCKOsXVwzwqb3AiNYizdJ8Ifm0FiWYEW44gMNGK3d8gkgrN0ks7PU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784666774; c=relaxed/simple; bh=XEtvBmsOF6gy5jynPLHk3e/T0p5JhjrijO8vtGUBbWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SQ6SdE+W27N+lUb3Pea1WNLBShSoHZwXrFH5DIHTk/HWxvMl0e324VLVQSZNUYSJFguJaM/dpN2ft3QSxDcDGZzjfnUMrN2CawQwvIquTvEnE/tujHIV9Z8S8CMQqWunlWC3wBNDAvs184hfWlkIQj4wa19bqSR23vOoWCB961M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gc9QLb94; 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="gc9QLb94" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26A1F1F000E9; Tue, 21 Jul 2026 20:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784666773; bh=nAQA8ptp2iDHr3nNjnC/S1iKWdwepMMEtPLCN5w8Gc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gc9QLb94i1nFsIzXj1GQkqzrZCWCYC8ErNQ9qTrskePTn3Z+jrqMv+V8thZTy5Ew3 nt+QjpfRp1alrc4onfCkvmBN8ar1apEoHHvnh7ZHsTpnPcyANIm5G2nAp0JB9p77Xp BwFVyn/PvD6+lZLg119go1gbp1BrZB2bAvr4837Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Weiming Shi , Xiang Mei , Jiayuan Chen , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0783/1266] net, bpf: check master for NULL in xdp_master_redirect() Date: Tue, 21 Jul 2026 17:20:20 +0200 Message-ID: <20260721152459.383373345@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiang Mei [ Upstream commit e82d8cc4321c373dc46e741cd2dfdaa7921fddb7 ] xdp_master_redirect() dereferences the result of netdev_master_upper_dev_get_rcu() without a NULL check, but that helper returns NULL when the receiving device has no upper-master adjacency. The reach guard only checks netif_is_bond_slave(). On bond slave release bond_upper_dev_unlink() drops the upper-master adjacency before clearing IFF_SLAVE, so an XDP_TX reaching xdp_master_redirect() in that window still passes netif_is_bond_slave() while master is already NULL, and faults on master->flags at offset 0xb0: BUG: kernel NULL pointer dereference, address: 00000000000000b0 RIP: 0010:xdp_master_redirect (net/core/filter.c:4432) Call Trace: xdp_master_redirect (net/core/filter.c:4432) bpf_prog_run_generic_xdp (include/net/xdp.h:700) do_xdp_generic (net/core/dev.c:5608) __netif_receive_skb_one_core (net/core/dev.c:6204) process_backlog (net/core/dev.c:6319) __napi_poll (net/core/dev.c:7729) net_rx_action (net/core/dev.c:7792) handle_softirqs (kernel/softirq.c:622) __dev_queue_xmit (include/linux/bottom_half.h:33) packet_sendmsg (net/packet/af_packet.c:3082) __sys_sendto (net/socket.c:2252) Kernel panic - not syncing: Fatal exception in interrupt The missing check dates back to the original code; commit 1921f91298d1 ("net, bpf: fix null-ptr-deref in xdp_master_redirect() for down master") later added the master->flags read where the fault now lands but kept the unconditional deref. Check master for NULL before use; a NULL master is treated the same as one that is not up. Fixes: 879af96ffd72 ("net, core: Add support for XDP redirection to slave device") Reported-by: Weiming Shi Signed-off-by: Xiang Mei Reviewed-by: Jiayuan Chen Link: https://patch.msgid.link/20260620201531.180123-1-xmei5@asu.edu Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/filter.c b/net/core/filter.c index 5bbad21c7757c3..62d21a961e5ec2 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4393,7 +4393,7 @@ u32 xdp_master_redirect(struct xdp_buff *xdp) struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info); master = netdev_master_upper_dev_get_rcu(xdp->rxq->dev); - if (unlikely(!(master->flags & IFF_UP))) + if (unlikely(!master || !(master->flags & IFF_UP))) return XDP_ABORTED; slave = master->netdev_ops->ndo_xdp_get_xmit_slave(master, xdp); if (slave && slave != xdp->rxq->dev) { -- 2.53.0