From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-221.mta1.migadu.com [95.215.58.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DB2933F5BC for ; Thu, 13 Aug 2026 15:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.221 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786633284; cv=none; b=ifG7vJkNmxX4NA4ERbHUPh846GQSFLpUsfYwvE2kH2J/1vxGN8K0GsULJZseFuCL9IrQ4p9GbI76U7todVRS7vB2nYbliLa6ffGcejyrebiIkDH56CjKKCJSWH1/JbFlpg0aztbboU905HkjUH6CIhgigL67RzOd3QSdTgI+U8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786633284; c=relaxed/simple; bh=kjQCGgpsYPUeNoy8VC501KK4ntDE5I7q0H01tiCcS7k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YYTCxIeD/nbAkinwrQ8ov7LEwwLodwuzwN2/kkquTqodqCiGHtwKDunLMl3Rjsm7NwL/zGRKRMFLhqXuPf46GrDWUmkaHZBqLOqV+ETuSsJuSUxMsSiiEgu/FETSCyV70M9IOb52eUnngx3wvziYJK+d7uXzaKnxUXPbLWnXN7M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=FRWg1qrQ; arc=none smtp.client-ip=95.215.58.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="FRWg1qrQ" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=kjQCGgpsYPUeNoy8VC501KK4ntDE5I7q0H01tiCcS7k=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786633279; v=1; x=1787238079; b=FRWg1qrQbMdFehBrMjXWDKeV4ZCuuQZwLfP7te3UtNqvAjQLLjzW9NGc6V02dXTgWGddCO1P yl9hGgVObKrZayOw5lRH916CdhRC1cHgF4cuiE9lw5dsPTjRN8rJ+2Z65ox8RT+H3VkmgF+NYwX dCef9F5jdRN53LWT7nOFMpkw= X-Envelope-To: linux-kernel@vger.kernel.org Received: from [172.20.10.7] (117.20.149.103) by smtp.migadu.com with ESMTPS id bb8ba90ab4d9734f; Thu, 13 Aug 2026 15:01:08 +0000 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Thu, 13 Aug 2026 23:00:56 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH bpf] bpf: fix percpu map update indexing with sparse CPU IDs To: Hui Su , bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, sashiko-bot@kernel.org References: <20260813120250.796934-4-sh_def@163.com> Content-Language: en-US From: Leon Hwang In-Reply-To: <20260813120250.796934-4-sh_def@163.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Hui, Thanks for the further fixes. On 2026/8/13 20:02, Hui Su wrote: > Per-CPU array, hash, and cgroup storage map updates without BPF_F_CPU > or BPF_F_ALL_CPUS use a value buffer whose per-CPU slots are packed in > possible-CPU order. The buffer is sized as: > > round_up(value_size, 8) * num_possible_cpus() > > The update paths iterate over possible CPUs, but use the logical CPU ID > to calculate the source offset: > > value + size * cpu > > This only works when possible CPU IDs are contiguous starting at zero. > > For example, with a possible CPU mask of 0,2-3, the buffer contains > three slots corresponding to CPUs 0, 2, and 3. CPU2 is therefore > expected to use slot 1 and CPU3 slot 2. Instead, the current code uses > slots 2 and 3 respectively, causing incorrect per-CPU values and an > out-of-bounds read from the update buffer for CPU3. > > The corresponding lookup paths already use a dense offset while > iterating over possible CPUs. Do the same for the array, hash, and > cgroup storage update paths, advancing the source offset once for each > possible CPU. BPF_F_ALL_CPUS continues to use the same value for every > CPU. > > Fixes: 8eb76cb03f0f ("bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_array maps") The ci bot got the point about the missing Fixes: Fixes: c6936161fd55 ("bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_hash and lru_percpu_hash maps") Fixes: 47c79f05aa0d ("bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_cgroup_storage maps") > Reported-by: sashiko-bot@kernel.org This Reported-by is unnecessary, because Sashiko would review most LKML patches. > Signed-off-by: Hui Su Acked-by: Leon Hwang Thanks, Leon > ---