From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BE18D2D8793 for ; Sun, 12 Apr 2026 19:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776022554; cv=none; b=hAggqP5zcQ8Cri0HASKY6331Mxo7x81R1/QQxqpmElr4ThJIHQ/+Ly+tltwMuEunFAqb9wz7dISIayt3ZSR52kXh5bIyjkfFqZSxLhAED6bUGhthqpcc9EGytByM14yIIeoamB2CpRO5ZoGxNkZgeC1WaKz9KV6/jzYvwp2tZlI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776022554; c=relaxed/simple; bh=3lYuYx/1DB+7hJAg5aGmApUTLScCCOsrHmPdhP3anUg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=roEdeyY5jlhaheWu4pwEwQsgswaM1L+29h6L29/0vFQ/ZZZJmhT+K9EUMUkEBjemymHRqbGkQJywTxT2X2Kzi8NJsq+BpwhJ4V/fqbxdu1VrzfwRjns/Wuj3dNIl5P9RsDOqNNwIBYazqSuv3enptBuikjAEmjor80my1UUoFBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tLbTht2C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tLbTht2C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31705C19424; Sun, 12 Apr 2026 19:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776022554; bh=3lYuYx/1DB+7hJAg5aGmApUTLScCCOsrHmPdhP3anUg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=tLbTht2Cgc9dYEn7WXFORFOWpa8T5Mm9C/qqv+EB1GmPWrtJ/fyQk6Knkujmwutgi dAAInACbW+ruzISmmmPmFfUEweNVQ2Ob/nJsyeWTIcPV0xm2oA/n3GuMZPXhP+C3Im /kXyWQ2jv08S8MZqfZuXaGJA67DcKmeC5oyNVA+ViLDnowC9NRiOawAgoKc4EHxxS9 Yvs0F4Uw1th+Bd3M4PNWBybyKwjQpfcZWkS2XqhTMJODIx6F1PfJJ79V033/meC5EW z/v5PqYePWrHYVg7DrL/fO9R/efjfGl5cV3V38bt4DpGiLdMUM3IRpnxeiaktAgT64 VrTbvi21FB2hA== Message-ID: <9c90a400-417c-4459-a82e-84a8b49a107c@kernel.org> Date: Sun, 12 Apr 2026 12:35:53 -0700 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 v2] 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> <20260406152001.2-arc-dt-cpumap-v2-pengpeng@iscas.ac.cn> From: Vineet Gupta Content-Language: en-US In-Reply-To: <20260406152001.2-arc-dt-cpumap-v2-pengpeng@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/6/26 00:00, 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(). > > Changes since v1: > - fold the NUL-termination check into the initial lookup test, as > suggested by Vineet Gupta > > Signed-off-by: Pengpeng Hou Acked-by: Vineet Gupta I've queued it for next ARC pull request, after the rc1 since we are on the verge of merge window. Thx, -Vineet > --- > 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..632976c22107 100644 > --- a/arch/arc/kernel/smp.c > +++ b/arch/arc/kernel/smp.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -43,9 +44,10 @@ 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); > - if (!buf) > + buf = of_get_flat_dt_prop(dt_root, name, &len); > + if (!buf || !memchr(buf, '\0', len)) > return -EINVAL; > > if (cpulist_parse(buf, cpumask)) > return -EINVAL; > > return 0; > }