From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.178 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== 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== 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 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 ; Tue, 1 Dec 2026 09:22:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 414BA606A320 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-f178.google.com with SMTP id d9443c01a7336-2f03eeda984so62506195ad.2 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=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) 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: netdev@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.