Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2062387ybb; Thu, 2 Apr 2020 12:19:52 -0700 (PDT) X-Google-Smtp-Source: APiQypLxRcseKHo2oSl0xUwIDYmddiblRToYmweaYdiLo/wvcMBsK8iF4PGkt4K82t0siJQQU84R X-Received: by 2002:a4a:7555:: with SMTP id g21mr4078990oof.46.1585855192594; Thu, 02 Apr 2020 12:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585855192; cv=none; d=google.com; s=arc-20160816; b=IPvyQsuVNO5dFRZP3yftAaKedhvNUZOficJ3ooih5hcFojFBCEfqyi5UYWthYWfa/x /3GsYtrUeqlc4g4SDTeYjcw1WBKtS+jblof/2X7XTEM5niiMmhOfyBsEg8hwvvOfnin4 6gzE6DnC4GSEmHhe7TKmlHZeJJmQC+FCDrFN9hoBejl4ZfDjkTX8jKGNq6gUhIcaLiAJ CSpazSO5WP2oYD9eUsX52nP4NepHZyHZt6GdKDs9Iu3ySTP8Z55Db2OUfUCQ/Ckh1bNK ku0NmJU259QGCVSp8RZAyELfZNKPhcMGplOgJUuQ9Lz8QihuIJF53eGVy8Er6I1RvgXm SLXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NSqtl7KQxoiSB7AwV07HkeMnVk1EmUahkKwJtCcJmds=; b=soDNUmV4RU2VVQZUpQt7E9ArH9/3qRLCq07Z+nBVRNMas2Z0uo14gqf6zpGmyCXBwC ta2F6RKPuF7P6HG29dD0EpxV7lnsxHPiy1HfnvTdfj49SH4hphUIBVPTYh1FS/VLxQfn TTZhjZ7b3vq8v/2bNX0XoiyKcZbSTtxZFnSs6EsNcDIQkiNm/wygDU6gjqI9h0YXKXaq 7bZ5BeSeOg1WLe01mZmmNLVtrIQaLDJun/OlFJNB1JrIzBGzPhylh3a9Qg78K7eAzaLT 2V83aBp1nZtVxxBxC1bg+dEMcvPqabMVMRC6p7D9i7m1cbKdL8L0ATssAogIJXqfEgnT 5RNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c67si2822017oif.5.2020.04.02.12.19.40; Thu, 02 Apr 2020 12:19:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389453AbgDBSHI (ORCPT + 99 others); Thu, 2 Apr 2020 14:07:08 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:49725 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728225AbgDBSHH (ORCPT ); Thu, 2 Apr 2020 14:07:07 -0400 Received: from 185.80.35.16 (185.80.35.16) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.341) id 754a245cf567c245; Thu, 2 Apr 2020 20:07:06 +0200 From: "Rafael J. Wysocki" To: Zhang Rui Cc: Takashi Iwai , "linux-acpi@vger.kernel.org" , Len Brown , "linux-kernel@vger.kernel.org" Subject: Re: OOB access on ACPI processor thermal device via sysfs write Date: Thu, 02 Apr 2020 20:07:05 +0200 Message-ID: <1971976.2hYWdNQAa4@kreacher> In-Reply-To: <0926f44775e91145a83c9eb88a468c64261af20d.camel@intel.com> References: <0926f44775e91145a83c9eb88a468c64261af20d.camel@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, April 2, 2020 12:03:30 PM CEST Zhang Rui wrote: > On Thu, 2020-04-02 at 11:03 +0200, Takashi Iwai wrote: > > On Thu, 02 Apr 2020 09:47:50 +0200, > > Zhang, Rui wrote: > > > > > > CC Viresh. > > > > > > Yes, I've received it. > > > > > > To me, there is not a hard rule that the cooling device max_state > > > must be static. > > > We should be able to detect the max_state change and reset the > > > stats table when necessary. > > > > > > I just finished a prototype patch to do so, and will paste it > > > later. > > > > Great, that sounds like a feasible option, indeed. > > > > > Please try the patch below and see if the problem goes away or not. > > From 7b429674a0e1a6226734c8919b876bb57d946b1d Mon Sep 17 00:00:00 2001 > From: Zhang Rui > Date: Thu, 2 Apr 2020 11:18:44 +0800 > Subject: [RFC PATCH] thermal: update thermal stats table when max cooling > state changed > > The maximum cooling state of a cooling device may be changed at > runtime. Thus the statistics table must be updated to handle the real > maximum cooling states supported. > > This fixes an OOB issue when updating the statistics of the processor > cooling device, because it only supports 1 cooling state before cpufreq > driver loaded. It might also be addressed by adding a ->get_state_count() callback to struct thermal_cooling_device_ops (and fall back to ->get_max_state() if that is NULL) and use that for the stats allocation. If the new callback always returns CPUFREQ_THERMAL_MAX_STEP, the size of the stats table will be sufficient in all cases and acpi_processor_notifier() can update it as needed.