From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796220993; b=Z972d4W5bTUKjKKlM3wfQy5zlVgMXpdIKk7VriVLHAYhkKXILlen+UF7J0LOYB1OEEvn nUToYv9FiNO45GCaZzBC97uXTtEofk7wqYtGn7TF5aI1dzqx+IUC/TIhf81RCRGBewJpj SlLNMdTKRr2+ipU/hN1UOWCB05NNF+5y2hv3D4kuALF18pj9e7TJyngVQGLzLNfgWj9Yw bgtcS98cOy/FzlahderP3wD1PDH8AqWBMxAy9ojEPJH6TS6bxgPilcUNLcyXoxSidl9Lq kTe82jvfrCTe5AMBhgM9KqHxTaeJRWTAxG4kvsQv3x42nRmXJ0ktoOWSAamJ9r7uIZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796220993; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=0DRTzmmvyhTsifmd3yLLJI31Q17OkH1cuZRntHiVOFg=; b=a9UIPRb2Pzuf+FpOQl/NB5GCx8yR8YD79aTM8IVheqN3hcdkh+aFaVYjumGQK+CXyhYx CJgnLMCYNXktTT4G0SOIfyds9D6C2Iz0tzZPoaetv7se2Wy05VU/7lajY8hbTA8DjJTPm 87L/TVi8DaKXFvXJ/qHCZvGYKFoCg/0U2nwfmNSp4jZIw7bJ9jWHQlIaFlgcPrlQJq2+M 0M4m1zMJ/D3pEiAbt1sioISywXIMgaNp7DEVkUH2pxBsNnrOu7OfU8a1rqBFUq/eeL3Nj HKJerFwP/7ZTpdSr7ZUy0TM5Jm8HaRtIkyrIKxLlWixY3JJHxWXoLfKTXeBXOS+ekLg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="oJOx/uzi"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34053606A31A for ; Wed, 2 Dec 2026 14:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oJOx/uzi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37D4F1F000C1; Wed, 2 Dec 2026 14:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796220992; bh=0DRTzmmvyhTsifmd3yLLJI31Q17OkH1cuZRntHiVOFg=; h=Subject:To:Cc:From:Date; b=oJOx/uziz8oFNTF98O4HGLrIJHGQEup5gw+3HhMcaUCxFjq0Mt1hD6REpuCjCyXxz Fx+1A+/lUSPTmKZW49cpJDqWBhrIsv+cTdQoThZEhzohvMS33UzQEIapFjZab9kDN/ cZrpYYrtdAGVqhv6TLwdVie8w+2LrYomdbspgKjw= Subject: FAILED: patch "[PATCH] cpufreq: Skip inactive policies in cpufreq_driver_target()" failed to apply to 6.6-stable tree To: zhongqiu.han@oss.qualcomm.com,rafael.j.wysocki@intel.com,sashiko-bot@kernel.org,stable@vger.kernel.org Cc: From: Date: Wed, 02 Dec 2026 13:59:47 +0100 Message-ID: <2026120247-residency-drab-33a4@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x c5bdb87573726d3a10c58bb3ae09daf017be2297 # git commit -s git send-email --to '' --in-reply-to '2026120247-residency-drab-33a4@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From c5bdb87573726d3a10c58bb3ae09daf017be2297 Mon Sep 17 00:00:00 2001 From: Zhongqiu Han Date: Tue, 10 Nov 2026 21:58:14 +0800 Subject: [PATCH] cpufreq: Skip inactive policies in cpufreq_driver_target() A policy obtained with cpufreq_cpu_get() may become inactive before cpufreq_driver_target() acquires its rwsem, which may lead to a NULL pointer dereference: CPU X CPU Y (last CPU in policy) cpufreq_cpu_get() cpufreq_offline() __cpufreq_offline() ->exit() /* frees freq_table */ policy->freq_table = NULL cpufreq_driver_target() __cpufreq_driver_target() __target_index() policy->freq_table[index] /* NULL dereference */ Before commit 2372784542cb ("cpufreq: Drop 'freq_table' argument of __target_index()"), __cpufreq_driver_target() returned an error if policy->freq_table was NULL. Since the offline path clears it under the policy rwsem, which cpufreq_driver_target() also holds, that check was sufficient to prevent the crash. The race has been reachable in-tree since commit c210063b40ac ("cpufreq: mediatek: Add opp notification support"), which added the first caller of cpufreq_driver_target() that can run concurrently with CPU offline. Address this by making cpufreq_driver_target() return -EBUSY if the policy is inactive after acquiring its rwsem, in analogy with the checks in cpufreq_get(), refresh_frequency_limits() and the sysfs show() and store() callbacks. Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20261104153042.3987338-1-zhongqiu.han%40oss.qualcomm.com Fixes: 2372784542cb ("cpufreq: Drop 'freq_table' argument of __target_index()") Fixes: c210063b40ac ("cpufreq: mediatek: Add opp notification support") Cc: 5.19+ # v5.19+ Signed-off-by: Zhongqiu Han Link: https://patch.msgid.link/20261110135814.621355-1-zhongqiu.han@oss.qualcomm.com Signed-off-by: Rafael J. Wysocki diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 24319b214d7b..4332cb114070 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2452,6 +2452,14 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, { guard(cpufreq_policy_write)(policy); + /* + * The last CPU in the policy may have gone offline after the caller + * obtained it, in which case the policy is inactive and must not be + * used for changing the frequency. + */ + if (unlikely(policy_is_inactive(policy))) + return -EBUSY; + return __cpufreq_driver_target(policy, target_freq, relation); } EXPORT_SYMBOL_GPL(cpufreq_driver_target);