From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AD203A6B82 for ; Tue, 14 Apr 2026 08:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776155328; cv=none; b=MAINY6utstr8AY1Uk2IY1B2cukDipxWo3pcItlAVhbtuHv6lhXDZ+nRPPNtLQ+w/SaMj6o8LaBnOXMAXqKPHqz65MGLuFcqNdapjIhGcUY9zxv/ptj3x1y+HVnHGCXh0mT9hRlG41SWU0bhXsFlNoptVze0uqRlasSqXonA7CUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776155328; c=relaxed/simple; bh=+hEjv/YEIGD+t/a2dkN4zlIRGvn3FwnMz9kChxBTaK4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hyFEYENb/Bjc6LVfBNtWlot7prpGx7pykn9E30vYR3nQSbgXLI9GKQ6dQGg+SUD46p8PDZPFi/m99jCKHmxbZSmEzS5nJSfCtcM0Pg6+rR+AAVR9shZsQr+tlWYm3KC9GgeIJ6c3DYJoitmrzGUobsmp4oVY74FhUHmG9PpQ4Vg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A5phyXF8; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A5phyXF8" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-82f4c3619b0so651178b3a.2 for ; Tue, 14 Apr 2026 01:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776155324; x=1776760124; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=sZgpgC+hTRJV50/Tas0DS70HG1hlLWD71CdGjtmP/tU=; b=A5phyXF89WzDmfeXYgJdqglyJlcO83XPh2MmHXIrwj11urgHW6L0ntXFPx1hhO/OVw gXPD3Jfy1n9Pbs47a1rBErKGM3MFKFWSSfanBL6schXUWq3c71PdDdkzNrCwfZ3/jMtZ 9zmgYXZhSkKkLP2pC8En11suzP07vqFyiVhsDjFf9IuZCwcebE/fUYjPLq+qhau1c37E aaf2tnzn/uLYE02nQDIxNJXtrDsjwM/ula121bBl5YlB1bHgUWzA5gTCcEnY0IAssfT5 SHAU3I0Yh/32rk6qGlrLFrXJ0h+s8fyHGmSlYQt7zhIgZqj8pFNKB8AnjzG6phNrf54c SqRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776155324; x=1776760124; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sZgpgC+hTRJV50/Tas0DS70HG1hlLWD71CdGjtmP/tU=; b=XqsRr3+tVdKPOcOvDUfpkwSm4eCUlPWSBCgXlthgvG14MuWWJgNwYCRx2m+K4CYgiU mtWBK3a55FitYtVbpZgK8lzlhYuo7VNFOsQMaIjw0XsHoB/a/jY/KdgKiCbTn8wQ9SRc Lk0+TnTaWb1PKdxW7s7xcOIoT0GwhuvXbSZRomkNim9vpnKILDtdD2wtai0eMiH6Aque dAKT79hTGGcnZJ0zl8WgQXLKSIU/dYNhBm1VvYsgtxHRdLa2r+P7OhdqijGTv/ZkBUOf VVuKJ++We4ICB4gF4ZIyuOMYXyWo1diyiRyjqOdstx0Fj4F6Leb0aNETqpOwL+7bO3vw 1Yvg== X-Forwarded-Encrypted: i=1; AFNElJ/zg2bN+iD5vOi+aY77iFX4Wv3ogYMonPN3ofxV7i1s6waSryyL54chJ1msNrKqW+FB/IvW2EYFxcXC6Qc=@vger.kernel.org X-Gm-Message-State: AOJu0YwcWiZI8W7pc73P0mwhaYXQO//juxN93ThbowMDSddZ3Cl+Z++q JZdLsASAyQ1yfYLc1QWVzasx62WhFsLcEie67Mt+teb3J1OYshw8WCyV X-Gm-Gg: AeBDievNCk69lTmZnm0ljccnNxLJKudnqHJGmtpWA4sBbtzbLsMIqiGHTovDTL973gH jvH+KzJEcfnLthtm8LxfYbkdBM/ynsMdUbj6mKIJGCU6nF5/RvF4Vu0B/cAy+T6tu5bbQuBI1cA hBYgdUXjc5aODbcvtFEnDJsXYULz0eFUoK7py1pCsuGtuPc7fCODXIxVX+1oMhhmnxiu8CWdbsK j5HoS7ujJmTDPmHU/o5Pk2U+3jlq/k08kV42Q1LKjyCwnI8tTDbbVdb2oKOTAdrHBSY4bWjhiH5 tIsyC/C55lbhV/b5Aaei2Z5LmVLfxK71gEoxAdpwioU2z7ACnTJ2BNVzMq7cpOTShj1HTEqsPFe EB3ufn7hzCI9bKbwHbTUrvwXjqEUD0u1VnjXq6+hNVfBiwZj6BwyICfenUslPPJhpCSNbju37IQ eifyXBpj8b5grbYd19DCql11g4wvBAVezzTo/Xc9VA5EZCGZlQFVEKxvrNjEP3 X-Received: by 2002:a05:6a00:399a:b0:82f:979:4013 with SMTP id d2e1a72fcca58-82f0c2509d8mr17075697b3a.37.1776155324174; Tue, 14 Apr 2026 01:28:44 -0700 (PDT) Received: from SLSGDTSWING002 ([129.126.109.177]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f0c50d24bsm17237769b3a.57.2026.04.14.01.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2026 01:28:43 -0700 (PDT) Date: Tue, 14 Apr 2026 16:28:38 +0800 From: Weiming Shi To: Paolo Abeni Cc: Vinicius Costa Gomes , Jamal Hadi Salim , Jiri Pirko , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Simon Horman , Vladimir Oltean , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xiang Mei Subject: Re: [PATCH net v2] net/sched: taprio: fix NULL pointer dereference in class dump Message-ID: References: <20260410153902.955227-2-bestswngs@gmail.com> <6f4ebd09-9fa9-4b6e-97b5-a6b1fcec8774@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f4ebd09-9fa9-4b6e-97b5-a6b1fcec8774@redhat.com> On 26-04-14 10:16, Paolo Abeni wrote: > On 4/10/26 5:39 PM, Weiming Shi wrote: > > When a TAPRIO child qdisc is deleted via RTM_DELQDISC, taprio_graft() > > is called with new == NULL and stores NULL into q->qdiscs[cl - 1]. > > Subsequent RTM_GETTCLASS dump operations walk all classes via > > taprio_walk() and call taprio_dump_class(), which calls taprio_leaf() > > returning the NULL pointer, then dereferences it to read child->handle, > > causing a kernel NULL pointer dereference. > > > > The bug is reachable with namespace-scoped CAP_NET_ADMIN on any kernel > > with CONFIG_NET_SCH_TAPRIO enabled. On systems with unprivileged user > > namespaces enabled, an unprivileged local user can trigger a kernel > > panic by creating a taprio qdisc inside a new network namespace, > > grafting an explicit child qdisc, deleting it, and requesting a class > > dump. The RTM_GETTCLASS dump itself requires no capability. > > > > Oops: general protection fault, probably for non-canonical address 0xdffffc0000000007: 0000 [#1] SMP KASAN NOPTI > > KASAN: null-ptr-deref in range [0x0000000000000038-0x000000000000003f] > > RIP: 0010:taprio_dump_class (net/sched/sch_taprio.c:2475) > > Call Trace: > > > > tc_fill_tclass (net/sched/sch_api.c:1966) > > qdisc_class_dump (net/sched/sch_api.c:2329) > > taprio_walk (net/sched/sch_taprio.c:2510) > > tc_dump_tclass_qdisc (net/sched/sch_api.c:2353) > > tc_dump_tclass_root (net/sched/sch_api.c:2370) > > tc_dump_tclass (net/sched/sch_api.c:2431) > > rtnl_dumpit (net/core/rtnetlink.c:6827) > > netlink_dump (net/netlink/af_netlink.c:2325) > > rtnetlink_rcv_msg (net/core/rtnetlink.c:6927) > > netlink_rcv_skb (net/netlink/af_netlink.c:2550) > > > > > > Fix this by substituting &noop_qdisc when new is NULL in > > taprio_graft(), following the same pattern used by multiq_graft() and > > prio_graft(). This ensures q->qdiscs[] slots are never NULL, making > > control-plane dump paths safe without requiring individual NULL checks. > > > > Also update the data-plane NULL guards in taprio_enqueue() and > > taprio_dequeue_from_txq() to check for &noop_qdisc, so that packets > > are still dropped cleanly without inflating qlen/backlog counters. > > > > Fixes: 665338b2a7a0 ("net/sched: taprio: dump class stats for the actual q->qdiscs[]") > > Reported-by: Xiang Mei > > Signed-off-by: Weiming Shi > > --- > > v2: > > - Update NULL checks in taprio_enqueue() and taprio_dequeue_from_txq() > > to test for &noop_qdisc instead of NULL, preventing qlen/backlog > > counter inflation when noop_qdisc drops packets (Sashiko) > > --- > > net/sched/sch_taprio.c | 11 +++++++---- > > 1 file changed, 7 insertions(+), 4 deletions(-) > > > > diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c > > index f721c03514f60..XXXXXXXXX 100644 > > --- a/net/sched/sch_taprio.c > > +++ b/net/sched/sch_taprio.c > > @@ -634,7 +634,7 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, > > > > child = q->qdiscs[queue]; > > - if (unlikely(!child)) > > + if (unlikely(child == &noop_qdisc)) > > return qdisc_drop(skb, sch, to_free); > > > > if (taprio_skb_exceeds_queue_max_sdu(sch, skb)) { > > @@ -717,7 +717,7 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, > > int prio; > > int len; > > u8 tc; > > > > - if (unlikely(!child)) > > + if (unlikely(child == &noop_qdisc)) > > return NULL; > > > > if (TXTIME_ASSIST_IS_ENABLED(q->flags)) > > @@ -2183,6 +2183,9 @@ static int taprio_graft(struct Qdisc *sch, unsigned long cl, > > if (!dev_queue) > > return -EINVAL; > > > > + if (!new) > > + new = &noop_qdisc; > > + > > if (dev->flags & IFF_UP) > > dev_deactivate(dev); > > > > @@ -2196,14 +2199,14 @@ static int taprio_graft(struct Qdisc *sch, unsigned long cl, > > *old = q->qdiscs[cl - 1]; > > if (FULL_OFFLOAD_IS_ENABLED(q->flags)) { > > WARN_ON_ONCE(dev_graft_qdisc(dev_queue, new) != *old); > > - if (new) > > + if (new != &noop_qdisc) > > qdisc_refcount_inc(new); > > if (*old) > > qdisc_put(*old); > > } > > > > q->qdiscs[cl - 1] = new; > > - if (new) > > + if (new != &noop_qdisc) > > new->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; > > > > if (dev->flags & IFF_UP) > > -- > > 2.43.0 > > Does not apply cleanly to net and looks seriously mangled. I suspect the > above chunks should be part of the actual patch ?!? > > Please, whatever tool you are using to help crafting the patch, double > check the result manually before the actual submission. > > /P > Hi, Sorry about the broken v2. I'll double-check everything carefully and resend as v3. Thanks, Weiming