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 324B13F1661; Wed, 20 May 2026 17:23:55 +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=1779297837; cv=none; b=JtcOnSUbIaFSqfnA9Rkovc2BKzyTlG03Ytt+1+Vj4dIYLuw9TC/qwQLeU28uBZZnR6HjGfoS4LeX0mzg7UIqe7+wRlYtneWwqu24AJ15pbn3bJND2aY9Vxx0VZAXkXvt0zhbPFdG0+e6wkiXh6iQtEW7Szo9e5xs5ZJ/Mo1JcTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297837; c=relaxed/simple; bh=Mq2hTHk58Lbfo2CHiaLaCedFV3vFwN5NxgfQQZdpHYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GSNl9idgsnk6aZnnXRKh1x9oioTEaVPOUIna3an+dGxMC4PTkpcGIZqoW0f5u2D3bMZn+wA1TqgBGgKkHueKrsjtj7X0qF9qW10lLh+WCGX3QITxZHKmpZESw4G22h15eUtvcmQbmBjbsSW5jsiAMsjK90Vo6jxzG00CF75d0J0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Z+a028kL; 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="Z+a028kL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DFAF1F000E9; Wed, 20 May 2026 17:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779297835; bh=Cxt9sR3Ahdssuo10C4j7/o8CXqBYJoHSaLNIH5z8vtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z+a028kLPmYn3HwxycuReES9UvX8EzMUjLD3igeDwMptuFehbB+sQdtbq5zk6ZGk9 yrvVmpf0QlHCMgpPYzr6o9Y+QiuBlo+k3vyPcXoAjKHYfSDwyvUjSmoFE86c5NPipO Er9pE8+KhHK16GLVH+oDVZOWbiTpZZQG1gzT/0e8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+80e046b8da2820b6ba73@syzkaller.appspotmail.com, Daniel Borkmann , Jiayuan Chen , Paolo Abeni , Sasha Levin Subject: [PATCH 6.18 183/957] net, bpf: fix null-ptr-deref in xdp_master_redirect() for down master Date: Wed, 20 May 2026 18:11:06 +0200 Message-ID: <20260520162138.521424523@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162134.554764788@linuxfoundation.org> References: <20260520162134.554764788@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiayuan Chen [ Upstream commit 1921f91298d1388a0bb9db8f83800c998b649cb3 ] syzkaller reported a kernel panic in bond_rr_gen_slave_id() reached via xdp_master_redirect(). Full decoded trace: https://syzkaller.appspot.com/bug?extid=80e046b8da2820b6ba73 bond_rr_gen_slave_id() dereferences bond->rr_tx_counter, a per-CPU counter that bonding only allocates in bond_open() when the mode is round-robin. If the bond device was never brought up, rr_tx_counter stays NULL. The XDP redirect path can still reach that code on a bond that was never opened: bpf_master_redirect_enabled_key is a global static key, so as soon as any bond device has native XDP attached, the XDP_TX -> xdp_master_redirect() interception is enabled for every slave system-wide. The path xdp_master_redirect() -> bond_xdp_get_xmit_slave() -> bond_xdp_xmit_roundrobin_slave_get() -> bond_rr_gen_slave_id() then runs against a bond that has no rr_tx_counter and crashes. Fix this in the generic xdp_master_redirect() by refusing to call into the master's ->ndo_xdp_get_xmit_slave() when the master device is not up. IFF_UP is only set after ->ndo_open() has successfully returned, so this reliably excludes masters whose XDP state has not been fully initialized. Drop the frame with XDP_ABORTED so the exception is visible via trace_xdp_exception() rather than silently falling through. This is not specific to bonding: any current or future master that defers XDP state allocation to ->ndo_open() is protected. Fixes: 879af96ffd72 ("net, core: Add support for XDP redirection to slave device") Reported-by: syzbot+80e046b8da2820b6ba73@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/698f84c6.a70a0220.2c38d7.00cc.GAE@google.com/T/ Suggested-by: Daniel Borkmann Acked-by: Daniel Borkmann Signed-off-by: Jiayuan Chen Link: https://patch.msgid.link/20260411005524.201200-2-jiayuan.chen@linux.dev Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/core/filter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/filter.c b/net/core/filter.c index 3d4bf4d2a1a4b..7fc01474c3781 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4385,6 +4385,8 @@ u32 xdp_master_redirect(struct xdp_buff *xdp) struct net_device *master, *slave; master = netdev_master_upper_dev_get_rcu(xdp->rxq->dev); + if (unlikely(!(master->flags & IFF_UP))) + return XDP_ABORTED; slave = master->netdev_ops->ndo_xdp_get_xmit_slave(master, xdp); if (slave && slave != xdp->rxq->dev) { /* The target device is different from the receiving device, so -- 2.53.0