Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1258474ybt; Thu, 9 Jul 2020 02:37:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYdUZXoxBdc4Fvot5kwcQkZGXCaWcLO/1N+C5qWVoLD/UpGu9XOU2hx506wPpq6gTwgsUE X-Received: by 2002:a50:dacf:: with SMTP id s15mr74270358edj.136.1594287419999; Thu, 09 Jul 2020 02:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594287419; cv=none; d=google.com; s=arc-20160816; b=NTB2+Q+1/+OU528IeJoURLSaQpvCBvy9cCwdSbH163SMeaIuPypZn+qymtQqD89jNh oLBSRLYD1i3WDVwZZjE5SDXzgNQoZZhJe/JGySipyPmQio74dKrTVV+VxLaVQ3ECF4/b pEYGU9UyBPxJEnOYTBXRhoO5Xt+3BKNV3rMR7dAioXmIXP/fWqnZOKJcIaH82svy0I6M y+7OZFG8aaqlgLnXP5HcGd+4f1X9qilbXa7YJsksu7+i3qqbCcsQ8bNZKJ6F13kH+NQO E9bhRuhx0G96YA1mIdMdQqs5GXvlZKVaFJj8ENInDK8C7lOGAMqnxzY69skZ3IbXK8tZ M3Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eygZbTdlFFJ71jCLfCgJ+FFK+a7qNbIVolSlOz1F8GM=; b=FtFamez4fAvbMgIE1FtZRtwt9iedzjr466YvOuUNAJO3kpGX0zuIcRdr+RXhAJ9YN/ rXxVOVxLdBFfRKMIVOGOEi9dviYIljnVC6sthSHrKgAKiT0F4TShQavrGvfPZnveL2GW JUaZpsjBKlILDcJW2+yRZil+GXdi05SvvoCRBhfaNw00dUjOA+9yB/MzIXttaT5OgUAb 0FLF0R2VXKRb/rPt82Aq67JTkdOjyZbFpEllalCt4p+ACcKPYWAaZAjtx+vBwK+EQEDW mAyvYiZ45vCKkqOSHtCEX7dIGGy1eNWtITwi/RjxgX1QNdWFAzyuBe0VIHyk72zJBJe5 j8lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=WiAQr+CW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si1814199edq.569.2020.07.09.02.36.35; Thu, 09 Jul 2020 02:36:59 -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=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=WiAQr+CW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726313AbgGIJgb (ORCPT + 99 others); Thu, 9 Jul 2020 05:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgGIJga (ORCPT ); Thu, 9 Jul 2020 05:36:30 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70DB9C061A0B for ; Thu, 9 Jul 2020 02:36:30 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id n2so1286274edr.5 for ; Thu, 09 Jul 2020 02:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eygZbTdlFFJ71jCLfCgJ+FFK+a7qNbIVolSlOz1F8GM=; b=WiAQr+CWI7AR7BcmGBUGWjPFNscJqLLdx51nc0bGW2Zjlly/I7bVYJKiNQ5FIK42gQ ztKZ39/kOKalWkN6N32n9+XcKyY2/UZpc0fDuRm0PCCb/Qq39LkHNF83Q1ad+4KSpgiV LTgltQyaJIT9ryfmqIqBqoTOuXUkDuBlRZqCb4KIGN39bAlxO6AKe1pry724NX4dMW6E Thw3IS52wTv26/tNSpIZ2OhuwOSW2kWMybtNxYwUWn+l1g1ADjvnStvay3TcV2Q2XIJY genZjiQMJwXx7fw8+JQ5Xk/LKkC57jVNSW8/UQ/LfFzmgNF9SBYB6Z7JaKK9wrAlePEW xRXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eygZbTdlFFJ71jCLfCgJ+FFK+a7qNbIVolSlOz1F8GM=; b=Igsp3P4Cy2Y0XQ0kTHX67j1HpmHS1u4SjhHqPqkQbkD1no4eRT6vLp4KwRWwGv7jq1 Ggg6NzEetrPMN4MA5Ybvaxoj0toRBYMXt8K0qkwQCdMAjjArhsIdpnJBDivNmzTLQTRH 9RmjoikLrS4+MOBUZk1NGATcPMYJnTpStamlt1hAJC+KKy/1djtj9frEvXD8PVHouiOc EmfZQ8Xno+YXTjJ6NKF3YEntlbcE3aWtQ5AOY70sZ25BH7AY127P1GlVR+ZMlnKBSf9R IFIR7SaDn1qU+TdZRwGm9jgIuWEnVM8oTUDunS9VtJbP4pcyM/zlsaEocEXJjMil82Vk Y/qg== X-Gm-Message-State: AOAM530B9xlqDOntP1JXuMgUpKrS1oxLYU45aC6uVzfpw5HUTnbF8iOg vUO1W/+95sW5UmkiEHNCc3VDqsiLCR4G8sCktIDs8A== X-Received: by 2002:a05:6402:14c1:: with SMTP id f1mr73921180edx.342.1594287389229; Thu, 09 Jul 2020 02:36:29 -0700 (PDT) MIME-Version: 1.0 References: <20200708134613.131555-1-bsz@semihalf.com> In-Reply-To: <20200708134613.131555-1-bsz@semihalf.com> From: Bartosz Szczepanek Date: Thu, 9 Jul 2020 11:36:18 +0200 Message-ID: Subject: Re: [PATCH] thermal/int340x_thermal: Prevent page fault on .set_mode() op To: Matthew Garrett , Zhang Rui , Pandruvada Srinivas , linux-pm@vger.kernel.org, Linux Kernel Mailing List Cc: Daniel Lezcano , Amit Kucheria , Radoslaw Biernacki , Alex Levin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rui, Matthew, I think this regression should be corrected still in the 5.8 release cycle. It may cause kernel panic if .set_mode() is called before current_uuid_store(), and from what I see both operations can be triggered from sysfs. What I'm not 100% sure about is if we should apply the above fix, or rather revert the driver to its default behaviour of using uuid=0 if it wasn't set from userspace (this is how it was before Matthew's commit). What do you think? Best regards, Bartosz On Wed, Jul 8, 2020 at 3:46 PM Bartosz Szczepanek wrote: > > Starting from commit "thermal/int340x_thermal: Don't require IDSP to > exist", priv->current_uuid_index is initialized to -1. This value may > be passed to int3400_thermal_run_osc() from int3400_thermal_set_mode, > contributing to page fault when accessing int3400_thermal_uuids array > at index -1. > > This commit adds a check on uuid value to int3400_thermal_run_osc. > > Signed-off-by: Bartosz Szczepanek > --- > drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > index 0b3a62655843..12448ccd27f1 100644 > --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > @@ -216,11 +216,16 @@ static int int3400_thermal_run_osc(acpi_handle handle, > acpi_status status; > int result = 0; > struct acpi_osc_context context = { > - .uuid_str = int3400_thermal_uuids[uuid], > + .uuid_str = NULL, > .rev = 1, > .cap.length = 8, > }; > > + if (uuid < 0 || uuid >= INT3400_THERMAL_MAXIMUM_UUID) > + return -EINVAL; > + > + context.uuid_str = int3400_thermal_uuids[uuid]; > + > buf[OSC_QUERY_DWORD] = 0; > buf[OSC_SUPPORT_DWORD] = enable; > > -- > 2.17.1 >