From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 700BE248F64 for ; Thu, 16 Apr 2026 06:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776319471; cv=none; b=BxUHTs50rOq12PzhcXZCv0FuXM3iK9TgjY4Ev96DM8ztFrm6IZEeiap4kvWIi2PuvPZmNEJqyFOcnqVZ9zroN/bA5X1yI+uIpxaBfAG2u9npRyzf8wvmL/L58hu7MpB4O492iIZHDjsNVx6YUGsPt3Y9lSqe39W2vLdntowfC1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776319471; c=relaxed/simple; bh=1ZVZAFCFHtfrGNr9S1XLBBMCeJj4TmZiFJFCxJ2Pi5w=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YbAi+cDLt/4NHvC8QB08ClmbO09Jqwrea47F5WtQUW/ufbk2evSug+ks0osZy8DxRi0EXDWbQiB3cVRR9Y5K7s5N+IKX1Ll8GH2fsjm6BzZzy6D+1i68PoLASfYbyQaQKEX+hbhn73MZ79JAu+yK7lhhGsHEoSaYNP2JxlyF8oI= 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=a7emnMXB; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=iBUipAl8; arc=none smtp.client-ip=205.220.168.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="a7emnMXB"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="iBUipAl8" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63G0gBAK3733611 for ; Thu, 16 Apr 2026 06:04:30 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= iQ5icNOmFIieJj0wO9ogPa0sSKFt+wk299/xfGEJ5RI=; b=a7emnMXB7wDRR9h+ iPhfy/2K3fT3sotUqANJGRp/zS0vsmT0M27rC+bunxFFJaMRgVXe9NkUGHKhzUNp vTnUzwGCW+UP8SY6WwfRJowni07Xes6Jfz8oTVWcO19HV/Vg/y1dsuk4HUUga3Ox BYt2O46898aeKDY9RwIDxfj4G57p0T9fGd027jNTq/RX3RWufXl9Kljq8e++Pmjn rS5j8/XqBzsJsByp4DP4xRwbLyj9JDl4DLxsJ9oloH2eqbbCxhfKdWoBb69ZDpA9 QeqLFN2/AVc4uKCkHJLE0O2H9V7ksBdXUpc72RIIITsl5lG+opIc7PCWMGeuRmsr OKJ3Hw== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4djcqwjmvt-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 16 Apr 2026 06:04:29 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-b6097ca315bso12335527a12.3 for ; Wed, 15 Apr 2026 23:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776319469; x=1776924269; 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=iQ5icNOmFIieJj0wO9ogPa0sSKFt+wk299/xfGEJ5RI=; b=iBUipAl859zKTKgt6EMKl8xtFinunZdwEdw6YGcwAefFU6MCi4xbfiG7pszaNfrr7d fPkgYssiv8oOypldb7+65zFVhCeVyyr0xskZQ0Sl4CMXFhWy+dw29Uf4KIcjeGRDXvl8 CBI8XdSi21dZdZuh2ssjxzdu2htRwt0VPbpvtkb2+MbPT/j/zJltRLPaTQhuxuMnFU8n yeKb3vSVRPw8lSg60Gi7CWVNPKpJOXMXH4+uHI6L2bJXgylfCR7ObbgUHf8aS0wVdeW6 NlQKZYVNbrrqY/1Bh1HoYhuumkLzSroNH1sH+FCOT1wZ25I8zMDihfVVIGDLN0Ilf9Lb o8YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776319469; x=1776924269; 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=iQ5icNOmFIieJj0wO9ogPa0sSKFt+wk299/xfGEJ5RI=; b=oDkhylpOM2j0E3k+wsUeNUaB5V3yt8+8VH2MS6/cHuhtWG7IALngZyhDLJlJ19f3uZ uGmN9w8Y+G4U9BWe1OwuWdh2+vZRJR5Icx69zXW5C2dJeMZKyZBt8+ij52kkvpYgxRMk idBShh+gmejmrnjj80IAAHTNHDqupdfid6fQNR/20EB703ojYViNdoLw6W0/MCa7FcR7 UO2I+X/qipadOI9t2vVK5KdPpdn3DDTpyxGGcwHJU57ys+tOPm8jugv6a37164AOMmpE h/AMwa/L2GpOCtd3ww0MHVW4LirC/8yk0TrN9udDeIM2LzgmPzN2D/8/DhzmG1c1YiAk o89Q== X-Forwarded-Encrypted: i=1; AFNElJ9F2YY894ZUNJndd6jLBrAKwTCWRqkXDidGOyAgkgmApiFGTFvGodVjodeOhavWbDB2j9KXmheCMDsJ4pM=@vger.kernel.org X-Gm-Message-State: AOJu0Yzj9SzC1nW3IuCStVwkb2QLh48VA81LWViEowNbax2scmdy/EeC GRvtK+qPjZqoMN/9C3jNkS7bLLMOucxyOGccuKNq3rSPNvX+3n14zK0uSdHbg1vqyN2laLcpVfa RWmiqYGi9iDhHcDEVPNnDAsA33XkoB8qh7hcACku3UWgBWu+kBkBQS2jnb/UKq0fgamTL/Ge6O4 c= X-Gm-Gg: AeBDies6qnotXaRkv7rfwHUpLc5KDrEfS+9iDSlRTAX4TbVM70RVZU9N9VBu+MFPTF1 Jgzlzfmigwgrr9SAqcf3ewISuMojIoJpZUurPkLOJj7EhZ3TvSKoNSQPfJr9vUU0HJPSRoRL525 b69vUZ63Ob5gIU4iQQXVvCzP58jiKCM8GvoUBxxfU2PrTmz7z7pIIZOkHdPmtoSiYxloYzist59 sGI4ukpThT6CnA1k5h/uHWQotETsUHS7AahoTrSeI9pKcX2kbKaTt8vqbkD4x6anYIkmDo3z1Yq jBoyqcT0PE7/zY+U3yfNE8k2oB1duX2M1ny8sOBWT7TkTUgteD82K2oBScbyz1PL/9PF1rP+lXi O1DlMzxFIJ2wcv4QFNO3F/WAN8Q+OGjKaSeOWpM5aCNcRlCLsRQWAy9RdsDwNuAmNZa4plenw8I 6398ODxJ9Dk83eE8znh+VdJ5ims6sb X-Received: by 2002:a05:6a20:1592:b0:39b:e789:7d20 with SMTP id adf61e73a8af0-39fe3ff14c3mr27343382637.44.1776319468873; Wed, 15 Apr 2026 23:04:28 -0700 (PDT) X-Received: by 2002:a05:6a20:1592:b0:39b:e789:7d20 with SMTP id adf61e73a8af0-39fe3ff14c3mr27343348637.44.1776319468356; Wed, 15 Apr 2026 23:04:28 -0700 (PDT) Received: from [10.133.33.176] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c79581cb03csm3668963a12.27.2026.04.15.23.04.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Apr 2026 23:04:28 -0700 (PDT) Message-ID: <952b0192-4ba8-45ae-a71a-79854d558702@oss.qualcomm.com> Date: Thu, 16 Apr 2026 14:04:23 +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 v1] cpufreq: pcc: fix use-after-free and double free in _OSC evaluation To: Yuho Choi , "Rafael J . Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com References: <20260415165139.14113-1-dbgh9129@gmail.com> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <20260415165139.14113-1-dbgh9129@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: -7D2Tp0kbyHh3IVQv6WRySN7OYxwptFY X-Proofpoint-GUID: -7D2Tp0kbyHh3IVQv6WRySN7OYxwptFY X-Authority-Analysis: v=2.4 cv=XOIAjwhE c=1 sm=1 tr=0 ts=69e07bed cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=c92rfblmAAAA:8 a=pGLkceISAAAA:8 a=OE-sKc923LUAuokmw04A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE2MDA1NSBTYWx0ZWRfX3tiudrdC+USZ A3eNgksvx96wtHkj/awb/BLKzusb91NlDNB0taL1So8o6lbssE1znixwxMF6bql9y59D96Vbfb9 G+92aROB1O4z+G79qU8I8WVEkaP6rld0mWz0/O9h9OKDkgaUW53raVkBlPBh/CZweXojeBICg2y rDAf3dkyPdw6763OHGg/7FYxpz++bSlnVLabyUSOLUb/y6OYFaoqOeGhKiWxZgSlHYbTRYOF0zK rsuQKO+4qD6HGRXTs7jNndj8McKcXDYR9IHMJLJUK5c7nVMf0WdxZtoGMaZswBQKnVwIHxrIPUU BOCzIr40mvWFr0876Xtk3HQrirOvWLL3Omfj2E2zdwCxCan739q6arnhBKT+lNejuhen4Y+6Hgs H5MNAgBarRg5p2lb0Bi9GDixd2LBDcPD5fs/E7aN5CGMp7mrJ7FZxQbv9Rsm7/WzBwSE2DBxC5x xm6Nwl9YkDfAcWWG1ng== 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-16_01,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604160055 On 4/16/2026 12:51 AM, Yuho Choi wrote: > pcc_cpufreq_do_osc() evaluates _OSC twice with the same output buffer. > The first acpi_evaluate_object() allocates the buffer because output is > initialized with ACPI_ALLOCATE_BUFFER. Freeing output.pointer before the > second evaluation leaves output.length stale, so the next call treats > output as a caller-supplied buffer and performs a use-after-free write > into the freed memory. The final cleanup path then frees the same > pointer again, causing a double free. > > Keep the first _OSC result alive until the shared cleanup path and route > the early error exits through out_free. This avoids both the use-after- > free on the second evaluation and the final double free. > > Fixes: 0f1d683fb35d ("[CPUFREQ] Processor Clocking Control interface driver") > Signed-off-by: Yuho Choi > --- > drivers/cpufreq/pcc-cpufreq.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c > index ac2e90a65f0c4..165826b5d6844 100644 > --- a/drivers/cpufreq/pcc-cpufreq.c > +++ b/drivers/cpufreq/pcc-cpufreq.c > @@ -23,6 +23,7 @@ > * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > */ Hi Yuho Choi, Thanks for the patch. > > +#include "acpi/actypes.h" 1.I don't see why this header is needed for this change. Even if it is, it’s already included by , right? > #include > #include > #include > @@ -351,16 +352,19 @@ static int __init pcc_cpufreq_do_osc(acpi_handle *handle) > goto out_free; > } > > - kfree(output.pointer); 2.Would it be cleaner to reset the pointer and output.length, and let acpi_evaluate_object() reallocate the buffer? For example: kfree(output.pointer); + output.pointer = NULL; + output.length = ACPI_ALLOCATE_BUFFER; 3.The sashiko.dev pointed out a few pre-existing boundary checking issues that are outside the scope of this patch. https://sashiko.dev/#/patchset/20260415165139.14113-1-dbgh9129%40gmail.com > capabilities[0] = 0x0; > capabilities[1] = 0x1; > > status = acpi_evaluate_object(*handle, "_OSC", &input, &output); > - if (ACPI_FAILURE(status)) > - return -ENODEV; > + if (ACPI_FAILURE(status)) { > + ret = -ENODEV; > + goto out_free; > + } > > - if (!output.length) > - return -ENODEV; > + if (!output.length) { > + ret = -ENODEV; > + goto out_free; > + } > > out_obj = output.pointer; > if (out_obj->type != ACPI_TYPE_BUFFER) { -- Thx and BRs, Zhongqiu Han