Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3305424imu; Sun, 11 Nov 2018 12:01:45 -0800 (PST) X-Google-Smtp-Source: AJdET5ewKo6DVhw2RC7Y7HjmFsx/NiAWnnGvqmfCNzihnd9rsPyMBzfFaHyd8JHFY/IedT6y3dLB X-Received: by 2002:a17:902:244:: with SMTP id 62-v6mr17562011plc.280.1541966505494; Sun, 11 Nov 2018 12:01:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966505; cv=none; d=google.com; s=arc-20160816; b=kP9+NsBKaSz7IoloHgNv3s2XD7fejyv6BK6ucOV4S5ekRAQ2bCKTJ0W5Eysx/zgP6N GJXI7hrQ94UUU4ZOPTz3NQ+JyKfksd+OERLAnGNtFR4n0Uxjir0F3LUX/hYfrfai8y77 dE++1V1WASekr7oz4OBaWVqGYJj6sZBtnSUy6YcAjELVwKwlUr0qsh6ApjDXZDcxDHY2 Jw2crAsGkNeD3xznHSgWUrcGh6zntAaRkUcLQ1a75dBN3w3pOGux2T2afUOCG+JfCG6i hIzWF2Uleu7AK81Zql3jvpRKTvWj/xii4G/9sXsutLdATKwLldaB1nMMae5t8X1XJlKv d7LA== 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=HvB/qR6Y/aRSW6cM8VVbsx2uak7K9/NGiR0keMZ+0eA=; b=c8pTimu5NaFESmdUYKg8NLbMxr1Lj2eNnyJNgcRAfkkm7UTyDR8ua8Fmx1ZkWt+5tK XK1GCPptodJnmsroeSUWpND0BVTFPE3ci5B0zkLR9CjLabTG8mTU3/qyzm5zZWPYU0C/ HRCsIfsItrEx0Wmv98tuOJX+OgWO6zFGH5rjrPgWpvysaZ8m29auH2GFifEB/xeE4uKc W53Nr6il4oNuS6kOSq7Z32n9VpiZxwCPW2kY0FHoa/raHKnWzIyzifdyPTwLNNHMNuDy eudEszkpJPtovSNP5e7EY7avw0yGgop6M5CC+3lHHnZiYAkrnZmdNjd/c4sSIzYxEh7Q hW7w== 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 f184-v6si725042pfc.224.2018.11.11.12.01.30; Sun, 11 Nov 2018 12:01:45 -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 S1730846AbeKLFse (ORCPT + 99 others); Mon, 12 Nov 2018 00:48:34 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51010 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729610AbeKLFs3 (ORCPT ); Mon, 12 Nov 2018 00:48:29 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsp-0000l4-56; Sun, 11 Nov 2018 19:58:59 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsX-0001kV-8q; Sun, 11 Nov 2018 19:58:41 +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, "David S. Miller" , "Gustavo A. R. Silva" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 269/366] net: cxgb3_main: fix potential Spectre v1 In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 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.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: "Gustavo A. R. Silva" commit 676bcfece19f83621e905aa55b5ed2d45cc4f2d3 upstream. t.qset_idx 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: drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c:2286 cxgb_extension_ioctl() warn: potential spectre issue 'adapter->msix_info' Fix this by sanitizing t.qset_idx before using it to index adapter->msix_info 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: David S. Miller [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "common.h" #include "cxgb3_ioctl.h" @@ -2256,6 +2257,7 @@ static int cxgb_extension_ioctl(struct n if (t.qset_idx >= nqsets) return -EINVAL; + t.qset_idx = array_index_nospec(t.qset_idx, nqsets); q = &adapter->params.sge.qset[q1 + t.qset_idx]; t.rspq_size = q->rspq_size;