From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796160267; b=xr9p+6/+GvqzajqF0Rz0UD1ePMXgxdnfwuEqaU1HoB5Jgl9mZFLK7jxUkihpLprm3xCl 1aXG/91EmVBcv+97mc0io8zz3jsQuQteWje2v9pw0wM3MWkw5/SEUPLsWmiIDaF0GgBgx f/IbK/x4X5ODu7YHojrjR6QWKQ47ibKuGQUZhctO0fusZZDUyExJsuEGPbZOhK7V/1147 rKXDPFmqvOya+2L2TzAQTZwAmMv1RrZDnKlSSjWgOpeKaLgbXIKH0CIzdMI+Y06w//ONR VVzYVlsIjbFbVM5yMjGVGtYXOqshoPCvXxPaKN3kZnZ5yaGuuihHtqRltnH2Gt7UIEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796160267; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Message-ID:Date:MIME-Version:User-Agent:Subject: To:Cc:References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=zNQod9cnlcVKk82UcOBOiMzfmduXNn9AlJ8faT/dV6c=; b=5b8TPWVYV9rx0B6zviysyPPrFSzuq4Dfywi90eXQucoKLNegVlYANdF/l3Cm35v5kk6S 7mMlIbQNT21VydD9OKetDU1m3+x3T8XrYoo3sAqn6XyGjMpR96PkAd7sdV8+5hVA7OQ1n iyAyIlKknzQFgs1BYtCZHoancRfrAMrP9cRTkBW/ez8jPVNVRdpj0aJ73Bf4D//2LtBJr bX1NrBNxzxLaEuKYBnjkc3PX/+wG4bAAjodb1MTEhbBNyea4v+ic6IJQLhiLf5kA6ZtvH pRGEn8jXwNQ41xLhK3m4PtG2f9dht5gvdhd7ACszy24i1Cf3hU+AfXb3TdJYqPB85IA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iv+is2eH; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=A2Egg7YH; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B09EA606A320 for ; Tue, 1 Dec 2026 21:24:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B09EA606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iv+is2eH; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=A2Egg7YH DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796160266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zNQod9cnlcVKk82UcOBOiMzfmduXNn9AlJ8faT/dV6c=; b=iv+is2eH/aZlkIIbZUOVIf7PTGJjtLcVdNARaa8mCJ+HILDDzPEFauebC5xy8WO13PpNP3 9aexU3dIXHLfRzKt0u5W/jWE55UGqWRMX6XsPy82NCGSXX0jGUz++hSUcLdOcm19vadV9G v/LxX2dNzKlfqFxuzZdBgGJXPu32z80= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-WNuXxD5nNHaEXiLK24k6Ig-1; Tue, 1 Dec 2026 21:24:23 +0000 X-MC-Unique: WNuXxD5nNHaEXiLK24k6Ig-1 X-Mimecast-MFC-AGG-ID: WNuXxD5nNHaEXiLK24k6Ig_1796160262 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4bbb2a62535so32248005e9.2 for ; Tue, 01 Dec 2026 13:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796160262; x=1796765062; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=zNQod9cnlcVKk82UcOBOiMzfmduXNn9AlJ8faT/dV6c=; b=A2Egg7YHRIPs1tzUYyAO+aZnHxMW7X2+IEY5+Irv5wDI5iI/8YUXVoRBYXpitaDd8h e79lwUUmwatv1++xo9SL2QtNBhNsC1Swny3Gxwp3wVMKFntcMekXnEqk0eFGtWWS3cK/ 31mvMmTq1BRlWAFRQB1TYgsTv6i/bJ4qFMh6YbQJClftJ17mOuVjXKceuOfXamuSgzFf nusrDeaGWl0+uQ29BP1LdxCdyxC1TOzpF1WMJhQVk9jjtH94B6wCLJj0UXHaF6MQmCVO AY6+4w/kLvl1PJ+aD1n53PqC0mmNfcmdjRiIShaI1eR6hgkUyBC1hvOeIQmgsEmHInO2 Tvkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796160262; x=1796765062; h=content-transfer-encoding:content-type:in-reply-to:from :content-language: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=zNQod9cnlcVKk82UcOBOiMzfmduXNn9AlJ8faT/dV6c=; b=JklTP6Dd3IATL4nIy8RFC692XzTJGSLOO8o4G0wIPDkU5f0+rmWkJ4Y2CvJCZW6n9Q GJsOeneIyZ2/2XxmjWmiI6L3PW9XnuOdRIBlkkm5LVtGYFlPWWya+arar+a2zY0FpeJs tJs3GHkpWNPVxIHh1BeOi867zpFR+2ZT58EeWKMnL5yfpLwruk6RJL1aMiQeKVpOYQSS e1i+ahaQEhi+aMh3ApdEhzHVNUfRszdkeNi0Us+1VBZK0MJjEZ5sMf/mAv9kytHQI5AH N1Zr0NXqeJ19DtbUSfURpZTrH6MFsuvZyjxQWQ3AZTXrE/L5Xqg8IX6/yEnjGJun/LPw eOkg== X-Forwarded-Encrypted: i=1; AL+hErHZKWWDS3Gr9WM2Cl2xUSPLCRgOXC77Xlwh7Q6GZJfDisHDzgP3fhIDhkXpvbpaPSfIcnuNxLJ8VI43XhM=@vger.kernel.org X-Gm-Message-State: APuU4Z+Z1d6w7RgvRZy+EAI7uts9tM+EAHyfPFnDhC970LeHzsEnjKQO IaSp1+jIXOgF5q4lFU/uWSq2KiOeMp3OecisZdqe5Wd7KaGCfsjK20mr/39oKdf5yxzmJSBfEpj GH+6lkldGnUDtVKsRRVVlIY6sYCtdngvR7GRbGVwbqtPHtkQWoDbnkSRzSMqQiNpCCQ== X-Gm-Gg: AZFdTZdN9t5yP/k3Yo9dD0/RhLkoFE2Wn8+JBjPNudBvATyaQ98zvaJakCL3aVgv0a9 dP2jLTK53Emc0dwGapTCZqFoSKYTWzolM6CNnDHwPwAU5CjVcYwytGAIVfg/Iyuy1tqKmWa5vym Dnlx59TmmwVWm4mVrpjyDDHwRg8pOsCIuHYXoKWzExNlIk0D4mlpkrNELL5yY347elx7zUAEaqX VAcuGdRwt7juuaggD3VRlzrXFsAn+igWnZ2HeCFKgzU3cxl3KRYYB8IYJdHcOJNjagzseX063yT 8ztqrPrdiPLeh1hdkR8QyyTbzunDUU9M1ji2CZpQRtmnt84hQObXkaA7lpQoFakJhgy69BUlRu4 +IBu/daYEgGITeeOZfDTOxcBmsWkQ7ocBNBe2lhDmELfB3a1sY16toiMwDYOj5XvcBD9kBkKIKv Glpbei8GQYreyOT+Au7li2FUbFO250r6BxRxfXa93nvdM= X-Received: by 2002:a05:600c:848d:b0:4a5:1cf1:b7bd with SMTP id 5b1f17b1804b1-4bb88810b2dmr742101235e9.16.1796160262226; Tue, 01 Dec 2026 13:24:22 -0800 (PST) X-Received: by 2002:a05:600c:848d:b0:4a5:1cf1:b7bd with SMTP id 5b1f17b1804b1-4bb88810b2dmr742100845e9.16.1796160261796; Tue, 01 Dec 2026 13:24:21 -0800 (PST) Received: from [192.168.88.30] (ip231-128-192-82.pool-bba.aruba.it. [82.192.128.231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884ab091sm1409391535e9.11.2026.12.01.13.24.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 13:24:21 -0800 (PST) Message-ID: Date: Tue, 1 Dec 2026 22:24:20 +0100 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: Jamal Hadi Salim , Lin Jiapeng Cc: jiri@resnulli.us, netdev@vger.kernel.org, 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> <143b8cc0-44c4-4a93-b936-a66677c1a0bd@gmail.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/1/26 10:28, Jamal Hadi Salim wrote: > On Tue, Dec 1, 2026 at 4:22 AM Lin Jiapeng wrote: >> 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. > > 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