Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2490294pxj; Mon, 10 May 2021 04:21:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypf1GAfuqLsdrHUTD5iZbNNzvPc65Ksx7YF80bFXDpoe4z/riTbF4rfnaxLCheu6BSdRwa X-Received: by 2002:aa7:d4d9:: with SMTP id t25mr20966003edr.377.1620645708270; Mon, 10 May 2021 04:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645708; cv=none; d=google.com; s=arc-20160816; b=YktmG8s/0B26+fqphBI+Snn7bRjDrTRRAPWsMl8jfT4T8kGruU9Ien4ZcpWJ9vfPMJ txkmiN8p5UNWzASuKw0pE6fP/di2Kv/gwao7LRJ2V5W5AXjAOEUikLjIt5q/23BY6rvs nl9wFpDtygnOGZMRmt5vZboTu2lU442ODGXyY2K7YjEmQ/eBUp4rGQ85IJ8Wyjb6XSUq okEdrW0MVHfVuFuCPVHNjpCXZ3W/TKBph9vNqf8con+fWJZvluq9BeY4mrOdS8iPZLVI uZObpgArEU08GZThI8cnVWoHn9jTBCOoK614D5AohVAPouCnhIJAUiW2SdCcR6XGvvV5 lj3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zB3intllfWX2dTLFoD3QaMyT2UaK6KKMLS5CG34IPYU=; b=tUAghrbINBP3cyzKbxkqGLwXqkMQSha2elYwGDgER2xR8kMUnjB0rTlaqCc9i1ovcf EzrGRO+g+9MwcWCrN+O3Pzioj23X/X+LMqGmRx0Hk9pdjyOPMkXI1vUAfWCdrn+WQfVi lqGkONnQwQ8VffTBs7EdfpJSn5MGoLn+57iNDOUkVojziZlpOFtWjstrq8Wf/17Q5a+i ysiZq2iKkJou2laycqciUtmp1oTCsvOJZzauCniz/S9HknSkqqdMLJh28pOb/fNSiNMd dyOT9BQiT9sMPBhBadmllc0WBPGXOo2ZXQBVs4qfZge46dSu/dOk4t4WEk7at9N1qghq oPUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JUWPC9lA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s27si14131756edy.9.2021.05.10.04.21.24; Mon, 10 May 2021 04:21:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JUWPC9lA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235453AbhEJLTX (ORCPT + 99 others); Mon, 10 May 2021 07:19:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:52158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234001AbhEJKzo (ORCPT ); Mon, 10 May 2021 06:55:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78A216192C; Mon, 10 May 2021 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643397; bh=ZhuCGbi99ueUfGcvZCo8L1Za/9MQihnuSfx3f9Jvur4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JUWPC9lAKCj4iBxyM51+ACz1EjGN2uUndW5z06p0YXY5tSf+lKHuWhi45XdG98j2j i1xGo+MzRQIYWYzmjHHOJXZ2J0rXdcAWM4ay2EvV+ivJaBN8gu3+CYX1WEhYfLzO0D SFjW8NsKynzCWKYTN9rbDJ4h+kbsZDzT/E58N938= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, brian-sy yang , Michael Kao , Lukasz Luba , Daniel Lezcano Subject: [PATCH 5.10 298/299] thermal/drivers/cpufreq_cooling: Fix slab OOB issue Date: Mon, 10 May 2021 12:21:35 +0200 Message-Id: <20210510102014.767545140@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: brian-sy yang commit 34ab17cc6c2c1ac93d7e5d53bb972df9a968f085 upstream. Slab OOB issue is scanned by KASAN in cpu_power_to_freq(). If power is limited below the power of OPP0 in EM table, it will cause slab out-of-bound issue with negative array index. Return the lowest frequency if limited power cannot found a suitable OPP in EM table to fix this issue. Backtrace: [] die+0x104/0x5ac [] bug_handler+0x64/0xd0 [] brk_handler+0x160/0x258 [] do_debug_exception+0x248/0x3f0 [] el1_dbg+0x14/0xbc [] __kasan_report+0x1dc/0x1e0 [] kasan_report+0x10/0x20 [] __asan_report_load8_noabort+0x18/0x28 [] cpufreq_power2state+0x180/0x43c [] power_actor_set_power+0x114/0x1d4 [] allocate_power+0xaec/0xde0 [] power_allocator_throttle+0x3ec/0x5a4 [] handle_thermal_trip+0x160/0x294 [] thermal_zone_device_check+0xe4/0x154 [] process_one_work+0x5e4/0xe28 [] worker_thread+0xa4c/0xfac [] kthread+0x33c/0x358 [] ret_from_fork+0xc/0x18 Fixes: 371a3bc79c11b ("thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power") Signed-off-by: brian-sy yang Signed-off-by: Michael Kao Reviewed-by: Lukasz Luba Cc: stable@vger.kernel.org #v5.7 Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20201229050831.19493-1-michael.kao@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/cpufreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -123,7 +123,7 @@ static u32 cpu_power_to_freq(struct cpuf { int i; - for (i = cpufreq_cdev->max_level; i >= 0; i--) { + for (i = cpufreq_cdev->max_level; i > 0; i--) { if (power >= cpufreq_cdev->em->table[i].power) break; }