From nobody Sun Jun 14 14:30:09 2026 Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (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 F222A31A576 for ; Fri, 3 Apr 2026 07:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775202926; cv=none; b=hdJQLeadGr57hXEiZ5OFd8aAY6BIflJprp0oDy5ht37EpsmZxRCZA6zYIJkwih2Pnhf+Fep13tvj4FaTB5W8r2JhlOkEHwQSBUcxaTMSq4Ae+0jSZc3zAgSvZdW6rXQiYWL27YsHoXnszxBf4w555WKV7bEeh3+C4+fbNLwAOqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775202926; c=relaxed/simple; bh=vJg/OKFQqCXKH+3oSvdcEJjnuwOxT8AgmNW6WpzogtQ=; h=From:Date:Message-ID:To:Cc:Subject; b=B6LlNfY+OxKq192k0EtJ7hXNsANwZY1GglEgQDnzqXgOc7zYHIYuvKPW6seDbyRnuRNebHGCs6Y1qdv0Mpd2vy5g1AlxuXniacsenGefHSJYOXwherT77KepbYkxwVweW0B2V2Ph2/0vY2gE1yuUAhCp+JFWQZH9yoq4TWDb4KU= 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.81 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 0003-timer-sp804.eml (unknown [111.196.245.197]) by APP-03 (Coremail) with SMTP id rQCowABnieBfcs9pfaO9DA--.13127S2; Fri, 03 Apr 2026 15:55:11 +0800 (CST) From: Pengpeng Hou Date: Fri, 3 Apr 2026 14:55:29 +0800 Message-ID: <20260403183505.5-timer-sp804-compatible-pengpeng@iscas.ac.cn> To: Daniel Lezcano , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, pengpeng@iscas.ac.cn Subject: [PATCH] clocksource/drivers/timer-sp804: validate DT compatible before using it as a name X-CM-TRANSID: rQCowABnieBfcs9pfaO9DA--.13127S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr4fXF4xuFW7Ww48JF4fKrg_yoW8ArykpF Wqk3y3Jr1Sqan7ur1vyF1kAr9I9a10yFW7Gry7CwnIvwnxtryUZF43GFyUZFsxCF18GanI qa1FqF48CFy8uF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0264kExVAvwVAq07x2 0xyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxV WUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI 7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r 4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI 42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7sRRX_-7UUUU U== 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" `sp804_of_init()` and `integrator_cp_of_init()` fetch raw `"compatible"` bytes with `of_get_property()` and then pass the returned pointer onward as the timer name. That name is used in later clock lookup and clocksource / clockevent registration paths, so malformed unterminated live-tree properties can trigger out-of-bounds reads before timer initialization completes. Validate the compatible string before using it as a C string. Signed-off-by: Pengpeng Hou --- drivers/clocksource/timer-sp804.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-= sp804.c index d69858427359..8164ceefee06 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -284,7 +284,11 @@ static int __init sp804_of_init(struct device_node *np= , struct sp804_timer *time int irq, ret =3D -EINVAL; u32 irq_num =3D 0; struct clk *clk1, *clk2; - const char *name =3D of_get_property(np, "compatible", NULL); + const char *name; + + ret =3D of_property_read_string(np, "compatible", &name); + if (ret) + return ret; =20 if (initialized) { pr_debug("%pOF: skipping further SP804 timer device\n", np); @@ -371,9 +375,13 @@ static int __init integrator_cp_of_init(struct device_= node *np) static int init_count =3D 0; void __iomem *base; int irq, ret =3D -EINVAL; - const char *name =3D of_get_property(np, "compatible", NULL); + const char *name; struct clk *clk; =20 + ret =3D of_property_read_string(np, "compatible", &name); + if (ret) + return ret; + base =3D of_iomap(np, 0); if (!base) { pr_err("Failed to iomap\n"); --=20 2.50.1 (Apple Git-155)