Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp23593imu; Thu, 8 Nov 2018 14:05:26 -0800 (PST) X-Google-Smtp-Source: AJdET5cbd4vSkVHGEwIk2tZ/P76E2BOBKUh/BGtXYKqrIqs1ksV4HijV+6XJzrfisXsxH482ey2H X-Received: by 2002:a17:902:6a8b:: with SMTP id n11-v6mr6366413plk.311.1541714726638; Thu, 08 Nov 2018 14:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541714726; cv=none; d=google.com; s=arc-20160816; b=p966lj6PBk0OkZzjmR3FSre+eE4tsj8SVOzJ4WHAOl2j83J+Z+/w0eI0/r17SmqQvl 2wAodw6RspVDR63hg73G89hUmMa47Kl+fCAUZQMtaxhFn1DWH56vO9F0IMpddIE0lxB+ VoW6x2txL8aFVugNeNgvGM5BDg1mg+FOPNjsXNQCObGY1hEv8OHfgkfGxk9AZJ8hl4re NuB5tvQcjsYLOyio8K+/38JHFvwIAc2nz3hqS8yQoOaqI4CQceww7hSgDs8AOF9gvbpj lmgejBykNNtztMH1N95pY0xITNDKuC6/R+tJM0M9N6vFrUFK8ZJgHVrXsaeLKyUdeVBH 0qlQ== 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:dkim-signature; bh=qYkLO7A5FdB9kxBvyIbv9JmEtXKV0A1gtADzMcyR8dc=; b=Y+j7J28tJeS750WJnwl2AHeb4M/KlBsTeqg9osvfEoWrlGN3LNLYGl86CexyDgEErs jI9G5PPsgrmRONaGx8mOUa9UusKZl7ihtbljxqGkwge8Sv0tmZ1+kqQiGF5MvPU3ygNP mjWvk4kCDwDo2yQT0HGWVGhsNnTRCUy++oN5dpKBY5q/S8uMsBh/KIeUJ1hxiMPjXOEe yHRjY/Bjiz/fQtS+6wFHkmIZcOVhuveLlgvnsbOTLDEFiDRnQYEXv8RybZ234WqGYvx+ XWaBiC/mAoCrpsKmthTDfWww9qDohRxfdzFfJWZn9Haig55TqgL1HRxjzCG61XpEa7eE v+HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jCpAhwaP; 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 f126-v6si2361006pfa.1.2018.11.08.14.05.11; Thu, 08 Nov 2018 14:05:26 -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; dkim=pass header.i=@kernel.org header.s=default header.b=jCpAhwaP; 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 S1730990AbeKIHja (ORCPT + 99 others); Fri, 9 Nov 2018 02:39:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:59070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728072AbeKIHj2 (ORCPT ); Fri, 9 Nov 2018 02:39:28 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2DE9221019; Thu, 8 Nov 2018 22:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714519; bh=LOKI/ylXW7fTq4Ff8c4QOMFbxdDHv5cXkGQN7iRQc3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jCpAhwaPlH6zvSkxnAw/oGSwQKEoiRFPtsP+sODG/T//dl04plLfoAQhUGxMJKs1F FTlEYYlb8aLmiZg342DmsK+eFQU9jh/HHTMhB0rd4U0NLlydqjQN1ttv2lJHQVAAsz vZYfEOTgpwotUlsvieV39GxXBvgOPswQ/bhTFERk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Doug Ledford Subject: [PATCH 4.4 106/114] RDMA/ucma: Fix Spectre v1 vulnerability Date: Thu, 8 Nov 2018 13:52:01 -0800 Message-Id: <20181108215110.346546717@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gustavo A. R. Silva commit a3671a4f973ee9d9621d60166cc3b037c397d604 upstream. hdr.cmd 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/infiniband/core/ucma.c:1686 ucma_write() warn: potential spectre issue 'ucma_cmd_table' [r] (local cap) Fix this by sanitizing hdr.cmd before using it to index ucm_cmd_table. 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: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -44,6 +44,8 @@ #include #include +#include + #include #include #include @@ -1627,6 +1629,7 @@ static ssize_t ucma_write(struct file *f if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table)) return -EINVAL; + hdr.cmd = array_index_nospec(hdr.cmd, ARRAY_SIZE(ucma_cmd_table)); if (hdr.in + sizeof(hdr) > len) return -EINVAL;