Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2647372imj; Mon, 11 Feb 2019 06:25:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IaFrcx7VFyKWzhZ6fQVIj4l//1uA2xfh2vm/W6BEe8o4gy1TkpfLaIYFcoVkDR1qmXDSkT8 X-Received: by 2002:a17:902:6f09:: with SMTP id w9mr38520073plk.309.1549895156902; Mon, 11 Feb 2019 06:25:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895156; cv=none; d=google.com; s=arc-20160816; b=cPAUKTvWTrLNXG/VfoPbwrcLkKBldpnSV2BB7C3BmXFZqENodboJB3KAUyTCNrosxA ggRMFJBrEb1qEtuoYyK/wCdR0Zxx29OrOGZTKODWYWWnK88Vgi2Jl1nIHXfqIKDZTaYL d+jD55DjZOKQgqbM+5mNiFnvZc6QFWBSB0xoOPSA1P2NHwxCfqyBpeQZTmfo5kxX7s0V a6CXO7PZVjbepWsCLREUYBiYgswBZg/r4A9MYNFp41jlb+Tjn6OA2ZOJe1PYYoGJ02Yo NskfGcHHXa68SniPCphroS7VIsCmkZs+gUsRot4nQ+YT/8tgaSkbYNGfCOO/k72OOczI xEdA== 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=BcKH8GAtly/5PkwUyuLxglcGLYVssxkClo8wxKahc3g=; b=Yy4KH1/G1yIQ3Ft9Z20DxtAE1RR4B/iumpCss9akRlaVcOeYHfIWzzWu9TzJDTWHKw VayZhiRQWCPj/u8r4+bUpGsZU1ezDtq1YDQ7J7+D29f2wBvTMB4RZYXDVgwnU1zfkRGU 92A6GR9VIpZOwXAcR1QFgf7MkSmuz/HVNOFz9NKlprsdVO2Cj/nQlS+577k0ALDWcmpg X2i5aI0DyiVFW+IOpZOBzIXZ2NcXwGZFDo3Re8M/3wwsvWWPToQBbWH3ze3kS0WuBVio HU3Vuvw5fsflmzIvMCuZhzsOVSgdLIJIdBRRKm/jvfSEINd65I9RrfSMHCwW90aHycwc RnQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D0y93m75; 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 p189si10417685pfb.0.2019.02.11.06.25.40; Mon, 11 Feb 2019 06:25:56 -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=D0y93m75; 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 S1728380AbfBKOUu (ORCPT + 99 others); Mon, 11 Feb 2019 09:20:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:53584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726796AbfBKOUt (ORCPT ); Mon, 11 Feb 2019 09:20:49 -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 5374520838; Mon, 11 Feb 2019 14:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549894848; bh=WYPSYzdLZ5ZsN1ieUok+VanCLX9cEhUwhiLFNcBm6eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D0y93m75qnZXKcz60jGTt0OAXFAJRzWb3ghE3VWypg7H7Cp167tNezuGqQOTWjLdM EykoV6F9edpzbZjJWo6FS1DL0iWMyLZM/hPabIsmaM5pQ7TVoL49hpNLZWl5V/DFTW Y2nQ3f4776ekXsTpxQAqu+Q0b2No7r3TIm4g0U78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Daniel Vetter , Sasha Levin Subject: [PATCH 4.20 001/352] drm/bufs: Fix Spectre v1 vulnerability Date: Mon, 11 Feb 2019 15:13:48 +0100 Message-Id: <20190211141846.622069821@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit a37805098900a6e73a55b3a43b7d3bcd987bb3f4 ] idx 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/gpu/drm/drm_bufs.c:1420 drm_legacy_freebufs() warn: potential spectre issue 'dma->buflist' [r] (local cap) Fix this by sanitizing idx before using it to index dma->buflist 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 Signed-off-by: Gustavo A. R. Silva Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20181016095549.GA23586@embeddedor.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_bufs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index 7412acaf3cde..d7d10cabb9bb 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -36,6 +36,8 @@ #include #include "drm_legacy.h" +#include + static struct drm_map_list *drm_find_matching_map(struct drm_device *dev, struct drm_local_map *map) { @@ -1417,6 +1419,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data, idx, dma->buf_count - 1); return -EINVAL; } + idx = array_index_nospec(idx, dma->buf_count); buf = dma->buflist[idx]; if (buf->file_priv != file_priv) { DRM_ERROR("Process %d freeing buffer not owned\n", -- 2.19.1