From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (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 D9B873438B5 for ; Sat, 23 May 2026 06:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779516493; cv=none; b=c/Wlq/BvewvAM5Cse7V1eMtK7QucwbULZ58xXGbtQXiaWDk1o0D7P+wyt9OcEYLFJ+0EOWRpvp/PSBqcMZD2vXk74qZ6t/S44WXo/Nzw25pyLn47FhNeau0LJFEXADjF3C1N5NfZ0zOPv2dPSZWhLaqBL7TCGpja0/W8tHBYgI0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779516493; c=relaxed/simple; bh=yFc1eDojAW6OMVzH1PVZXrc/Ic+iTOfWhnKl+u5u19E=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=DDnx1oIb4QRV7BoEyr3Y6GGwTyrxeWZ55DMpYBStX43lNL/t6HabX8jpq9FAZpd0JxfrsrT+yE6w7NnsT3BxN6y8z3JoApmNpDHnfH1Qq3ZpmXFH4796MpKfoTz2Hpfkj3JeGY2JfxjWQzoVrTG2mSjskguDfsDe7HLezPNZB9k= 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=kJaa0OOE; arc=none smtp.client-ip=95.215.58.187 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="kJaa0OOE" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779516488; 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=yFc1eDojAW6OMVzH1PVZXrc/Ic+iTOfWhnKl+u5u19E=; b=kJaa0OOEMca/jHAP+gWzLu/4webJODc3ONobMXJbHWKLVcOeLBCPU5zuN9bdf9JeDvkkAX wu7Qv3gWQtnQsQoW22VJVg0BWpL0ebDTLzLgVon1E6mGuJTtb1rkMu5gQ6PuJKYK2oPKai ppF91LRMT+9slBHThX9OZViGk4A9RhU= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [RESEND PATCH] smp: Avoid invalid per-CPU CSD lookup with CSD lock debug X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260523042703.862592-1-zhouchuyi@bytedance.com> Date: Sat, 23 May 2026 14:07:11 +0800 Cc: tglx@kernel.org, mingo@redhat.com, luto@kernel.org, peterz@infradead.org, paulmck@kernel.org, bigeasy@linutronix.de, clrkwllms@kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20260523042703.862592-1-zhouchuyi@bytedance.com> To: Chuyi Zhou X-Migadu-Flow: FLOW_OUT > On May 23, 2026, at 12:27, Chuyi Zhou wrote: >=20 > Commit b0473dcd4b1d ("smp: Improve smp_call_function_single() > CSD-lock diagnostics") made smp_call_function_single() use the = destination > CPU's csd_data when CSD lock debugging is enabled. That lets the debug = code > associate a stuck CSD lock with the target CPU, but it also means the = CPU > argument is used in per_cpu_ptr() before generic_exec_single() has a = chance > to validate it. >=20 > This becomes unsafe when smp_call_function_any() cannot find an online = CPU > in the supplied mask. In that case the selected CPU can be nr_cpu_ids, = and > the !wait path calls get_single_csd_data(cpu) before = generic_exec_single() > returns -ENXIO. With csdlock_debug_enabled set, that indexes the = per-CPU > offset array with an invalid CPU number. >=20 > Use the destination CPU's csd_data only when the CPU number is within > nr_cpu_ids. For invalid CPU numbers, fall back to the local CPU's = csd_data > and let generic_exec_single() perform the existing validation and = return > -ENXIO. >=20 > Fixes: b0473dcd4b1d ("smp: Improve smp_call_function_single() CSD-lock = diagnostics") > Signed-off-by: Chuyi Zhou > Reviewed-by: Paul E. McKenney Acked-by: Muchun Song Thanks.