Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1829483imm; Mon, 3 Sep 2018 10:30:43 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbq6qx0Cpxx0TxcBx1WVvWfGZt88OAXuX5kel1UkWT+XXRrVH+463IsDfKywiXrqsdvI/Kp X-Received: by 2002:a62:68c3:: with SMTP id d186-v6mr30321196pfc.70.1535995843196; Mon, 03 Sep 2018 10:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995843; cv=none; d=google.com; s=arc-20160816; b=oiVVHVcV8C3f1NUtEN5ujv1/ogOm4D9LBhDhmV7KAWLXxdp8y0rTM+4GMzJwPTHGSb djcesOvurarqaQoX/JByO8sBqI4KNAOzKn4Hqk94JYbOF/C9vI+o8t8ZVIruKy2txRki cuL2exakZrX23ZBAf5gJvJfuP6JAiBcSm0UreKb7vYEznrcnmLjiaA0K8RKdexyMYiYb FdWCK+kUQspcivPt+rWxXywdtkil+nPfvPIgPIgPgtpI2ZXY8NmtcFE60esh/4zypkl+ xUjPpXOQa0Ii37Hlcu/r7OKAJ1GCnzg4molgJm7GV5J6vFcFC7mVOlrzCff/zTekaoS5 XHgA== 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=Ul864mec5z4JYf+QK5RCIS63W/izLkrHWmU14SOqAlE=; b=BCV9TuxC9633pygXttBVSztrvsZy0U6sK+zRmSLwyBBMZeYI25F6ZDUKvCpqgUyBd0 lJrwAgiYmDhStbuobZjCPFmkGiiMFX9AL70Bvr/Da7VFGNTwV6qCuOUDhdWCiPNRGha6 2V1djSPxu94pGPqkbYHlNUF4WoN6n8kGg2ad/uKM3k7Wiipu8TOidNr1uBzPTCumq1Qd PzGy37H0jm2P8NRxNnba3RdabSF3O0nqumpSgampFTgUyJwSzRVC/fk7RcjAlVKZAeo4 Ne2Z24PRoWK4FffoU3cj4QYPvknNgTcTJIIhhGuX9IciZi75+QUo/oid39gGlXix8pm+ 1lhA== 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 5-v6si18137503pgf.18.2018.09.03.10.30.28; Mon, 03 Sep 2018 10:30:43 -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 S1731242AbeICVuL (ORCPT + 99 others); Mon, 3 Sep 2018 17:50:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46524 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728733AbeICVuL (ORCPT ); Mon, 3 Sep 2018 17:50:11 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AEE4ED18; Mon, 3 Sep 2018 17:29:03 +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.14 140/165] hwmon: (nct6775) Fix potential Spectre v1 Date: Mon, 3 Sep 2018 18:57:06 +0200 Message-Id: <20180903165702.554782873@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@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.14-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 @@ -2642,6 +2643,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;