From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116957; b=XR70hlkmwTNuLzsmNCiNyMsSRExf5fSCZcc7sgX1noxoaTscb7P2OD1USS20q+fSrZ9+ lIndjX5zN9cv7Dx6kj5l9VJVINAZlozaXct6uCKs8MTSC3mpxnthonxKvqcSGaW1QwLVQ D/hVtCwXnVMoxPQG04b9oUabTQQB5904wIS6I1tJK3eBCq6GqfFLMAuzJ/6ALQWPLiUOV 315DdIlEKzXK6aT4PQ0SUA3Zqq7Ve/WjKROM2GZjd+70Q2djJeSFG6lTvRgk4A8NNYqcN UYuvTudXRKKypmd0S2LmzyI3tpry5bFu0JSkUFQ74Ioc6KnhLkaKZyA+3RHxXJfiR0Q== 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=oRkYtOq2yrdVnqebv/OHwzZXvkLAU/WfOYSWblInDGvfJxuDBsZrzMTGQEjs6gxNcedC PNnIqpCN/qRRIKu8vLvTY74zWsOXa9niRE5PqrqiHzkVYfcxRbDFEJPuboCsB6HWxNIzP UOc3rcvtrBuFUVXEycdLoVq2qFz3m0JLnOXCEIlZ1kZ+a4aytkqYB89WbksdzSkkZD1HV haQ4yVArAOauUtArHZ/aco/wfJz54PD2R48wpZMV+/JlPQqvBnSOk/vZxhZi+f5qd9a53 5/ZnkZIOPihKE8ZYINiRa1k39G2nkIfIflmR3MdBfNfeSoEG+nve++13qHRBvJoZADg== 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.173 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 57BA3606A325 for ; Tue, 1 Dec 2026 09:22:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 57BA3606A325 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.a=rsa-sha256 header.s=20260707 header.b=ZCg/csIS Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2f04f61282dso54542755ad.1 for ; Tue, 01 Dec 2026 01:22:37 -0800 (PST) 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=RmOxYQpQr967wyJtisUaWA9gMAS9wEt6iCp5qcjEjVe3StD7usCQzKvEQlhibirKUF 5GbUaWXsPd2widfQ7oybQrL5TNbCePkb5anOuh52iWVTFttp+wGZiEVVIVFuYIRjqZgc GVLBkYOX2WSKL0tUH1GZF15YqcEvIbo1w8F5e7+E+CBiMWtNphS6okNwVznEzhfWCeux dvv2CEebcYctBAV1NSlNGcFFdAXt8WbuB0zy6m/9GvaIvypN7yVbWVHEzKnVzZRugnp/ EEPe/r4L62ydebQ4HZytGq/4v7I9/HdWXNzpalLZ15h3HUxBP7gs+/QMruNkuaDL8FTE HjBA== X-Forwarded-Encrypted: i=1; AL+hErEXJ55BoBWM6XqyqSbEWZ6rg2f1HW0LR5KG60hsAWK30K+hg0G217Vh83JcLnjHf/Iva4LUbD0jaR3hCrA=@vger.kernel.org X-Gm-Message-State: APuU4Z8LXCy5rv07F7Eg20ngkIH3QaXqdcGig9yl7speqISW8efN8DrN x7jgaX1eMe+Tn2glTK9VADQsGKO6GHLUTdHbJOS5y8Nlf6rBrot3Um8W X-Gm-Gg: AZFdTZfGmPnjZLJ8U49O4njhmD30DrgdojXuWkDzxxvNLCjd4QPTJmpBgu00bMw9oHr /hHZaBSO6fphHte5F18iHbiRA+DKyLuWk+gRfrIM+boQvdnmhvEj2V37fMGic2aaY0dXOzkA6vl xca6rIHXItIpf0UTPQOk41hjFz3KGgo1b/WJMGKgAawp+Xjuu9Oa+LRLJ4RJLTL+9znsBQ7xOjQ rMkbzlOOsn43wZKKtjfMwtxa5fHLqBUKDN6eGV4vIqZSs7zu/q5wt0J17Fhs4GbpuLzsLe1YHbq Wrhv07mK2HUVQ24u1IM/p2f066Dv/HnvKlr6zC8S5POx1LKRApRxDn6CgLdmGTkZ86mrL8ti+m1 Ba7UfEHqklHqkrbj+itxu0oxGycCzd4nxlLfCTd6v3Njh4qXkIWNL6lKJS9S1R69D7APRqhiMd0 KTwiOnRG9a7TSre8zNQzEOYEb6vP74SsNXrSJttoJgIFNLS+bXLigm4kraODT1nEJduJyS4FZ3Q ISacNVuJDquykuqTIWj1l4Z2ppRLFhDG1yDoUzI7/UFc19RTJhJ9eLXF98OYErlqXj2vTBcnKp9 fkylQioBzgS63PmUlrHgvIft49Kz7rErcterViY3553zJgtwUWpX0qvsBQ== 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) 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) Message-ID: <143b8cc0-44c4-4a93-b936-a66677c1a0bd@gmail.com> Date: Tue, 1 Dec 2026 17:22:32 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 net] net/sched: sch_qfq: bound backward slot rotation To: Paolo Abeni , jhs@mojatatu.com, jiri@resnulli.us, netdev@vger.kernel.org Cc: Lin Jiapeng , TencentOS Corvus AI , kuba@kernel.org, davem@davemloft.net, edumazet@kernel.org, paolo.valente@unimore.it, linux-kernel@vger.kernel.org, horms@kernel.org References: <20261124040208.13282-1-ljp1205831794@gmail.com> <7ecbb59e-d985-4b75-9240-ce83bcd87175@redhat.com> From: Lin Jiapeng In-Reply-To: <7ecbb59e-d985-4b75-9240-ce83bcd87175@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-12-01 1:22 a.m., Paolo Abeni wrote: > On 11/24/26 05:01, Lin Jiapeng wrote: >> From: Lin Jiapeng >> >> 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 >> Link: https://lore.kernel.org/all/20261116121710.77403-1- >> ljp1205831794@gmail.com/ >> Signed-off-by: Lin Jiapeng > @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.