Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4532768imm; Mon, 17 Sep 2018 16:00:46 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda8Hs6SMY0oIt+fWCrTWBinL4znrnD0wyKHL481fKfEMOj8cjat4But0BAtUe9uLHwgs0wi X-Received: by 2002:a17:902:9696:: with SMTP id n22-v6mr27087968plp.212.1537225246845; Mon, 17 Sep 2018 16:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225246; cv=none; d=google.com; s=arc-20160816; b=Esrt2mgjXG2mnu3Rc1Y+Npp/RlBoA3CSvpXanJDNn4ERAbLPBn1MN3w3LxDJ0eEsgB chSKmW9sySVzQkC5soUZ3IkETx4eh5SWtBnW+k/H7dCHVK3QyJZ/Xvl0Vt3BICNKt4la oFzkXl3qEUqdTOFqnaJF6fD2SZr/3dkBf1dnLVEEuEGhDJZxCgyNEx/3TDBk3HNkx+FV 6w8g6oqvniu6+dJOJH/uzBf1+D3/r/UP27xDQe1Bv/kisPcQM0XcELR0bw3jWB+4kI5J +meMvdAOEgAQ5ZPUTS9m49kw0AlWBYbrtLGlQm1tU8cBHujW36bduy4F3YISKvpzso4m CaGw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=0lsrx2AWoUHUvo4NvGFkjDSaTGnB5tVBHEZNUf2HiOQ=; b=u5zD7tSh1sD1bsWubrecCbwdj48Ov1CW/OjF6DXkx05QFb4yuZ1GUvSV5lXGD5WENO ajJfdRADblVwb9u58v0WwVlEpuNEMQgK6utzoYktAzykbF/KLyV4xrQv9hLt2Uolu4Q4 fdVqO6gaINJ2Jo/dyaX5IM/MbwcqjTWZb4ZWFD2ZdEjsD9AU1JcXDLOZQqP8aE/aiwhq wzRTyNN9x3mlsWwntMpvCxIzBmfzpdkj5MdcjKBJ8Czi5fsueigVTh1y6q1EZr4pI0KZ ohxhDJr2XPjpq+LsHdM89/A49kQBP/9BdFwKetwXae8wjmLVgRFmaorZw6CRhbQ8tsnU YYjA== 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 x23-v6si16403917pgj.543.2018.09.17.16.00.31; Mon, 17 Sep 2018 16:00:46 -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 S1730023AbeIRE3x (ORCPT + 99 others); Tue, 18 Sep 2018 00:29:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48066 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727559AbeIRE3w (ORCPT ); Tue, 18 Sep 2018 00:29:52 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AA304C7D; Mon, 17 Sep 2018 23:00:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Bjorn Helgaas , Logan Gunthorpe Subject: [PATCH 4.14 018/126] switchtec: Fix Spectre v1 vulnerability Date: Tue, 18 Sep 2018 00:41:06 +0200 Message-Id: <20180917211705.882751290@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 46feb6b495f7628a6dbf36c4e6d80faf378372d4 upstream. p.port can is 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/pci/switch/switchtec.c:912 ioctl_port_to_pff() warn: potential spectre issue 'pcfg->dsp_pff_inst_id' [r] Fix this by sanitizing p.port before using it to index pcfg->dsp_pff_inst_id 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: Bjorn Helgaas Acked-by: Logan Gunthorpe Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/switch/switchtec.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -24,6 +24,8 @@ #include #include +#include + MODULE_DESCRIPTION("Microsemi Switchtec(tm) PCIe Management Driver"); MODULE_VERSION("0.1"); MODULE_LICENSE("GPL"); @@ -1173,6 +1175,8 @@ static int ioctl_port_to_pff(struct swit default: if (p.port > ARRAY_SIZE(pcfg->dsp_pff_inst_id)) return -EINVAL; + p.port = array_index_nospec(p.port, + ARRAY_SIZE(pcfg->dsp_pff_inst_id) + 1); p.pff = ioread32(&pcfg->dsp_pff_inst_id[p.port - 1]); break; }