From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (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 1D2022848A7 for ; Sun, 5 Apr 2026 21:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775424963; cv=none; b=QO8TqL3n1DEeJr5tnu7RVt16bEbDhaNlfLIpbEqg9WozA7GJ5m+WFxtBafO2Jvmiyo+prXmUqODtW1W/VBvS1fDd4VgHAtPyeit16NlKHazgHUoa1pqkOGPm//1s/T2ewBw/1b4flOU9gU7lgao9TVDrJRn555KUZNdTYPhYvtc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775424963; c=relaxed/simple; bh=BreTEwfROjS3MAOqFTGx6kwmc7dy/oAchP35enUqoSc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fmWZlrLCIR/57vVTpsvCrpwtPBb1yEaUZ4osxbJPZ0d4YATAEmAwbRREQUowgpZ0ow+EWQUqZwdR7Ry30IBvvVHcvd8YCqbrEu4VdX/kExLhxHxsSHLMzfzkc25SGUb707AH8LGRjTu1R4i14soC94ebkdQbDyUpziQAkp3VF60= 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=iYD1rEFT; arc=none smtp.client-ip=95.215.58.176 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="iYD1rEFT" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775424959; 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=7OArgJEPAI8F9DmozjP0epZraZMY00IfFSc2+NfThhY=; b=iYD1rEFTOMmiYxH5LKrwkaMdCn2vdovwpMN1J2bKTbYpdEbRKgY3PhsFbjwIiN7mDUMnCe 6/cTtiSs628IH+yixriuiVLYMEcTDpJdhU8sBEPzjGhy7eVJODGpGo5pX78aUJopROQBxM 3Y022ISYvCHgXNZEXtAp/irQpvWmC3c= Date: Sun, 5 Apr 2026 14:35:45 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] arc: validate DT CPU map strings before parsing them To: Pengpeng Hou , Vineet Gupta Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org References: <20260403161002.2-arc-dt-cpumap-pengpeng@iscas.ac.cn> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vineet Gupta Content-Language: en-US In-Reply-To: <20260403161002.2-arc-dt-cpumap-pengpeng@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 4/2/26 22:41, Pengpeng Hou wrote: > arc_get_cpu_map() fetches the possible-cpus or present-cpus property > from the flat DT and immediately passes the raw pointer to > cpulist_parse(). That parser expects a NUL-terminated text buffer, but > this path does not prove that the DT property is terminated within its > declared bounds. > > Reject unterminated CPU-map properties before handing them to > cpulist_parse(). Seems like a reasonable improvement. > Signed-off-by: Pengpeng Hou > --- > arch/arc/kernel/smp.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c > index b2f2c59279a6..e0f8218e9172 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -43,11 +44,15 @@ static int __init arc_get_cpu_map(const char *name, struct cpumask *cpumask) > { > unsigned long dt_root = of_get_flat_dt_root(); > const char *buf; > + int len; > > - buf = of_get_flat_dt_prop(dt_root, name, NULL); > + buf = of_get_flat_dt_prop(dt_root, name, &len); > if (!buf) > return -EINVAL; > > + if (!memchr(buf, '\0', len)) > + return -EINVAL; > + Maybe fold this check into first one as !buf || !memchr(...) Thx, -Vineet