Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp36311imu; Thu, 8 Nov 2018 14:18:31 -0800 (PST) X-Google-Smtp-Source: AJdET5eImCFsgFYrKBhHdTmwIZ59zmRAAziWbIR4WhPmmKtn6yN7pw/GYSa8FMsNAGky79QE0j3I X-Received: by 2002:a17:902:8543:: with SMTP id d3-v6mr6336809plo.313.1541715511600; Thu, 08 Nov 2018 14:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541715511; cv=none; d=google.com; s=arc-20160816; b=GfwmUmZkujG/PaqOVhrfl36sgMySyqAFp+tM8U+QTWhYSt5kqOWea7p+snMHribkLV BAQcfqej7wPWkotTGnwrtRtznfwChlVQra6xyU/C+tUH1qQSCi3hwXtW2On4KAnIqLxr KCH1PdOep41oS3DNYGinbRApNCOQ9CmHe5iIIEWSaXXGvoT1Z1tl8eEVqlFC8/xWoSG8 oqjPXlUAu7yxeKmLg76tbExT/Oorwtg1luZ/ZVgCnGloh48dkVKB52rDq/Ta5mPBZCoc 9Pl77yaH03ynd9vUlvfQkjFH+WMhzb8J5xtEkT2nxAffT6pcHMQ4FkshvDGFA/4XeUKY GgFw== 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=/XKMXkQLLn58XYDB9Bcw8Iiix/pc+vAcuqUVpLocf58=; b=RYdZSQvwsyeknVHH+JaZsGNBU6I/WXHn6vaWlWhufu17Z4abHdfnRdxaB/UZEuA6Cu c8E7nns2NZx6BfYh8ZbvFS2EK+mYTUdUlSQ9we6gKFhJgpSjgA3rW2W8IwJ+xpLjGjzg pTI8FAe8Msnxsq6ARNkChWk4uXUxnmqb5ZtgATMmTKRZXidNBHEwbB/SNsYS1fWLGGbf xdhIk3YELAIHF0ijI6wio+hip+RJxkNVwMKbw6TRJRhJWlLj8PuUP3ixWj0NMHqlS+mA bkPRLjzQADCUWbUL/zlefU0DWDPfY5z/lef071lGc3whBwU1WN6GMYnYfXQfknywj1ov Uo/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="x9byEub/"; 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 p25-v6si6352191pli.239.2018.11.08.14.18.11; Thu, 08 Nov 2018 14:18:31 -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="x9byEub/"; 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 S1731482AbeKIHo5 (ORCPT + 99 others); Fri, 9 Nov 2018 02:44:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:38232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727468AbeKIHo4 (ORCPT ); Fri, 9 Nov 2018 02:44:56 -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 4E6FB20989; Thu, 8 Nov 2018 22:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714845; bh=TJNeulwiDrV7iG0S4P8HiTqzwuUZSQ4dwvxmV203Jb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x9byEub/RwvtgXs4npkCppvhTrMtvEc+MPWbqRsZ8mdNEGreN5jSByNKv8XvvCxyb /UpWhZ5MIbzqsI7tk95hj0Gvl2do9X4eJI9/7MzKVxhENpf4niXNUF6KTpBqrPfWkj 2F1tsYGUIKVpa4+k35L4zTfEK630qQjn6DTBw62o= 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.9 162/171] IB/ucm: Fix Spectre v1 vulnerability Date: Thu, 8 Nov 2018 13:52:12 -0800 Message-Id: <20181108215138.652601648@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215127.257643509@linuxfoundation.org> References: <20181108215127.257643509@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gustavo A. R. Silva commit 0295e39595e1146522f2722715dba7f7fba42217 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/ucm.c:1127 ib_ucm_write() warn: potential spectre issue 'ucm_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/ucm.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -46,6 +46,8 @@ #include #include +#include + #include #include @@ -1115,6 +1117,7 @@ static ssize_t ib_ucm_write(struct file if (hdr.cmd >= ARRAY_SIZE(ucm_cmd_table)) return -EINVAL; + hdr.cmd = array_index_nospec(hdr.cmd, ARRAY_SIZE(ucm_cmd_table)); if (hdr.in + sizeof(hdr) > len) return -EINVAL;