🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25129

Re: [PATCH v2 net] net/sched: sch_qfq: bound backward slot rotation

#25129
From: Jamal Hadi Salim
Date: Tue, 01 Dec 2026 09:28
96 lines
15555 bytes
On Tue, Dec 1, 2026 at 4:22 AM Lin Jiapeng <ljp1205831794@gmail.com> wrote:
>
>
>
> On 2026-12-01 1:22 a.m., Paolo Abeni wrote:
> > On 11/24/26 05:01, Lin Jiapeng wrote:
> >> From: Lin Jiapeng <jiapenglin@tencent.com>
> >>
> >> QFQ+ keeps aggregates in timestamp-ordered slots and rotates the
> >> occupied-slot bitmap when a group's start time decreases, avoiding the
> >> need to move the aggregates themselves. Insertions are capped so that
> >> occupied slots leave room for a later backward adjustment.
> >>
> >> A stale aggregate can make the decrease larger than the slots can
> >> represent. Rotation can then drop occupied bits or alias distinct logical
> >> slots onto one physical hlist, and a later removal can clear bits in the
> >> following slot-list pointers or leave stale bits. KASAN reports a
> >> slab-use-after-free read of size 8 in qfq_choose_next_agg+0xd04/0xd90 by
> >> task repro/92 after the corrupted group is selected, followed by a panic.
> >>
> >> Limit backward rotation using the highest occupied bit so every occupied
> >> offset remains below QFQ_MAX_SLOTS. If the decrease exceeds that limit,
> >> move the activating aggregate's S/F and rounded start time forward by the
> >> same slot-aligned delta before rotating. This preserves its service
> >> interval and the logical-to-physical slot mapping, including repeated
> >> rotations, while leaving representable rotations unchanged.
> >>
> >> Fixes: 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at
> >> DRR cost")
> >> Reported-by: TencentOS Corvus AI <corvus@tencent.com>
> >> Link: https://lore.kernel.org/all/20261116121710.77403-1-
> >> ljp1205831794@gmail.com/
> >> Signed-off-by: Lin Jiapeng <jiapenglin@tencent.com>
> > @Jamal: could you please have a look?
> >
> > It's totally unclear to me how the aggregates become state and if
> > the issue could/should be addressed flushing such stale entries
> > earlier.
> >
> > /P
>
> Sorry for the unclear description. By "stale" I meant old timestamps on
> live objects, not dead aggregates that should have been removed.
>
> The PoC works as follows:
>
> 1. Group D remains unserviced while q->V advances, so D->F stays old.
> 2. Aggregate A is reactivated in nonempty group g, and
>     qfq_update_start() assigns the old D->F to A->S.
> 3. This causes a large backward rotation of g's slot bitmap.
> 4. A subsequent class change removes aggregate B, whose rotated offset
>     is now beyond the 64-bit bitmap.
>
> For example:
>
>    old D->F = 8, g->S = 55, B->S = 83
>
>    A->S = D->F
>         |
>         v
>    rotate g by 55 - 8 = 47 slots
>         |
>         v
>    remove B: offset = 83 - 8 = 75
>         |
>         v
>    __clear_bit(75, &g->full_slots)
>         |
>         +--> bit 75 is outside bits 0..63
>              and overwrites g->slots[].first
>
> All involved aggregates and groups are still live. A still owns a class,
> and D is a valid ER group, so flushing them earlier would remove valid
> scheduling state rather than clean up stale entries.
>
> The PoC uses only packet sends and class changes; no race is required.

I will let Paolo decide if he wants to take this as is - but you
should always describe how to reproduce in the commit.
Here's the order i use in the commits:
1) How the issue was found
2) What the issue is (include KASAN etc)
3) what the fix is
4) Conditions to recreate

cheers,
jamal
Technical Details
Message-ID: <CAM0EoM=HCGh-ePzG2V7RSwbh7v69zzVh+0qf+O6K0HHw+qefaQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374901-linux-kernel-netdev=dewy.ru
References: <20261124040208.13282-1-ljp1205831794@gmail.com> <7ecbb59e-d985-4b75-9240-ce83bcd87175@redhat.com> <143b8cc0-44c4-4a93-b936-a66677c1a0bd@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374901-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v2 net] net/sched: sch_qfq: bound backward slot rotation
Date: Tue, 1 Dec 2026 04:28:58 -0500
Organization: Usenet Network
Message-ID: <CAM0EoM=HCGh-ePzG2V7RSwbh7v69zzVh+0qf+O6K0HHw+qefaQ@mail.gmail.com>
References: <20261124040208.13282-1-ljp1205831794@gmail.com>
 <7ecbb59e-d985-4b75-9240-ce83bcd87175@redhat.com> <143b8cc0-44c4-4a93-b936-a66677c1a0bd@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1673745"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:A/fHAcrW7TVtukbBOqKqThJ6XXc= sha256:Ax92Rlgeuyj9Aou34NU3ikw8XtNNWApjzc7YZZYnHh0=
	sha1:yeuvi4sEkHZR5KnjRcMX6YI0Eug= sha256:BaK4Jb6ca3USaunQ0ttz2/zC+GrHJrrSor9HcxZX8Fc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D15A2117301; Tue,  1 Dec 2026 12:29:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=mojatatu.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id arwUPhXJMamF;
	Tue,  1 Dec 2026 12:29:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374901-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 6AFF81172FD; Tue,  1 Dec 2026 12:29:16 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 9D1B62BC34; Tue,  1 Dec 2026 09:29:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796117353;
	b=RvWF93BA2H/O/0t8gjG/bQNj8Gt7Jl+cGptJ+Zt1qyrt/cKD4CCBbulg+xoXuPigB94W
	 /g+XIP+SgDY+eo1EImv+26hDqcxEl+72gUnstk4WDlk7u8gQzSm2NDrl6xyU4GIoAGXaW
	 ehE+Hp2fOWKE7GdRZbXpBPlAz37ipnmLw8vpm9GVyvwbiaLQ1386Kgcl8m7/MG+sKHoYU
	 +DBpa2c+g52Apkwmu1s2jalNj2+pYrsCQLMSXvIZpDHa2ZXJUZ3KoGyp6yqcbv2ZUzTYP
	 w+4OYZL3d5DL+NjhxQbSIBQfogepOAwGLMZwSFzNrp4Kam+wE1SSIaps7KZDpy+7+xQ==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796117353;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 References:In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:
	 Cc:Content-Type:Content-Transfer-Encoding;
	bh=Oz/lLXejdR1XJy3pLSyPTD1mK5g4nyiasgz29VrMRJ4=;
	b=drpnxWLK0RGXLESJVO2h+FHvEZFC4RKsqKKkwEF/aSXxtfQExOQ9dCi4DVUkbMyL9TvC
	 yKVwbN3n5ZEyO9amSUG+89DmJkueekewlH60IhEnwGE44PjNDgvxYjBoVdB4JIZOyaqWR
	 OE8PE8e6yFgC6qxnwMxE3azcF8DnaGkr8HzhXvqGSEepTRyytH/2gV5Be5ewZOMpB4sGS
	 ucq3ImWdBZAhRShBnEPcTvz7C/PEWMG6noKraw4LCv4GLe4TDydLlKWPLEw1FqRQugVSs
	 /3qhbLCn2sNvlyM5XEbF7WL3wc8IzZ6TjgH4/Wb+U5xvMmv4rL1OmDvlenos51k5+bA==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=eogu5zpr;
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 027F7606A335;
	Tue,  1 Dec 2026 09:29:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=eogu5zpr
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.210.170
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796117352;
	b=tKkmHal9xk7Q5KZPuVqz0I3t/+19vIrbVicjZHLssb+KChCRJTDtHWhbOny6St2eQgyK
	 RC1wKHrmivuHrnXr1g+JNF4ibuFj9V+GVxtm0+61xDFiQXLUuTThSmrKJn7A5DXMIMMtQ
	 BEYIA4Fj03evBRBAr1EFpZeSFXA/yLt+p+5MHhshxK8NQV3plSrZ4vdDUw6rVECOjd3cn
	 pABew4NsgeOjewlcNo6OafP6eaBNYvz2TJE4Gfjr8384dz7IUJJvxVTJSJ/T3K+3wHkHe
	 +EMhp3Nj8QfL0A4XoyC/L/On3JtmF+tuUP598U9eJmlennfAUeBWfXlal8icrXaSHOg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796117352;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 MIME-Version:References:In-Reply-To:From:Date:X-Gm-Features:
	 Message-ID:Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
	bh=Oz/lLXejdR1XJy3pLSyPTD1mK5g4nyiasgz29VrMRJ4=;
	b=WcY7AgI7LWGIWS7f+4qBH9tNjUDPYqm9B4MGkvnYKUxHOuoDgCIdVylVMgMYOkHZl+/L
	 1G8cx4/SsF/F8oibxk5AiCRissMjTXdoxzDBXBQFxKJa98GD2NQHxZ5UYiSaVYrTKQkU+
	 iFscAEki3QebSI2SO7oPzwM3DrZYdDo3qA9emtV2O9Ym8kgHVX1N7u1nja/cZVa6W/kaI
	 1nYRYvKngZ9/anQbnX0z1uEE7HgJB6FfIbuXYmcwUpnQ7zWDDR+xpL0UlkNKY1Xq+R2ZQ
	 8IOwv4Do0aHq1GtDzUNNf0szoOeteJlmMom54GlrH34p99G0iD7NApc9fQvdJy8khHQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=eogu5zpr;
	arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.210.170
X-Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 442FB606A31A
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 09:29:11 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 442FB606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8b58d6f67a5so5701064b3a.2
        for <netdev@vger.kernel.org>; Tue, 01 Dec 2026 01:29:11 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1796117350; cv=none;
        d=google.com; s=arc-20260327;
        b=K7jLEpDagaskT5Oqf82t6R9wbVx9QNdm191YMrOwLdGw2/Y51LS+hcOPzKrn+vApDE
         1b+ucNQFZxSxt6YO4TkPq154zj50iyFZ3noH9bNuY9n6oGDP7UFjtFuNMjZJTBCT4b19
         uEAxuYtrgOywC2zIqr/JmjH6nWrARhoH5swjDXsM9hfgk86PJ0OQH54QRf88AjhZakVC
         WGAqpMVY2m9f8QuPy2niFaL8CkDbUB50XoTIfM87RkBQAABSLR8C3jflacUrJ+8JEMM0
         zsvRuTrJcAZdUQ6etyl7ErHRf5EfC7pRjZDdEVJxr3CtJqrrwZk1LTNiFKUMp9YdE4da
         fwpw==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
        h=content-transfer-encoding:cc:to:subject:message-id:date:from
         :in-reply-to:references:mime-version:dkim-signature;
        bh=Oz/lLXejdR1XJy3pLSyPTD1mK5g4nyiasgz29VrMRJ4=;
        fh=zJ+/zNqoQZB54faV0XQjsf6Tt+pu/YiyDhYf/HtNpos=;
        b=Ej4NCiam7lxM5fQwDV2/rCM4ZhcBTkFaI3EIeczfxRg/lJ2KjU+L8MmxuiF4wQvf36
         za38VZ+7YPEyhvu7V2xcuW1xFvxStxs3pLSoMSQxO0kj3fVJJoeRAEOTb7Gw4YNHPJDm
         7iEINBNOWRHEpoG0lFPenOI+55G4Uw4heGNN0txZw7EOQ/OuHU5q5hOBkzNHBraPePWC
         awME1kBF/E/rN6kCgigOokBaMi45MMm07QOWSGcsYCgOJlTfh3o3jk5Z0df/oEeBXLv6
         KG1IpyMinOJMZl9ZLs36Yzknkqxv/X2EuqKzm+cztuodAUoA8LGAluoOo1n8BulVFYKP
         D3sA==;
        darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=mojatatu.com; s=google; t=1796117350; x=1796722150; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:cc:to:subject:message-id
         :date:from:in-reply-to:references:mime-version:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=Oz/lLXejdR1XJy3pLSyPTD1mK5g4nyiasgz29VrMRJ4=;
        b=eogu5zprVouPqYNeyFkdcghcsGCQkoWaC2FyYu+/E5sxEfaBNOmQDY6wjNCM0wqziS
         7RXP9fEnRYOKukU4GNJgYiqh2cxU8XIFN9h48xDzuSyFCNg/nQIwU254idm6lDKw6Nef
         BhMVB/nq9HBcSidONj7pk7N5VAPRbChgOwASw=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796117350; x=1796722150;
        h=content-transfer-encoding:content-type:cc:to:subject:message-id
         :date:from:in-reply-to:references:mime-version:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=Oz/lLXejdR1XJy3pLSyPTD1mK5g4nyiasgz29VrMRJ4=;
        b=0Qcm3BO+xib+vcmaMMLXivoSvrwzV/E6FJckLZSFhtlRYNM1yjk5wsu2+6zzsaV/KS
         zDwKfDu5xDY2DLoIcMBcAGKyhEwouixagY+ROwMo43caqVsX5XKif2kA79a9gsarV77R
         CfTKxHQs/eXgnPV04ERcGKbHWh3eKwUr9aCzA7lRD9zclXy2wc0+H135Bn8ws3dWnQQ/
         wzrhCzS5NHV6vc0k03reNw+2MchuEbJOu/riEyaMDulSvznu7wgSz0i6FS4xPzn1n3jC
         gTPQLCzj/34WkHym5D2IPnKVgoSiZpQ4WJFIIVHflpTsMBQsWdSSSNBSn9gzIeYD//MH
         sUeg==
X-Forwarded-Encrypted: i=1; AL+hErH5IpM4vkt/5pMYq9qDjuWSQeLVT1Jq7fXXKhbVP4VE3QO9ZujUt5mui+jY9ZsApNajg7OCopQ=@vger.kernel.org
X-Gm-Message-State: APuU4Z+zxFRsDxwtisytPxD04i/oj9qoW7gA73cRpeUO+VM0yZ/2eODz
	C13QDirlUMNxqAlQNQsEDGnneXNGUneN1Nii79rSxp+XecG2+zJlFxL9x0jIgAulh1+OvFEYck/
	WT0wHisjeECwkiF2qSHzdzcS7srYgwWGKT5ReXXOm
X-Gm-Gg: AZFdTZfx/gjIQ+3WShcVeF8ufEB4mTiwxn+Cs89jU9ccgiBmagLgLYejQRMofKvBpXQ
	maiiujVBIfr14yK6M/KEfTM55lgf2Q/vNt4twmH3auo5WR2Po2Jx/Gfd+7157agfD3jyWceUlSt
	obuTz9FgHOTE/uPFJO+gsHKjN1Q01/+J6/ccElRRwLSh+Iw9Zl5PO4HrwFtL4gRGSuo6l+RLwWX
	P2PbKGp9qA5/Jba52mNMzT6JqxZffCoequSWQ6WGXyuVcTrd3E4zyHsaEX2gvRjdAJ8sdcPeZmF
	3xsK936B2f6SSjvdFGNlDOccOmZovJ5E4klOFN7Hc9+AnLKYpK31LaMSIEjo9XxqysQmnk3p/rp
	I8ii4ZukC7i2PXuH3pwtuFsfEnVVMZNKOSrkmfhDtliNkJy6NovVJMX1rovAUjFLD3F2YZwQskX
	VNZt5915GQpLABsYj9yXwrvovTeyjMj8vOHvtWjdUR+rCVhvte5F8Wr8PCJ798JG/t8jlrXU0c6
	cRTf4UIjA==
X-Received: by 2002:a05:6a00:94fb:b0:891:3049:8ef8 with SMTP id
 d2e1a72fcca58-8c87d5169c8mr33130877b3a.47.1796117350420; Tue, 01 Dec 2026
 01:29:10 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <143b8cc0-44c4-4a93-b936-a66677c1a0bd@gmail.com>
X-Gm-Features: Aa3M54rpBp-oz0xUmvSGn93vu6UIl5Rjmdn4wIi27hFhPsZp5Sd4msNUm7PRNUA
X-Cc: Paolo Abeni <pabeni@redhat.com>, jiri@resnulli.us, netdev@vger.kernel.org, 
	Lin Jiapeng <jiapenglin@tencent.com>, TencentOS Corvus AI <corvus@tencent.com>, kuba@kernel.org, 
	davem@davemloft.net, edumazet@kernel.org, paolo.valente@unimore.it, 
	linux-kernel@vger.kernel.org, horms@kernel.org