Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5615056imu; Mon, 26 Nov 2018 03:02:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/XJwDyEEHMSXHcCw/Uny0X6JPIHf7dmyJ7FYRQ0jhuthYQvCu9E68CSPC1jXJp3S6QrqpU+ X-Received: by 2002:a63:24c2:: with SMTP id k185mr23715738pgk.406.1543230165710; Mon, 26 Nov 2018 03:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543230165; cv=none; d=google.com; s=arc-20160816; b=TC13JH4UynZWd+d6scgtTAe0JNVCWNdRVE+oSWhSJXyNoqxIS2wUAS/nI2kBcljr7G tjQ5VwiT6pEwl9rTTrZeHW+ABFZiQDpB51Vp4o2vSE149KkB/2JWkbVjP4PQCaY8iYzj ErOrsOXhzPV1pJIYV2TgKXFFGOzoevoCBU1ejqLliQheRbObSMDkNEA1gzTNzpEXd4s0 K/TI1xfdYwm5HV5cn4rC53Dt+HYzvGlw+64CSuyQf05ssDDEwzLnS3R1SWGpGyJMXBNb DswUwb7en9dUsH0DDJtcQr/v1YImTf8IturOGsjnc0C5DR6RVyPo+PmdxLglCMWjLceB Q94w== 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=imyuicaP2gUKz9zuC5uCrwIwDvWh1AdmKd6YrmQyk5A=; b=iWuhOGUCNx7r09MG4hNwnkik8zqHs9RDB79oExfXNwI5qTzI+7Gznvg9qgcpoa7xj+ Qt2jgkVgzH3j0d7WpW4sDLKMB7UMIDrMLbSK6zqUf9A8NCggTdiAkrMfoZT0ODHpGDTE oQiUnRQR8buXmNPYuPi4MWLJltGgPd4qSUuoFcX24m6eO0vt0wgy7pBDiSZLP9IR+o2A kMXMu1Sv4uwrpb0OcCvcAsnksSBby6R+gyapznJWkGSaCkIfcRAtq7P3r3Roz28alycN t7fcscQW7GhTEnV2ofljQ2WhIdXWtmDG9UAIhiN3vSHs4+jIiVAQLLKaGlP7M9rcobyh iLPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qDyppsvO; 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 x74si46127887pfe.23.2018.11.26.03.02.28; Mon, 26 Nov 2018 03:02:45 -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=qDyppsvO; 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 S1730056AbeKZVy4 (ORCPT + 99 others); Mon, 26 Nov 2018 16:54:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:37284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbeKZVy4 (ORCPT ); Mon, 26 Nov 2018 16:54:56 -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 794BF2089F; Mon, 26 Nov 2018 11:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230070; bh=tK4Ev2g/K3bk+abi+HNndug5WoYB05kw2bVuFK37FuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qDyppsvO92wpkJy2RSvl5SsQop3Twj2i6lxwsKatTM5JZdskF/SAKQjwr950Q4mT4 Dj2ctenQgofRDLLGlm6ATatvf1EYW/xXyyGekqvLqPc038QmYJq6ZtR5uxmRSgobS7 5CP5SwMpYG5Lhb5fdwKCh8xwc5Dx/iSNXTk3/TNg= 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.14 59/62] drivers/misc/sgi-gru: fix Spectre v1 vulnerability Date: Mon, 26 Nov 2018 11:51:40 +0100 Message-Id: <20181126105054.997469993@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105050.592727680@linuxfoundation.org> References: <20181126105050.592727680@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 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;