🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25126

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

#25126
From: Lin Jiapeng
Date: Tue, 01 Dec 2026 09:22
75 lines
14018 bytes

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.
Technical Details
Message-ID: <143b8cc0-44c4-4a93-b936-a66677c1a0bd@gmail.com>
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374897-linux-kernel-netdev=dewy.ru
References: <20261124040208.13282-1-ljp1205831794@gmail.com> <7ecbb59e-d985-4b75-9240-ce83bcd87175@redhat.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374897-linux-kernel-netdev=dewy.ru
From: ljp1205831794@gmail.com (Lin Jiapeng)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v2 net] net/sched: sch_qfq: bound backward slot rotation
Date: Tue, 1 Dec 2026 17:22:32 +0800
Organization: Usenet Network
Message-ID: <143b8cc0-44c4-4a93-b936-a66677c1a0bd@gmail.com>
References: <20261124040208.13282-1-ljp1205831794@gmail.com>
 <7ecbb59e-d985-4b75-9240-ce83bcd87175@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1672876"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:DvJ9TLL29plb3G+zO5iarAtwB8A= sha256:fp1qQXIAF7QtXgg8f7oQhnxCwE3nnSNjhQQYfDu0ilk=
	sha1:mDZpnZWWHpX+Atp1/lWm/2n2KI4= sha256:KIYtY8IK67gCsTOK3nnm2Jkm7LCerTn2tmJWcmnFaqI=
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 A22A71172FE; Tue,  1 Dec 2026 12:22:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, 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] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.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 kINRPyPuyYQb;
	Tue,  1 Dec 2026 12:22:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374897-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id B08F71172F4; Tue,  1 Dec 2026 12:22:41 +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 5360B2E953; Tue,  1 Dec 2026 09:22:39 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796116958;
	b=Cytjj4Bxl089+rqJP/rzcOEa1Om2jSx/6jLIrnbNXQfyVN4xlHNOWZNWFlrYCX2OHBcW
	 6bDjq+4Usrd0b/71U++RxnHXAMrA2BXXARB+D+Ok+3Q0lbxGpkaXIf7kQY9fs5oa6SKeO
	 IRp8uwAfPl1iJN0T07nbTbLflv315hyHSqnozxV7BPn8NldoliF6fm/XTjxx9+ImHHjQT
	 X5comaZXo6LVim55bxM6rizVv15iS0pJ1Ynp5ZaUgKPbsphqtMoU9/DoRLY+3cqWqG0KT
	 4l0MKXuX8aHHSbjNlAlrLwC45o5J2kSF4jvuqtn+eU4Rw4m6HboPXcQVJfs2C53mZwg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796116958;
	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:Received:Message-ID:Date:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:User-Agent:Subject:To:Cc:References:From:
	 In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=wmCGIUxEiciMgYNZZrIGOHzyCm8pQ5VKyRL3IydPktY=;
	b=OuGaMZMBdu7LY+5MDSjSvNCY/OGpazGqFpj0xpUIIjP+Vk1WJ7wCJx0EVXvD6otaTpv0
	 SYobvEUR0S/+W6VofhtI19PjrLz0v2Lu7LU9NwOlYCkIPxlBw7K7zdEHKPo0mXf88S5Z4
	 PQSC/Nezq6tvLo0+JOKYnTdxXp/vO3fBXyTN+9rezxPtzR6gEreRj8s1RYl/zdNPlcqQr
	 C3/pMXEdC3Wj8cxQ7sesEtEi0aRtI3B8Pfu+GuN/08gxOOjPRq4GNTBrUeuI2+oBH+yWV
	 vLFOtemKfkZGOIRHp6UpPvnd10c+/xm6dOjZ588IK1zs+D19c+Z12z/bsT8+o25gC7w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="ZCg/csIS";
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.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 76F15606A33A;
	Tue,  1 Dec 2026 09:22:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZCg/csIS
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.178
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796116957;
	b=wCOY6Q8ZjvodbEC3+bc9SYVfNXNFqcLjRUp6w76kJ8eWft1+TSe4EJqoVjTw0mN9q/++
	 YPMk8IVuONW6UHM386QJWK6vrSnrctYuDY1yX2rb2f+xu8F/ugg408bz9wzZLPlTHyutq
	 Kdk1Kpw2y+iDhqEmYZ0rhsHf62vIyKzHAzH2O611QI/LLVUnHuD9dq2X/I2DyfZIQMviZ
	 ZjCSdC6gtEw2GXCLoUmjse/5t16dwnXedkqRJtu6z7rRtpYJGIvUjnXCVy/fFU7FWU9Xl
	 IiI9sh+vya8kn37oy0iZU6CO8rw4Rw5aSn8Qkmbl3iPeXxfFliNtw+3FhCIbe2p3Q4w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796116957;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:
	 In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=wmCGIUxEiciMgYNZZrIGOHzyCm8pQ5VKyRL3IydPktY=;
	b=I44Wb5ysjSIp/nTaflX13BDHP/K28OOtSmP9HM1FACp+2nSKraFqkH2rJd3reLbrz1+B
	 ZWVyanZqlanGvEAVs95ZpaN9ONpTZcX0QiPi7gjDt82z+vnH8ZW7Ht0KRlocr697SiL8M
	 LomW7w4Fo2wPWIYxI/8DI/9BQtYg9XQm/Y4KqwLqgtwF8sIgIabX2woxlIw16mFn6SHdF
	 IERzFCiIEoMYyLNAufmaQUhixBdfLRabmvKG0fXl2W1N6K+WRI562Wbw3PVFiKeGYx5Ea
	 XNIWws7WJQQJd+7ef+YHSQeB6gMvw3TKciuLXoUHthJQeOBG1ZHKi98x/uz2LzXh4LA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="ZCg/csIS";
	arc=none smtp.remote-ip=209.85.214.178
X-Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178])
	(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 414BA606A320
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 09:22:37 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 414BA606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2f03eeda984so62506195ad.2
        for <netdev@vger.kernel.org>; Tue, 01 Dec 2026 01:22:37 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796116956; x=1796721756; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from:references
         :cc:to:subject:user-agent:mime-version:date:message-id:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=wmCGIUxEiciMgYNZZrIGOHzyCm8pQ5VKyRL3IydPktY=;
        b=ZCg/csISQLOvnWgewCJHYO8Q2HpDNPJFyrEEJ03pcNAMXqBgo+G+zf/TLA/vcF6js/
         xOsJoIUj9FAeULS67MXx4qKfBZkuz6wI5W/6w5rrO3OKVo1PZg401XkSSlCQK3JDeg1K
         x6ZpAxFLm0BudGNdadI35MX1p091AcGBHVndA17fXAsdntw4EHRlpnYhoGR9xXnyWgf+
         w8NAPbu+zWW2u47E0asKGCnITsfpt7mHVB6xRg6541KHs8u/SCT0W5FyDg45JKVoIeZv
         +EI3yI1gJv7h1dsa1bxCoKwuhYcUR6yR30ytQQu5grGtJvvSOfgSmdgx4AwYH3hlZdNQ
         zb0A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796116956; x=1796721756;
        h=content-transfer-encoding:content-type:in-reply-to:from: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
         :content-type;
        bh=wmCGIUxEiciMgYNZZrIGOHzyCm8pQ5VKyRL3IydPktY=;
        b=kbfN2anEsenqnt/jhnxd96KQb6RsE5JHaDRj+lWIrBPZH+FHVJ7U43a7BJ6Fc/hlU/
         UOETe4BCQems/CHMJHuVJ9Tvx845Qwsh3Hkg8F8K3+jiVz1kdlpJDZ0Jgnywwkl784dH
         805j3/7z3qO2yHiHJLcYCVIZrpeFxxcADxdkts3r8ds2zKo7mL8IzQAgZuQQFCAhPrql
         Kr4zQwUBtw7ZMm8nN4PQq8SRpMjzjRy5G7r7JSnjMwgsFK9oq/daKRnWeL5C/Bx5bWBh
         wARNLCgrhk33mCMOkSlgP0OHeK1LDB8yzK3ZylnVB6VpC7lZ/8cpIbL9ZU9EftdlE27Y
         74Nw==
X-Forwarded-Encrypted: i=1; AL+hErF+U1O7MSLtKunYXt30gqBB8bHX0EWPS+xD4NZkeCl/peXS+Ox5zqvn2T361VzGLt8Vi8cnJMo=@vger.kernel.org
X-Gm-Message-State: APuU4Z+BKFJzIMeteNMTbI9UaCmoFU0QkCHY1GnPAH+K4XfDVm0B1DYM
	OsDH+wMlULuL9qsejScQP3+KirYWBp6NrILrh7jHagfgF90FuseVm9Mu
X-Gm-Gg: AZFdTZf++3Ydf5jyRnHYA0HvPWpRgg6OmzHyTtAiwdTiZMXUYm/j8ha/cz3fHlbKbqC
	Pw8Jj7eOhx39mr7Ay6ykRzXRvyBIpM5qLPm4BEPyHOuuT+dKaMpr32h/rXEtp9329EgifeBQaxX
	LTXALJzbV2LmJHfZEQnsPkf2IUJfjn3swQfMTEPEKe7K9y83hFuwLJwgU8phP7nNPT+y/doAlXE
	Ge9SfRqE+nYX3McjlM4TPUeixTdEAw2iJfGeT3a9tkwKREPDB+L/+J08OJdXYpFGmYbgsXYIj2Q
	CrRhx+cwNkP5/RhWD4RHMj9iCCrTqB2bgkXYleCENMc4E0o0zrWNJwIBY6IyB9gttqQSl8hIx0/
	Aaat98KxpX3TNDHSzDAcJ2qpWvwlS9cHPCkYULTFpNQ0uTKxzRsea7rn5XFSjAeqSzFfjYf0y8M
	Fxil4Z+Jt/uui011SGnS77RagilvILVAoG8Hxe92t4/z0JyqMYFZPxam9tgGGWRZP89IkKxV3cN
	+/xHHaXtnrV0yQ/txf+V2YnFWJ+bbBGMlWZlu6lFUPLiwks8xunxaQ9Qnrosz3VQuCpOEdoL08k
	Wwg1eRAjifc1c5yeM2QV888QAHsD33RLwSsWfTBFZ60lqsGqYHFHtcokpQ==
X-Received: by 2002:a17:903:4b07:b0:2ef:de9a:e59 with SMTP id d9443c01a7336-2f03f1a1767mr350937855ad.23.1796116956390;
        Tue, 01 Dec 2026 01:22:36 -0800 (PST)
X-Received: from [192.168.255.10] ([43.132.141.25])
        by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03ee848c1sm179568735ad.10.2026.12.01.01.22.33
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Tue, 01 Dec 2026 01:22:35 -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-User-Agent: Mozilla Thunderbird
X-Cc: 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
X-In-Reply-To: <7ecbb59e-d985-4b75-9240-ce83bcd87175@redhat.com>