From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 C6A1B3B3C05 for ; Tue, 14 Apr 2026 08:53:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776156838; cv=none; b=X4LOTgDPObLFAC5V1yHnkM3DA3wFJ/UJlV7UlZPTzuWLAwWT7jx4sEAmy79ffInxUTSpT64yZO6eLC1g2iVuZK8BYngiCYKMneBhZhQZmIadh+bBeyZvyYiQ9Rb8l0oDqb8K6EOFep+5LzbyLjdNBnjrLiqxLjJJkSwNtQQkoR4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776156838; c=relaxed/simple; bh=OVu9KdSJZseM7Nt2ItB4OpCFv/h6niQO/sezNN27FOY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QMqQfvkFoqycBXzgFP0wqQH6fsdfx0mPEkGrmQF6dxGiqh6B+yPzHlnI+joUcykntmkIfJrzpEQjs04kNF5K8Xu3PCNZy1nfLn/dudDdu5HIgHCIlxwpc262KxQPlQB+C50I6Mt+utk5y4PRthU6ElkdYraOmhmtL+9zddjY/18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CKKyqhqO; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=D8045Z7D; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CKKyqhqO"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="D8045Z7D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776156835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oxmBacf55etftW8UnPkV/EpOImxHgh4CswOaaLPDOw4=; b=CKKyqhqO2So0XpOB4Uh/L9Kq3rF8sqLrwta2N8pLYMrogylHIgUicCxeMU9HRexeSicwts ryvVpSAg5otUrSF0cqmkD9nQCFSiYE3zghYUchT/hVf9rw6DZrTGxATC6+6sYtVBi0gObC PLlgM6rO4wcefbgrdtsUTaDEAgeerAw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-OcpW-oJcOuap7Swk21Rlqg-1; Tue, 14 Apr 2026 04:53:54 -0400 X-MC-Unique: OcpW-oJcOuap7Swk21Rlqg-1 X-Mimecast-MFC-AGG-ID: OcpW-oJcOuap7Swk21Rlqg_1776156833 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-488c74405ecso32623645e9.1 for ; Tue, 14 Apr 2026 01:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776156833; x=1776761633; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=oxmBacf55etftW8UnPkV/EpOImxHgh4CswOaaLPDOw4=; b=D8045Z7DM4W6TRMmcU3o9sEfc1br3fLGCCWbiZy6gZ036NAzT2SNL1ZO0JRVW9NAv7 +/L+RVVPNigrXF2DTqzeIkotIPNfokQwJlrQj5oUABBwTuD4dKek5A2WdNiDzYj3S+uZ L+V/TSILikmX0dFpylurwkW4cfw8vTYf0J50Xl3K60H7BGw56Kxx5bCe3AtsBCQJqyE4 ZP6Z+02zx609KNdcioUQv61v9vxZ085+TxmI0XxZ8uYCRh5+ukpYnv4RnljYl7uJXE7o 2QmZ2mQTdTw91jnJEA4CyPcHyrNgZyJ2USNACTRucftITeH+uT4Xp798U2m5zXwONzmQ d8hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776156833; x=1776761633; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oxmBacf55etftW8UnPkV/EpOImxHgh4CswOaaLPDOw4=; b=KRyGdf6j8BoDSzJkwJES7/DDOgrxAS65xUvvaUUHGRwQEz0HYGg1fG2DMraGEQRKVN 5gY7rzKabnfSI9y2H9Jw9273dpx8VKyHyAaJDy8G/tOKH/SrJxMmkSx/AWc10RoGzSYb qRPb2AdWsXD8xmldjwswVSknO1H/ssgW0HOr+IdOz7gkgBBJ/g3YO9dnEmXmRKZ6O7xw bI6jluk2RoPXYw2XU697a4gEZmglgy/zwj6LjwWTuVxwf6DVPIDk5e7XecjVTbKA6iew Ks3ON0ryHLtfG0e0ZOfMWpDuByEsBE3zFOVoW+0m8Y7OtXwx/KQ7UdSF7yLuV/6a7ujf ryLg== X-Forwarded-Encrypted: i=1; AFNElJ/zeDduxitGHOVJ1TM0o6noYXf0hKMqAhK+wsIj0z2Putq94dVGKeUkg5U97woSK9KpKhPyENAcjl60dCA=@vger.kernel.org X-Gm-Message-State: AOJu0YzxOZmDse+zUjc7TLjfbABxm5vMLTAntO6ozIJ/kTbiIfa11Hfm BVP/t23C4e10zN2qyBaRvyJ9Nu8Fcujr8MejSTItYy2xhpR9y94zRX895zkSHXhTRnQyUC/hmAE ZIWD5g29dicgDZnPKe6zaECQOfmSL6GVNnGPLmua5YfMaBVBW/rAT7TIX6zUAR7EDuQ== X-Gm-Gg: AeBDieu8ZRymVqDIt1v3mNWIb9eSSOkTvysYNJTtSshHbCs69vfj83qHEJw9zOemJP3 RaaNkrSsCL4btv9WSLxVWOR2wO/BQmW8atqovY/2sZbYWYIofquUELvktn1Tm/2lHyEwzkeL1ok UB+U24C6kPnoXQeywInq4uFfU3STL/PaSdcZ6fqac6lChMmBstlbtyVZxToDlIdjHBGGTN6qEp5 54a1me6GWzselCtS8eAlRTsBSdaRxOJqtPd42hoT/2G9EqlmZnW54sPDnScfMZQFcSL1XfxVhtF qudeoKSB8+oBcS4tCUMHjoZaP1D4yrEvNmqYmyTZBahAqEB5OK9K9fsf2cQVSwHklUHMwGXb6nJ C7TwImiafAdGdN1Xx5F+ad53PbG2q/NhapYTxa5PhcY1LN8oNXt0obAPe X-Received: by 2002:a05:600c:3150:b0:486:fcc7:d6a with SMTP id 5b1f17b1804b1-488d67f4c4dmr251372785e9.13.1776156833175; Tue, 14 Apr 2026 01:53:53 -0700 (PDT) X-Received: by 2002:a05:600c:3150:b0:486:fcc7:d6a with SMTP id 5b1f17b1804b1-488d67f4c4dmr251372295e9.13.1776156832656; Tue, 14 Apr 2026 01:53:52 -0700 (PDT) Received: from [192.168.88.32] ([216.128.11.125]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d6f4bf2b4sm23579778f8f.20.2026.04.14.01.53.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Apr 2026 01:53:52 -0700 (PDT) Message-ID: Date: Tue, 14 Apr 2026 10:53:49 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v7 1/2] net, bpf: fix null-ptr-deref in xdp_master_redirect() for down master To: Jiayuan Chen , netdev@vger.kernel.org, Daniel Borkmann Cc: syzbot+80e046b8da2820b6ba73@syzkaller.appspotmail.com, Martin KaFai Lau , John Fastabend , Stanislav Fomichev , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Hao Luo , Jiri Olsa , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Simon Horman , Jesper Dangaard Brouer , Shuah Khan , Jussi Maki , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20260411005524.201200-1-jiayuan.chen@linux.dev> <20260411005524.201200-2-jiayuan.chen@linux.dev> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20260411005524.201200-2-jiayuan.chen@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/11/26 2:55 AM, Jiayuan Chen wrote: > 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 > --- > net/core/filter.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/core/filter.c b/net/core/filter.c > index cf2113af4bc9..9ec70c4b7723 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -4398,6 +4398,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); The AI review noted that the master could be (theoretically) NULL here. Since that event is not a regression (unconditional `master` dereference already present) and syzkaller failed to trigger it (despite being the sort of thing syzkaller is very good to find) make me thing it's better to eventually follow-up instead requesting another revision here, but please have a look. Thanks, Paolo > if (slave && slave != xdp->rxq->dev) { > /* The target device is different from the receiving device, so