Netdev List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>,
	Lin Jiapeng <ljp1205831794@gmail.com>
Cc: 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
Subject: Re: [PATCH v2 net] net/sched: sch_qfq: bound backward slot rotation
Date: Tue, 1 Dec 2026 22:24:20 +0100	[thread overview]
Message-ID: <d3cde999-1651-4881-ae45-5c912889ac8f@redhat.com> (raw)
In-Reply-To: <CAM0EoM=HCGh-ePzG2V7RSwbh7v69zzVh+0qf+O6K0HHw+qefaQ@mail.gmail.com>

On 12/1/26 10:28, Jamal Hadi Salim wrote:
> 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
Since it seams that the lack of clarity is not just for me, I suggest
reposting with a reworded commit. Please try to keep it concise and
include all the requested information.

Thanks,

Paolo

  reply	other threads:[~2026-12-01 21:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  4:01 [PATCH v2 net] net/sched: sch_qfq: bound backward slot rotation Lin Jiapeng
2026-11-30 17:22 ` Paolo Abeni
2026-12-01  9:19   ` Jamal Hadi Salim
2026-12-01  9:22   ` Lin Jiapeng
2026-12-01  9:28     ` Jamal Hadi Salim
2026-12-01 21:24       ` Paolo Abeni [this message]
2026-12-02  9:18 ` [PATCH v3 " Lin Jiapeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3cde999-1651-4881-ae45-5c912889ac8f@redhat.com \
    --to=pabeni@redhat.com \
    --cc=corvus@tencent.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiapenglin@tencent.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljp1205831794@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=paolo.valente@unimore.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox