From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1489DC433C1 for ; Tue, 30 Mar 2021 03:04:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7956E61584 for ; Tue, 30 Mar 2021 03:04:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7956E61584 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Date:CC:To:From: Subject:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SsrOBYWXGVb1EbVOXt7S7dL7Dh76Nl0Flhv654IrksA=; b=icP6wU3L/dgxpuBMuq6mwPI4/ vza325qJ1ZTAHaGZL1m5NEHxh6WoQsHqQgeRhoSmjlfzKMU7sSgjgq6ZLHDSAaGQ3P7y1MwGp0I5Y +mlx9R+6nYtu4ls7UvmcnPR6kUDdlFLvqrTKExhzvL8GhzVOsjPKRXrtOBV6fjrYJ3B9u6HLmWCdy t/bEhfu0Mbx8Iy9F4R7XioC7Kdr8k/XLz87EDhMmVeMvWVnkgAW3R+m7SM2VAbE9csRRUTQJItplm pZu6iBUGObZwAW2jLltNMryxnIYiMKYS66IUQo+UW17qquAO+ywy7lCTiJBmSvSXttEaisM0aoOwp gKThxmdsQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lR4di-002Wik-Pi; Tue, 30 Mar 2021 03:01:58 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lR4dJ-002WhT-Nx; Tue, 30 Mar 2021 03:01:36 +0000 X-UUID: 1b190ff9d065450ea9655ba6a7dd464b-20210329 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=h3tgTgAhTPVHl6C7nGiDPVcZVqzWaFEKu+Mj0evMIr4=; b=LI7e3Glzwpjv1aUej04C4LHb49W1O+HP+7QCPeYeNiwA4nkulkaLUAjZKbYHa+kRIPbMAy1thXHAoqgRTqNU235yUxSLgW3TvMS5vlolspzNH3jHdEQ31HWUtfeX6ONqGonQuGvD1wl5dqC1buA0UCC7mYVMLyMBDi1Ta0S9fpk=; X-UUID: 1b190ff9d065450ea9655ba6a7dd464b-20210329 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 910363157; Mon, 29 Mar 2021 19:01:28 -0800 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 29 Mar 2021 19:51:25 -0700 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 30 Mar 2021 10:51:24 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 30 Mar 2021 10:51:24 +0800 Message-ID: <1617072684.13941.2.camel@mtksdccf07> Subject: Re: [PATCH v2] thermal: cpufreq_cooling: fix slab OOB issue From: Michael Kao To: Daniel Lezcano CC: Zhang Rui , , , , Mark Rutland , , brian-sy yang , , "Eduardo Valentin" , Rob Herring , , , Matthias Brugger , Date: Tue, 30 Mar 2021 10:51:24 +0800 In-Reply-To: <20201229050831.19493-1-michael.kao@mediatek.com> References: <20201229050831.19493-1-michael.kao@mediatek.com> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210330_040134_340937_06FF9745 X-CRM114-Status: GOOD ( 20.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dear Daniel, Kindly ping. Can this patch be merged? Or any comment? BR, Michael On Tue, 2020-12-29 at 13:08 +0800, Michael Kao wrote: > From: brian-sy yang > > 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 > --- > > Changes from v1: > - add fixes tag > - add reviewed-by > > drivers/thermal/cpufreq_cooling.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c > index cc2959f22f01..fb33b3480a8f 100644 > --- a/drivers/thermal/cpufreq_cooling.c > +++ b/drivers/thermal/cpufreq_cooling.c > @@ -123,7 +123,7 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev, > { > 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; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel