Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2988925imu; Sun, 9 Dec 2018 14:25:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/VpNuU4+9Oi79A44JiNBNsgwgpj0/6RlyDAcO2Hxxez5BAaM7eW5ap0U2IABzAkfZKUQzND X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr9948220plb.169.1544394308414; Sun, 09 Dec 2018 14:25:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544394308; cv=none; d=google.com; s=arc-20160816; b=XRdfF/fdRwQekCkDDbTCKWwmHtTQQIAk37PBqEd4oJ/uQd/tXbhIvdecUMf8GDQ0KY qlMoR5If4Pn6+nbgw2oRSjy5nF892HF335nn4lkxTC85y6bOCezRZ9Z5Bm91RdEhKSrE BNLZ/vBTNLynA9HK++DHZsHizKpXcUV4Vrbh4CRv1qPKvw2GYO3ebniJ7P2TlAypffjN aEcyZlExSauOh7puKFBB2nr3RiLTgEwlygndtvx7M0A3LfqP/MMZ2Aoq3TvDY0EZcKeF 2NPTKb3Hk4cpBuVXJK9+pPT1RGMOjfg3ttMBa/bFX8Xa4IuGtkeRqDNQOmTIrt7BXXwB 5Uuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=mMx9z2ie/9WFW9a4cobY8liXgzR0ojDF9UnKnXYnE/E=; b=nB9+Ff6huRFpcuG0T4zFmZjXPkfZD+Y6fogOU1OpABM0xQnblYPRyhI6BvxkoXeyFS NgIwxWzXDNikMDP9/9WY7mK4eE23aWyFSu2AK2NNAlHyqoKnTnJvqKWisyIU70BgtmVY qmbm+9XvM4bv8Tyrw1+DrANibSuBMD/b/MXIupbAVYMyM/iroJbwnDRHASJG2aZ9FK/F HYyyvYdAQBtYobupC3MV0G17N6RacFAgP1hvU1sdsPAANXiKdoe8tUapXzOATQv7PM4y E8LYpCCBOk1wzR3ldWC9r1w+pvaXiHhWgxogc5d94FSkFqccY85bF6OBG2Ly0swOFASp 1xjw== 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 d39si8486358pla.278.2018.12.09.14.24.53; Sun, 09 Dec 2018 14:25:08 -0800 (PST) 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 S1728613AbeLIWXk (ORCPT + 99 others); Sun, 9 Dec 2018 17:23:40 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35076 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbeLIVzS (ORCPT ); Sun, 9 Dec 2018 16:55:18 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72h-0002ih-Qp; Sun, 09 Dec 2018 21:55:16 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72e-0003RG-E5; Sun, 09 Dec 2018 21:55:12 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Gustavo A. R. Silva" , "Guenter Roeck" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 162/328] hwmon: (nct6775) Fix potential Spectre v1 In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 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 Signed-off-by: Gustavo A. R. Silva Signed-off-by: Guenter Roeck [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/hwmon/nct6775.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -57,6 +57,7 @@ #include #include #include +#include #include "lm75.h" #define USE_ALTERNATE @@ -2438,6 +2439,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 & (1 << (val - 1))) || !data->temp_src[val - 1])) return -EINVAL;