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 B8E64466B52 for ; Wed, 13 May 2026 12:53:13 +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=1778676795; cv=none; b=qVvtFL5BuF0s+o1uBsIPTI3ev+1RAN7k3m+eF7ax0RLKMxLM6oFswv73I5NyfbSl+E/EcMPUjsl0tE6t21y+6pC+qJcd3eLMKVoQLPIrCX+lt/DqxbH1qYNqgOgEPeK5fEsgFwJwainZt89MPnj7erbGTcMmQrSgc1DXnLr815s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778676795; c=relaxed/simple; bh=/HH7haICvL607AxS8hNW9kSpLZhGR6SydcI2RJVfWCU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YvP/CHR0wHciMN7JjIK9isWO4aNkuEyBo2uQx/4ELre8hPr51FiS24H2F7xDyRhMA86a5c80U2w1lnDo8KVhaxB2eVfhdaPeeWs6zlnD/tz+hrb7RaMCs5v8rEKTroBZ6PNAZnFJyAzr6KurDOtv1zvghWq2w0idOiLlX7wnT8E= 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=AqiSairY; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=UU7Oue2J; 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="AqiSairY"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="UU7Oue2J" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64DAVGLv3430122 for ; Wed, 13 May 2026 12:53:12 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= aTLeqmMmfK12s4Sze+pZmjyLHuMZbfIZnuitTDsnOuY=; b=AqiSairY52agx2UO eVjuap63L6tTx/GauCDW4xJdqb+fclI9bH3ImGBjaUisyy8Qlp/qP7hdlY0idlY/ M2DvLTvldjKK1GsrRt4DfkYEDmS7cqbi3XV03Zo1pAf06KR4cv8nWez4pJ4Mwez6 G0IjagL8hTQLnAxh+BeH+esKtbfJNI3h/OSbtTmwU48wEh4RtZCvsgyUFqzM5PFD NDtUfQlpiVcf3xy1wGz2IXTiuVQEFyd2qNv15myxvQ2WJzY07tcOIpsfcVUoZsPp gIOHOLEI0b1QPjfpKq453c8kfnhlgl8daSvM8ys5IWaT3xU7Ie7s0CKovqMJOsaQ mVWAiw== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e4qmcgffn-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 13 May 2026 12:53:12 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-835444b6ce1so4852880b3a.1 for ; Wed, 13 May 2026 05:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778676791; x=1779281591; 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=aTLeqmMmfK12s4Sze+pZmjyLHuMZbfIZnuitTDsnOuY=; b=UU7Oue2JGTyMNnjjkyaED53TpVHaLWiCMU5SSOXmhITEVNiLs5wonrNmphd8LdZYXy wQXIpY9nwcjQVuUZkxvtJUCmYggxkmxV9qPk+XZTfogUoNXCDF9W+3cJ6dVGFLcuN44d 9DO6MPBs6RTCOAu71HsBydcNEaZL/wuQb11vIE8pKQ6ukZxDodOJqJpqZFGgMyS4zLDl F5QNpyQITdbSbrJ4AV1UwotBdyy/fHuUc75EZMPu8Kouk7vbIbdyCDCPJnbax4o66Y4P 6EOeU/2ZjHRYysoOW5HoFrt2/eV8eJI/1ckHuGgn3JpK/B7b15i6yn/YDsA/OGjkEgS3 xsHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778676791; x=1779281591; 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=aTLeqmMmfK12s4Sze+pZmjyLHuMZbfIZnuitTDsnOuY=; b=sfz4g6njmtkr2BbLK1wOMl7X/D8vhUAX9RoZGZ1MrstGvUDON4O8UHkQ/p6t9f0fMD W6v3c3kiC59o4C8M0+0eU/gtdbEVT9aVsC5yWH7n41BZsPbrrsCyUyvCwE5QdAqwoYMd zyJofgT+tHck9CLe3lN2K5iVb6VOCkHy7RGHTKT/G7I44Px+9LAldV7W4Z4LdMn1nGB9 a+TTLNG2VwW80oGkiOAP/0bxEs5XiZstPqr4dqN/c+p9qpIiRANT3xooYHTDRddw202Q rLYJx6otT+IRmr8sbx20+iwBtrjcXGxvHUwXAc2QmosgKR/dCYvJu2jCvdtDPq5pGsGl ct+A== X-Forwarded-Encrypted: i=1; AFNElJ8RqsM2jYvSENK+7Na4C3I1/4XZlrduf2xKRK4iE98VMHRw5t6SEtCmXnhk1tovYJbcHfaKgKsfrGRl57c=@vger.kernel.org X-Gm-Message-State: AOJu0YxCZVhxVM7SemBHOPNPUuMX8BCDYM0MS+fUbU92qMZhcAPwVZlG nVtoZDWDYpBwYMPXi9xiJLCrcO9ze7Dh74lHTT7JuyjEt8I5d0EjWnBlLKQ/ZSKQe0gjFKO3LAu EJaHGNV1s9s/7Imy3BeFLU9D6ezttdopuSufREMEXBYUn2i//9F3QLRVflPxMiz0qy2fxjpniE6 8= X-Gm-Gg: Acq92OHrPylQHYwhMwo+sstaUp6vLqzCr8TQ1F6qSlmeMka4HQnFnmNKa7SSiKW4gVZ Ct+HIQB5k7h009xtDCVfyv6+kclGeu+ippVM60fOtaP9fwAwHsm9TsqOiiBdpQB6udZUrpc3elO k72DwTgt8WiXPe3pUKMS2fjXCf2C/XvWnVUBFKBZIfuu9Ls/Hy0JUtz0OSX7Jkdut87XQNpdfBo wneyimpsMdVjROFe5e5bVKWqvfXmUQYnwRUnEVKYmN9VPZ48V7yfTBPqw60wtJY6mD8ZorM/s8g 5ebpPamqoScO63G4CcrbvWi3/I4T//91jdXhKakKetJyH/110bZEnqMaKm3gxCQUY1HTdt3Ipm7 Jxx7nrhPBwKxqaSQIZbOnLnkc7SeiS6PzToF45GRNVf97fohhw843c5wD5NVyiDCUxJKhRKk2wS cNRFrognP9AWTpD4SSGg== X-Received: by 2002:a05:6a00:a227:b0:81f:ac81:d597 with SMTP id d2e1a72fcca58-83f04fd7db0mr2661198b3a.0.1778676791363; Wed, 13 May 2026 05:53:11 -0700 (PDT) X-Received: by 2002:a05:6a00:a227:b0:81f:ac81:d597 with SMTP id d2e1a72fcca58-83f04fd7db0mr2661165b3a.0.1778676790867; Wed, 13 May 2026 05:53:10 -0700 (PDT) Received: from [10.133.33.247] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-839682a52cesm25421224b3a.57.2026.05.13.05.53.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 May 2026 05:53:10 -0700 (PDT) Message-ID: Date: Wed, 13 May 2026 20:53:06 +0800 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] cpufreq: pcc: fix use-after-free and double free in _OSC evaluation To: Hongyan Xu , rafael@kernel.org Cc: viresh.kumar@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, Slavin Liu <220245772@seu.edu.cn>, zhongqiu.han@oss.qualcomm.com References: <20260513120639.894-1-getshell@seu.edu.cn> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <20260513120639.894-1-getshell@seu.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: pjdTQ4TD23bfuGOYDwxa2igFGCGdwuOV X-Authority-Analysis: v=2.4 cv=Hu5G3UTS c=1 sm=1 tr=0 ts=6a047438 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=VwQbUJbxAAAA:8 a=pGLkceISAAAA:8 a=6qQVmtZs7bol9fj5NwoA:9 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDEzMyBTYWx0ZWRfX5REheRCSp3xE zVKu43R+euv1Db0Fj69nBZVMIiu2VpV55l/6uaFTEJAMGcxMydp8h9mjxIHJVnWCZX4D8RhoyNz q0o/83DGf3IbE+R5nR0HfehOCPR7bbfZw7kcDlf1SgXg118qAoL/Cqkxt8DzA3FGj57EzWXFPI2 ciog2DmVByijRyt3EXyhQlpMlxU13pDAc7uH9BX6IURtW43BoNciZXXs1r7HMuoJc3geSV1UxxE QQuidJ67UYb/3zzkqRoZNO6UWfyjbR5QOwqbeoxD26VpAIf7CMqFKY62eVYJwSrfn6eKpUeYmHF /GHtAQ6tOsBawpfFPOkW+/65XkhRpjzJLIxniyD5McCUsTSgCg+EcefHB3nnHT8xeR4I3jUFIS9 y1XfQ018XJyYL+HuhLo7eOrBYsZen0PvncO/Qu6odJl+agOt5blOSihekOb21uv5Y24jAZiEW4T 11MsmpU903/vq/EHAyQ== X-Proofpoint-ORIG-GUID: pjdTQ4TD23bfuGOYDwxa2igFGCGdwuOV 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-05-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130133 On 5/13/2026 8:06 PM, Hongyan Xu wrote: > pcc_cpufreq_do_osc() uses a two-phase _OSC evaluation and frees the > output buffer returned by the first acpi_evaluate_object() call before > reusing the same acpi_buffer in the second call. > > However, output.pointer and output.length are not reset after the > first kfree(). That can make the second acpi_evaluate_object() treat > the stale metadata as a caller-provided buffer and write into freed > memory. The shared out_free path can then free the same pointer again. > > Reset the output buffer state after the first kfree() so ACPICA > allocates a fresh buffer for the second _OSC evaluation. > > Fixes: 0f1d683fb35d ("[CPUFREQ] Processor Clocking Control interface driver") > Issue found using a prototype static analysis tool > and confirmed by code review. > > Signed-off-by: Hongyan Xu > Signed-off-by: Slavin Liu <220245772@seu.edu.cn> > --- > drivers/cpufreq/pcc-cpufreq.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c > index ac2e90a65f0c..a355ec4f3dd4 100644 > --- a/drivers/cpufreq/pcc-cpufreq.c > +++ b/drivers/cpufreq/pcc-cpufreq.c > @@ -352,6 +352,8 @@ static int __init pcc_cpufreq_do_osc(acpi_handle *handle) > } > > kfree(output.pointer); > + output.pointer = NULL; > + output.length = ACPI_ALLOCATE_BUFFER; Hi Hongyan, Slavin, Thanks for the patch and for looking into this issue. There is already a similar patch under discussion: v1: https://lore.kernel.org/all/20260415165139.14113-1-dbgh9129@gmail.com/ v2: https://lore.kernel.org/all/20260416144621.93964-1-dbgh9129@gmail.com/ You may want to review that thread and see if your findings or testing can be contributed there. > capabilities[0] = 0x0; > capabilities[1] = 0x1; > -- Thx and BRs, Zhongqiu Han