Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1834808imm; Mon, 3 Sep 2018 10:38:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbWw4B7symwmJVsgapoOz4+4i/spgiQ8MLpLOmKtLIJrZaTz/rZHYZA+lXwlltEf13XqtVH X-Received: by 2002:a62:63c2:: with SMTP id x185-v6mr30555211pfb.13.1535996330120; Mon, 03 Sep 2018 10:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535996330; cv=none; d=google.com; s=arc-20160816; b=TDqKVZ8np8Ak6/D3EVSsN0seA+YbYcM2FjtsELMFq3/lSFJtGLRDLpNOr74Ayz6qql 8Y1298P4Dh/WQY1xZLmH/+IC+r5QYdNX5ytSZ6g6Bkq2OhSadvK99LC8yPzsKdsV0KZ1 YtuXoyOSqpqxxahOwBFJDKhRoQ2ln/1wHh2E03g44Pf8gDuRVILeGHyshLmu39JaDN9e oUHwMImndkFjr/Ad2a8/Mz76OHXnnQXSrRIw+NUlzl8j3XC44Jj4SLiB6jbp5RcUNmca V15/tO3oh9ul7dCHkk7EQDHgSp8cIWFgSvH41756hrDw3s8At313GCPQfwMQW6q3n24V gK3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=khvv6MY5HJTzls68xLFUbx/6Gexbi3nFRIL2LDkjFVA=; b=OvrLWEA0jBXHVP875+MNu2e4qyC2I8xeLPHgO/mPeFTZ1FyKYQVDtDVxJLTB9ShcTi E8MwucB+8U0ffU62gyYG35aYRBJ3+FJIon1uujqBYK/Pu1uRVfTKBO+sTkEksa400T1s gRowSo92Ipw70tkG/jqxKCy399edPCwx6PNaiKaYcyXBQ96dkRz27W5MnIJfC7c/gYlW RfqbJP+uiKlV4G3x0fk3h9g7t5PtoucbOPNm3wsnd3T827Htj21ygAeA/youJdcB4N5k MPDqhe94fRB49ac/yBuynwho/07Ov2k5i9pbCCg1NjhezP01fSQ9mt8NK9HYn0IgNgaE vmFQ== 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 d30-v6si19980260pld.452.2018.09.03.10.38.35; Mon, 03 Sep 2018 10:38:50 -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 S1731667AbeICV6Q (ORCPT + 99 others); Mon, 3 Sep 2018 17:58:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48212 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728430AbeICV6P (ORCPT ); Mon, 3 Sep 2018 17:58:15 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DE982D24; Mon, 3 Sep 2018 17:37:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Guenter Roeck Subject: [PATCH 4.18 084/123] hwmon: (nct6775) Fix potential Spectre v1 Date: Mon, 3 Sep 2018 18:57:08 +0200 Message-Id: <20180903165723.091229745@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gustavo A. R. Silva commit d49dbfade96d5b0863ca8a90122a805edd5ef50a upstream. val can be indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability. This issue was detected with the help of Smatch: vers/hwmon/nct6775.c:2698 store_pwm_weight_temp_sel() warn: potential spectre issue 'data->temp_src' [r] Fix this by sanitizing val before using it to index data->temp_src Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1]. [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2 Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/nct6775.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -63,6 +63,7 @@ #include #include #include +#include #include "lm75.h" #define USE_ALTERNATE @@ -2689,6 +2690,7 @@ store_pwm_weight_temp_sel(struct device return err; if (val > NUM_TEMP) return -EINVAL; + val = array_index_nospec(val, NUM_TEMP + 1); if (val && (!(data->have_temp & BIT(val - 1)) || !data->temp_src[val - 1])) return -EINVAL;