From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 4B6D7330B10 for ; Fri, 3 Apr 2026 08:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203714; cv=none; b=gcKgX0UKbkZ8Bcv+0H73lgBn0Taf7sNm1beHhTH3BlAbYKrsVB0+pgiqPq+DS+pG6V39cQDe3ar2nPjOw4MfW4SwEarv5bHxSbPNpu8oNhL81kLJGO2jw8BFQLpfQVIrTQ4n7hDVVa8CxYFJ/hlCz1re6Lum+fSOYH7y7Og+Zkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203714; c=relaxed/simple; bh=LTvWWUk5RI2Hh0XVsAScBzRIKWb9ZswY31RYkIbz9SU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZSGTeBi0sxKLF7EKY0uITtwm0cHM2jiQmf6vKv6Sfupi5PeSeuQE/C1rYkrFXrQJBWccT0A0VH0yT6NDx4qXXx81gQapaSH+XZP/J/GWcMCHQLVh3h3Ib/5gkTygAfRnvEJivHcKe4QmnAiu2zxCBvQRcpySJx1U7pgMHaUERGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=lqkHuzCg; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=hBLtZDCF; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="lqkHuzCg"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="hBLtZDCF" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6333C58s982316 for ; Fri, 3 Apr 2026 08:08:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= VZhcvxDFzn1xS32HvpBkUEaxkBPL6ouHLTXaO8Ffxbs=; b=lqkHuzCgezPULNAO d82ilfEfunPbOh35X0fXvkuoqAq/Ca5edQ5cRUowg2KYg/5y91ZtRmCd5ovJKy7h nwHJTF55782P6VVYCf+eExngjbR4Ov5MHoEBvxA0AI90K7NTKTYikxxoOQVGp7Td UnAfgg3WAeT2QE9mlrprX4p8/gGTDdt8ANyzMkWdo7dMK7y95huK8xLDskMxd2BW MxxS5xGcpSwSVIVOK1he70yOBvmDqEV5mroZsUOPAXXmst37mgn+LO/EzU15loOq I/rVYKiVM9cSSp1kTN+xM4sNOCCBlEpn6y1Q1e6g+/NaIwYhjo3TiHAk+y6wOQg/ BXqYCw== Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d9tuptshj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 03 Apr 2026 08:08:30 +0000 (GMT) Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-50b220c72bbso54967681cf.1 for ; Fri, 03 Apr 2026 01:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1775203710; x=1775808510; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VZhcvxDFzn1xS32HvpBkUEaxkBPL6ouHLTXaO8Ffxbs=; b=hBLtZDCFhYfhE6PQDhEsVry7usceF2LVXioJYKjOtaGF0KMtPFbvx8MpvAC6SKSB9a 6xXmHzqMaYPZ6f5NLNgyJnz4dSS8gibnxLWXesa5dr8OxPsoRkpgFk5acAhprvmS/IDN IENpriDWiVRhOkIVqGtlXIjREExlikjK+/SmLMLqC6HBaHJllQCKYQqDkL6JEnqsiMjV BvfsNDn+sfAUeGTybkfLeMEssN4qvG7zQeaU7GKfzlkVCGbFWOYA7lC7UlPrgFP/LR5I eVMVxI9iv9aIMYcPZ0oHixJb3IlXsSB8i/vfe4aSaU5MJdc/wdt11T2hDKwLT3YULy/E GY4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775203710; x=1775808510; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VZhcvxDFzn1xS32HvpBkUEaxkBPL6ouHLTXaO8Ffxbs=; b=E5lsc4gBkgAJn8M0zKfheSzM97pKveTdAwsgmtcV0kYSlGAdnrhAnqnFTEH71HOOo7 8kTP4b7L2aZsM5plppJzqovpW4hliI26O+zOfgy4NNiMZofK8Jp0w15Zg5R6zxM89NUN l0lQi5yZN9C0TfZ7ITL+qF+yONtFPvgwU0odZhLWVpOFrCZCZOfmSdJGNK1Q+8MsKFwx QRY5zr2oflWd6IUanqWBWfE/a69A1eg8SCiXo2WXK+FwkKPutW5//v3ihu9zuyHZXWor 37xGfMhEUCxnHMGr76eWsVY344G2U6Dt2r1uadz6Q/TtO2J6ss9ZCOifDZNpH/CSrjS5 j/iA== X-Gm-Message-State: AOJu0Yzko26yU3es816eM7EwjOxtDoNjK4sHiV8P6yfk0vgjbleAlaT5 UkosjDRozYmhaYz9yuBH9x36pRM825njGqNAQVfrjNKuwS0TBytV3Cdkz+czRuHzcLgtzrkhAUK EyHnpD/yIcRrDH7BOjUSkeC07fTSto4ElQZV7fXineE5YUy3MffuLqibwK81sgvzxOjY= X-Gm-Gg: ATEYQzzLkqVK7+NgWhlY1YH0s4vSZJoQngylNGiaP5ilUC+yn2CEVY7yq0udoq69wXL XBG58OyLXcQYWuZ/GA8OP/OawDPrs9Vq9pB6/sdNFiJlxI0eJ2V9GAHqz8ZidcQ5SN8GLoT0yfV 58yyQKTrgOch9QQg5ScmZJjcNTVywBJljpTpmejsvDymXN2MhelPSqNzeRz2kd1CkIz94s/t58r fJaJ7JmH2PsQq00c5+mPbFZNuGASEiLSmHu0nZv+RP6Nenc5OX4JX8A2E6+4EawGu2JsiY5+S+e kmFqIDYYIZ/+ylISkIp+mV/57uxWIvIHLcaZphIuHDfnX3Bixyc28LtVPkBr1GKNlhAx62qWUq0 91r8VuXw6wgA8pEGeI8tSS/CKcWlFGJBka7EWZpSUUy2NK+H957fN418czhLOD95dawQu6QMfm8 DOZ/Gw1mY9 X-Received: by 2002:a05:622a:aa49:10b0:50d:5008:25ad with SMTP id d75a77b69052e-50d62a41da1mr24815701cf.31.1775203710305; Fri, 03 Apr 2026 01:08:30 -0700 (PDT) X-Received: by 2002:a05:622a:aa49:10b0:50d:5008:25ad with SMTP id d75a77b69052e-50d62a41da1mr24815571cf.31.1775203709907; Fri, 03 Apr 2026 01:08:29 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:ae20:597c:99b8:d161? ([2a05:6e02:1041:c10:ae20:597c:99b8:d161]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e2a6f13sm14365831f8f.3.2026.04.03.01.08.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Apr 2026 01:08:29 -0700 (PDT) Message-ID: Date: Fri, 3 Apr 2026 10:08:28 +0200 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] clocksource/drivers/timer-sp804: validate DT compatible before using it as a name To: Pengpeng Hou , Daniel Lezcano , Thomas Gleixner Cc: linux-kernel@vger.kernel.org References: <20260403183505.5-timer-sp804-compatible-pengpeng@iscas.ac.cn> Content-Language: en-US From: Daniel Lezcano In-Reply-To: <20260403183505.5-timer-sp804-compatible-pengpeng@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDAzMDA3MSBTYWx0ZWRfX3GWTE1wZNigS 1a3EeTakwOhQYacHHzvlNzsYBLBvVPn8IA1twqbFqqxxPf3KxRU0n+l0bks8cH+z02EZp7M6iSx y8v5zuY8mwoYRMpTO2RmGrgaJkwdkNaZKH6hl9UMnD/eERfialTp+7zdBXjF3qwgY5f2kJu0y9A v9D0aeZYrg22Tp+dAUZWuV5yFc4gisqOXqcmxizkvZWgn4GCJqI6s1amhJkH87wWy+OCXB8DFgt I8VwMujEPJAKMytUiHTv1S5mWSkYbAE+HciOBEFryqjoKVwtH+ipONbsMK9U1P7aqus2Kejnupo NZo9wTuT1U1tnn+FoAHHDvlRPLwY0SQ5utQUmqfAqRMxOvd3MnJslqp2eURH06ZE8b9Zcuqbz4L QByMesBGFaQSaJVCeXCrclW6DpPiQHSx1kVz4F97jCVyxj2i54BLKR1NEWc+13e1lKLzADfuNvq aAW61YZr7wb11Li1OYg== X-Proofpoint-ORIG-GUID: hMQ7Hz9tMNoAzjGircJsv1_W5qcbBHIG X-Proofpoint-GUID: hMQ7Hz9tMNoAzjGircJsv1_W5qcbBHIG X-Authority-Analysis: v=2.4 cv=DZ0aa/tW c=1 sm=1 tr=0 ts=69cf757f cx=c_pps a=EVbN6Ke/fEF3bsl7X48z0g==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=mpE5YTnArsVgtuVLCKgA:9 a=QEXdDO2ut3YA:10 a=a_PwQJl-kcHnX1M80qC6:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-03_02,2026-04-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2604030071 Hi Pengpeng, On 4/3/26 08:55, Pengpeng Hou wrote: > `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. If the function is called it is because there is a match with the compatible string. It is pointless to check if it is valid because the location of the executing code is under the condition the compatible exists. > 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 = -EINVAL; > u32 irq_num = 0; > struct clk *clk1, *clk2; > - const char *name = of_get_property(np, "compatible", NULL); > + const char *name; > + > + ret = of_property_read_string(np, "compatible", &name); > + if (ret) > + return ret; > > 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 = 0; > void __iomem *base; > int irq, ret = -EINVAL; > - const char *name = of_get_property(np, "compatible", NULL); > + const char *name; > struct clk *clk; > > + ret = of_property_read_string(np, "compatible", &name); > + if (ret) > + return ret; > + > base = of_iomap(np, 0); > if (!base) { > pr_err("Failed to iomap\n");