From nobody Sun Jun 14 14:46:27 2026 Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F5EB274652 for ; Mon, 6 Apr 2026 01:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775439866; cv=none; b=QI1YNlIRWJg1i+dsyQYVjCCKK+EK3HBPc2SnpRpkLW+HR4KyWQTaoF4aPWiZgj8NNWsA1ZMno+ge5ncSt7RlCkUzBM5OihYhj1XAlVw08uBvtcjuN5L67M2/CJlP8/qk6zW/ZhRbLDuDfwKf6BRs4fMdluZsItWT+hDiNfnzjqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775439866; c=relaxed/simple; bh=bvWzZn6h1/k64pOvr5f0bHCXKLNYiZdsfDV9U5VnJj0=; h=From:Date:Message-ID:To:Cc:In-Reply-To:References:Subject; b=GaH8XoEsnCy0LxDBuV1B3WxQ860J6g5pDByOY4MYKV295zTJJqWxguhnNaGiYRGYOZsPwX/2nNIdPEzB+Sp9X72X8ngrEBnjC9+SkJoHEu2Y/vQInqshokXcc3zzYPbFLIPwRbUK4bk/dF+D7c/bOrFwqzJ023j2KMgjM9bNlLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from 0001-arc-v2.eml (unknown [111.196.245.197]) by APP-05 (Coremail) with SMTP id zQCowAC3Sg70D9NpD3imDA--.29086S2; Mon, 06 Apr 2026 09:44:20 +0800 (CST) From: Pengpeng Hou Date: Mon, 6 Apr 2026 15:00:00 +0800 Message-ID: <20260406152001.2-arc-dt-cpumap-v2-pengpeng@iscas.ac.cn> To: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, pengpeng@iscas.ac.cn In-Reply-To: <20260403161002.2-arc-dt-cpumap-pengpeng@iscas.ac.cn> References: <20260403161002.2-arc-dt-cpumap-pengpeng@iscas.ac.cn> Subject: [PATCH v2] arc: validate DT CPU map strings before parsing them X-CM-TRANSID: zQCowAC3Sg70D9NpD3imDA--.29086S2 X-Coremail-Antispam: 1UD129KBjvJXoW7AFy3uryUtF1xWF47CrWkCrg_yoW8Gw4fpF Z09FyqgrWqvwn7Ja4qyr1xua4Ygwn7Jr129FW5Kw47Za17try8XrZI9F1v9r1xAr409a4a kFZ8uF4qyr4UAaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkK14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUWVWUZwA2ocxC64kIII 0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xv wVC0I7IYx2IY6xkF7I0E14v26r4j6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4 x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8C rVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxV WUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lF7I21c0EjII2zVCS5cI2 0VAGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrV AFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCI c40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267 AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7sREbAwU UUUUU== X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 =20 #include #include @@ -43,9 +44,10 @@ static int __init arc_get_cpu_map(const char *name, stru= ct cpumask *cpumask) { unsigned long dt_root =3D of_get_flat_dt_root(); const char *buf; + int len; =20 - buf =3D of_get_flat_dt_prop(dt_root, name, NULL); - if (!buf) + buf =3D of_get_flat_dt_prop(dt_root, name, &len); + if (!buf || !memchr(buf, '\0', len)) return -EINVAL; =20 if (cpulist_parse(buf, cpumask)) return -EINVAL; =20 return 0; } --=20 2.50.1 (Apple Git-155)