Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5623199imu; Mon, 26 Nov 2018 03:08:38 -0800 (PST) X-Google-Smtp-Source: AJdET5fuXNk8Zc5vqODJAuYyiardknR7HiqKhEmIF1qVAyVYq2zgi/sLYkqtDvVXM3+JFsj+l5i9 X-Received: by 2002:a62:b9a:: with SMTP id 26mr27700078pfl.196.1543230518058; Mon, 26 Nov 2018 03:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543230518; cv=none; d=google.com; s=arc-20160816; b=K/8hadyo5pNNqT+bBXo0Uf9VOgciaLwEz+nOMbogeVBbhvWvKmWfRLdNEnrirvCO+1 sFNkjpsGpVi69DWyWVYH5xyHGv/tUEMMsX0xk9fCJuBgyc43QnaBP02JtYLnD4B1jPCR cJ0pt/ozSBGbnXtrJUPy7k0b1DWIIJxtIk1EE80+8Ar5hj5cGZG51+8nbWJkRZhXvvOj fh6K33jebuPT6LiYfejLVlgEh7M7cMVU8xqTOO6gRcrPsCT04Ah72e0RGhEjTJeAorwi Sr6WMU/DTbqDxNVsv0eWkZIEmF9yKfPvdIWNcXmEntCs3HCs4g3q/xVcw/iwQiWYzciP vb1w== 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=/s/kkfhhCb8dmwTya7UmQRRgsHLcLej/+JfXg34AZE4=; b=W7Emv/3FtmoqD0cvYpFxzr/VLd2J7mxlO6GZz8sOftuI0cKwbQrYDokVJx00fITnlH /04hj56e2P6SbpAfGHODzNBst8TBPpQRSfBc8cVj6HPmIaJRYjXn/7Ju7mp8uYbWUh09 /A8Rs2kvfjfKN8auEWzAIKKInd4FHzhAoSb8095vvni5b4IFLq3tp0hxOPQXUWAPpIJt F6v5XlrUNSedROQr4j7qYZ+GFcITx3xbJtFgXInzxGh/dw4yCTa2c9RIZbdt2EZEFNns fjlnZKBTsSKE0d+Zd4bxM+ZCsTI9fjOHmf0BcId7FncIFRAeGfyBVgLtAV86ZE5sngZP I0uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EaT7rCHW; 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 g33si43240345pgm.426.2018.11.26.03.08.24; Mon, 26 Nov 2018 03:08:38 -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=EaT7rCHW; 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 S1731604AbeKZWAT (ORCPT + 99 others); Mon, 26 Nov 2018 17:00:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:47140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729543AbeKZWAS (ORCPT ); Mon, 26 Nov 2018 17:00:18 -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 6351020645; Mon, 26 Nov 2018 11:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230392; bh=dYBAKaCgyDuausGH9hq5jFSnRiRVQIw9Tjw3qLs+sVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EaT7rCHWFcVRdxavpZDwCG1WQWgNEWA5K7mZZGo3gAJ9rGd5n7ceZA3OuxgPbTdHh q86KD5Cg/W1kehKXomj6v06PW6YWcVcV7EbaJGi2g04qDD+sDqZ4uXjSBRv6gBRYUz UukHwemPsmPyzPRGPu22ns1nUZWJv/liTkbgV+lE= 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.19 112/118] drivers/misc/sgi-gru: fix Spectre v1 vulnerability Date: Mon, 26 Nov 2018 11:51:46 +0100 Message-Id: <20181126105106.243838383@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105059.832485122@linuxfoundation.org> References: <20181126105059.832485122@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.19-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;