From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BA18261B8A for ; Fri, 17 Apr 2026 01:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776389605; cv=none; b=SdWLLpIoXzkRqk56T7hfwn9XGZEh7a2hzkyjSio3FxAnJtBImXQlJIDCvqpmNbMgGdc+4ZpYOm3jhAhVzSMdo/No+NRbwT1pjehmyS7U+QwLuYAL4m3lZjvclSHzAii4T/TYTUk1rr0PL1swemdX2oGaiGkz5sXD5om7WLq1dU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776389605; c=relaxed/simple; bh=NNJQ3IBCEpDTzOuaxDUtzNlpaun5jfWr9xC9Z8TlErI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rzH7SnHkFdxdPj3/iV054o3mv7HBy3nETvQHWnZk5ROd8z8ofbDwTyfr50Au2yaLhuVjvPkKo28QYFDyCC3swAQOVfvu2r0l5Ad+JoszUjf1utPvyWjq9drIKrPbLkrLKBCoi5DinVLhtAS/LOVXdBFYCdzOnNzvCwRZVic+Bng= 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=ZT0sbawc; arc=none smtp.client-ip=91.218.175.171 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="ZT0sbawc" Message-ID: <3578a97a-bb70-4644-ab9c-4cf95be533e2@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776389602; 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=/MBo22biYumCIziOVkSTFKvBIGoA96wIF2u8b28uBF4=; b=ZT0sbawc2uf2ONKMSm0Z8m+uSYpH0woJE+IR/EI71NE2sviFxxQv6ACBRbD5UsaMo8u5b5 fgAMiGTYjsROuuQReEDl38pwB13Fq3h3aSopd4p2CsfjTfFlAmCRj+IzjIIQo2sI6okZte qtat7t5PDljV1YbqVg/NXKg7kH2JSf8= Date: Fri, 17 Apr 2026 09:33:12 +0800 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v4 5/8] bpf: Update per-CPU maps using BPF_F_ALL_CPUS flag Content-Language: en-US To: Alexei Starovoitov Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net, yonghong.song@linux.dev, song@kernel.org, eddyz87@gmail.com, qmo@kernel.org, dxu@dxuuu.xyz, kernel-patches-bot@fb.com References: <20260414132421.63409-1-leon.hwang@linux.dev> <20260414132421.63409-6-leon.hwang@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Leon Hwang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 15/4/26 10:21, Alexei Starovoitov wrote: > On Tue, Apr 14, 2026 at 09:24:17PM +0800, Leon Hwang wrote: >> When updating per-CPU maps via the lightweight skeleton loader, use >> a single value slot across all CPUs. This avoids two potential issues >> when updating on an M-CPU kernel with N cached slots (N < M), especially >> when N is much smaller than M: >> >> 1) The update may trigger a page fault when copying data from the last >> slot, as the read may go beyond the allocated buffer. >> 2) The update may copy unexpected data from slots [N, M-1]. >> >> Signed-off-by: Leon Hwang >> --- >> kernel/bpf/syscall.c | 15 +++++++++++++++ >> 1 file changed, 15 insertions(+) >> >> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c >> index b73b25c63073..f0f3785ef57d 100644 >> --- a/kernel/bpf/syscall.c >> +++ b/kernel/bpf/syscall.c >> @@ -1785,6 +1785,21 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) >> goto err_put; >> } >> >> + /* >> + * When updating per-CPU maps via the lightweight skeleton >> + * loader, use a single value slot across all CPUs. This avoids >> + * two potential issues when updating on an M-CPU kernel with >> + * N cached slots (N < M), especially when N is much smaller >> + * than M: >> + * 1) The update may trigger a page fault when copying data from >> + * the last slot, as the read may go beyond the allocated >> + * buffer. >> + * 2) The update may copy unexpected data from slots [N, M-1]. >> + */ >> + if (bpfptr_is_kernel(uattr) && bpf_map_supports_cpu_flags(map->map_type) && >> + !(attr->flags & (BPF_F_CPU | BPF_F_ALL_CPUS))) >> + attr->flags |= BPF_F_ALL_CPUS; > > This looks like a hack. It's not addressing the actual bug. > If there is a bug submit it separately with fixes tag. Sure, will verify whether it is a bug. If it is, will fix it with separate patch. Thanks, Leon