Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5608953imu; Mon, 26 Nov 2018 02:57:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/XwnAFdN7vqImA+TADocvqh5hKBseKV6WBA9eytdhnkqLDbsoFU67t/obN83RmeaZPmnJA3 X-Received: by 2002:a17:902:8d83:: with SMTP id v3-v6mr27128410plo.162.1543229867775; Mon, 26 Nov 2018 02:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543229867; cv=none; d=google.com; s=arc-20160816; b=n87kZXaeRI5SIrensbqiyN600FZUllt1gRqNdM48o6jWMv+HG58xBNmtd00mMEnD7m ZzwGtVQq3Qx5Oeqwvr0L0Zox1MpUkRFBWG49v6hvmqS0tFfkbeWvdOQP7KFuJdhtOGnS trnz38Zgn2r+SbQJHqD1c0q/PvzFEoEg7xPY18W5y7Dh98MyJXHRkjhSlzzSrsQFJtAu BFhT4oaB5/R9pShQess73xzte28ZOi2FhFk0jR//klDNQpffqdtWctx9yRxiEu2mzEP4 ouD9KZDZA/MHONUguGAVkz4S6CnuHgmzjokoy+hHqrFHG84pyOa8OC7n4nATG207CzHW DaCQ== 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=aq+E8C8/fSrtzWF0dOnHe1k/v9nQW43TbLBZONyxeB0=; b=a18Vrm2f71aFcXwLHepNRbzlflJ3vCb4pZ6r5NLigNX2GqrDYt0JUGF1yjQKAfU7tC vawzNB/AzD+tf3DjA0rj8v32F0Lyciz18NWYCxVvj/PdZREhP9KP2s4TreB/eMX20fyo 1cLltZYj1Px1TdUlGMJ7CAQ/IUrsUeCnnMJcWD1zwlfWdQyuqT+Ie5TmwaHGv62mDqpV Xezw3DZAijr+M7JZrAOU5kDNVoSeyrne+XcJTRhE0x9T03X8N4hfCSy9DOONatvXYv5G yxOmgXazIVCOI5sT8V2XdpaVkyrbnp9zF11y02BW2SZb+zW/3LjFnaA96WiV7gZ+Vb0o XCiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VgDbwICA; 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 z18si58227422pgk.367.2018.11.26.02.57.33; Mon, 26 Nov 2018 02:57:47 -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=VgDbwICA; 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 S1728303AbeKZVt6 (ORCPT + 99 others); Mon, 26 Nov 2018 16:49:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:59040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbeKZVt5 (ORCPT ); Mon, 26 Nov 2018 16:49:57 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 D2A1D21104; Mon, 26 Nov 2018 10:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229773; bh=VuRSoejHeCM7O8qUOf2CFDtAajRoIqy2QNSLFPKCY74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VgDbwICAweGQW4sqTqLor+UuQJCA5xAnNKKFR9LESugaXiGk0U5uOZ2gIYknKECc0 bf04S5+XjERaVcAtr/ikr9U2Fxzj38rCUF9jqwFazVGihZ6rc6JHc8QxFStO4gMkbM WWQ6JyfD3hgzxD8RQwMhL8IbOb0TMPJ/dRj6sZf8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 4.4 67/70] drivers/misc/sgi-gru: fix Spectre v1 vulnerability Date: Mon, 26 Nov 2018 11:51:22 +0100 Message-Id: <20181126105053.014239351@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105046.722096341@linuxfoundation.org> References: <20181126105046.722096341@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 fee05f455ceb5c670cbe48e2f9454ebc4a388554 upstream. req.gid 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/misc/sgi-gru/grukdump.c:200 gru_dump_chiplet_request() warn: potential spectre issue 'gru_base' [w] Fix this by sanitizing req.gid before calling macro GID_TO_GRU, which uses it to index gru_base. 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: Greg Kroah-Hartman --- drivers/misc/sgi-gru/grukdump.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/misc/sgi-gru/grukdump.c +++ b/drivers/misc/sgi-gru/grukdump.c @@ -27,6 +27,9 @@ #include #include #include + +#include + #include "gru.h" #include "grutables.h" #include "gruhandles.h" @@ -196,6 +199,7 @@ int gru_dump_chiplet_request(unsigned lo /* Currently, only dump by gid is implemented */ if (req.gid >= gru_max_gids) return -EINVAL; + req.gid = array_index_nospec(req.gid, gru_max_gids); gru = GID_TO_GRU(req.gid); ubuf = req.buf;