Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp574756ybt; Wed, 8 Jul 2020 06:50:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqnorGmf3cnvOor2wmPA+mS2SPvud4En5S5fx2GqhDlAmO5jNFLzz+QZeDNromOE1fu2FB X-Received: by 2002:a17:906:46cd:: with SMTP id k13mr50773264ejs.312.1594216230338; Wed, 08 Jul 2020 06:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594216230; cv=none; d=google.com; s=arc-20160816; b=O46J0D4f7h/wKwzeffAu0SIWWoV9dfDJTOnAwrqS5FsSMC4dV3tqxQZKE52OPxaXaa 15hVK3/HPvUbH3cossrF+y35IWmc+FedebZ8cR3pb35I5YcQq3z4ij5ra0mTlLCze+CF IAQalcC9wDduTYD5iUrF/4lWq2a+owm46jCJsNy+qZU7OfhqcMtYezC+s6h6zRLQlsJW S9+NXjno8k/7PqzLXc4EpwiwJu60W3kXxowCCizyPxv7feJYEHJa7nAYQ5Mvx2xlJAuT z44f0SZ8G9pmBhumI5pWwTPsGNYNsyExjXS3z/buJeExixDhJD6xO+dLQtLknAhvixkB zcDA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=yokX6/GqNfCJVra9vogfMzW7oEaeEABdbokc5LYRIwI=; b=zc6PHyQRMktkqQcbVpY72buKOlW2DG2TXm4O30NHUx1N1+3f0pSGmzVysELUmGZIP1 mOLsirasDEaDmSobCnDDkJ2ZGgtQywiTW6QHCk095j2gAW1iGMKMa4mCWQOpqqUOwxDc JsjDu0qb99kq/PsbE0MvrkrYQPXLoSP+3qt7mn/D0F992sHdEQtLQVVopOC3bVeSpYrX EPLrGqKtX6msbQqSiUB3+HSxqDFT5yI/eKsfmPeL4mbAwRiFlJZCIJUdEffpkutQdysk ADWYNcac7tr9RRO/QdQEDpkCDpEeBgacUBMCKzPNYzA07kOkz4CxLO1W6heG3joLazzw nQmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=RlNUnYwY; 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 t27si12133290eji.205.2020.07.08.06.50.06; Wed, 08 Jul 2020 06:50:30 -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=RlNUnYwY; 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 S1729411AbgGHNq0 (ORCPT + 99 others); Wed, 8 Jul 2020 09:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729288AbgGHNqZ (ORCPT ); Wed, 8 Jul 2020 09:46:25 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A7F8C08C5CE for ; Wed, 8 Jul 2020 06:46:25 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id y18so26910017lfh.11 for ; Wed, 08 Jul 2020 06:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yokX6/GqNfCJVra9vogfMzW7oEaeEABdbokc5LYRIwI=; b=RlNUnYwYCZObU1qK4ULsAxSxIXkTG7mMUyf77VNDSVZC4Xi6DQ4dCOW2m4BXHu+HCL nwfiJhi9CyF7hG35p4U+XBd8E71/Fl/59SCIYtqWsNfPTf5d1rHJSZxd/SYHEHZ8XxPY 2rDi6EuVbK0iMGwhD2fvX8QpM5iO9TsO6sUDMGQq0FXnC0MhfaW8NgV+kEABTllp3BKf 4n4ZUFiG1Zfj2vk7+ooDH9kOeaugMGbqOzT1unF1S9ydZ/6CWuWeUcbE8l59bZxQiCuR FuMJD9nTgSZ7bN2O5sU1ctPUWsjcmKeDp43MghNoo8oKtgoFYt6OE1wcGaNFhau9/FcW RJUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yokX6/GqNfCJVra9vogfMzW7oEaeEABdbokc5LYRIwI=; b=oxyBoXctaq79c4yQjC3iS+RQndtfWejJjGtBnA6pDaoLHgnjupC+hyegcLLWkYDiTi mtSmrYUnIipuA0s6o8tBXckzaDnR3DoCb+G4drpBGjvvcs2MekCibvMFiZrpLSiFarDT 3fWfo+0FFfj6LaJwCyU9GIrZHCa0sojXrUQnPHOaVRV9EZQ+yW3ngfZSML8/tdh5RAm2 RBjDj4dhy56jrtaLQL2nTTIgTSoeEtlQ0fyhjodc+aGXdURg5biLWFjfn/N1YJmcAHVe hJT6mB3EDqTbHUkb7O7JFLOx5Dl8+VBqIqezAjthTOZMR+MbFT3fXY4Z0I6wE0xysPMv BnOA== X-Gm-Message-State: AOAM531og+9fnURR4wwcb7R2WpHuOGYowJpxJDOOHnpH0S3h0DRZXMvY pFXz3TXhgoRCmP+7wFB6oc4XYg== X-Received: by 2002:ac2:47e7:: with SMTP id b7mr36026094lfp.68.1594215983911; Wed, 08 Jul 2020 06:46:23 -0700 (PDT) Received: from fedora.toya.net.pl (staticline-31-182-130-176.toya.net.pl. [31.182.130.176]) by smtp.gmail.com with ESMTPSA id i22sm924902ljb.19.2020.07.08.06.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 06:46:23 -0700 (PDT) From: Bartosz Szczepanek To: Matthew Garrett , Zhang Rui , Pandruvada Srinivas , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Lezcano , Amit Kucheria , Radoslaw Biernacki , Alex Levin , Bartosz Szczepanek Subject: [PATCH] thermal/int340x_thermal: Prevent page fault on .set_mode() op Date: Wed, 8 Jul 2020 15:46:13 +0200 Message-Id: <20200708134613.131555-1-bsz@semihalf.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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