From patchwork Tue May 23 00:14:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9741635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 539A960210 for ; Tue, 23 May 2017 01:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43A36286EC for ; Tue, 23 May 2017 01:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 388AB28779; Tue, 23 May 2017 01:00:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 056E2286EC for ; Tue, 23 May 2017 01:00:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D3C9E6E2E0; Tue, 23 May 2017 00:59:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 889BB89C1C for ; Tue, 23 May 2017 00:15:19 +0000 (UTC) Received: by mail-lf0-x243.google.com with SMTP id m18so6671142lfj.0 for ; Mon, 22 May 2017 17:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+ENv1g4EEvFfTi0xE/Wzb96HFV+vKBE4ugaPimI5lBE=; b=pb69K/vjT2t8FgUhdL224wrW1WZ9nEshW1f9AcsEu9NBG1xyecHyAS60m+y6FXeNG/ PggJhKNANEUE19+LcfnB10xdc+2bA+m0qO6B9851hq5rlvIdCknVKaqL39apIZKo6Cb+ USa4U1bOZzDxsmIV85q6tTRPAbwv5P2udGDN6Sgp8/yS9tQba74dyEtuLEiqx2E11vSt kyQTEEdaaJWN30ki6Vr/2ctUdb1Ibu5IPAyZpp2s7zTKlLO0l4BFFiCw6zkJD3otsjDp /M+UD/r/yFn1HBoxTinFstwpJoIRrn2F0YFepfulGjJTqhxE/B7i6ufIdNSbgYlChCf6 2ioQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=+ENv1g4EEvFfTi0xE/Wzb96HFV+vKBE4ugaPimI5lBE=; b=BBIFgfmCR+MiYvZ3uDZbybIeul5jC4auUJi/xJg1SMgQcShHXvmc5On/DlRmNy+Cmp z8gQy9Khqh9/WmBbxtMvm3X1WU6VjEZrfAJIlmNJfyGNfjwbhTMs91QZYjW4pleCm77i HvS436mPO4vte9hGI9ou1tvb150pvtaZsrfnlvsJ2eOByIEwKWOSIGxfpwip4bz/KrnD u6rluy5iHZCQrLO7iDemK/uxWUjqKVq7dKQ7BzXID1xhCejYG4SlkqAqX2bc3hN8KMu2 Luvk3MIjHW0dqYQhyTo65E6ls0+AQPvykL/26nnPa7dQ6N2ejlgg23NwsiA0LH4y2lUj ROmA== X-Gm-Message-State: AODbwcA1sDlGpRDTkZVw9jwtRdorGcntyFegeZOB/wxiDXsoy8ButfGg lISNZFMXv3rLbA== X-Received: by 10.25.150.65 with SMTP id y62mr6005673lfd.167.1495498518009; Mon, 22 May 2017 17:15:18 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-175.pppoe.spdop.ru. [109.252.91.175]) by smtp.gmail.com with ESMTPSA id v30sm3440904ljd.9.2017.05.22.17.15.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 17:15:17 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen Subject: [PATCH 03/22] drm/tegra: Check whether page belongs to BO in tegra_bo_kmap() Date: Tue, 23 May 2017 03:14:18 +0300 Message-Id: <04637a55694493bdd8267a7f19798d7968568087.1495498184.git.digetx@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Tue, 23 May 2017 00:59:38 +0000 Cc: linux-tegra@vger.kernel.org, DRI Development X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This fixes an OOPS in case of out-of-bounds accessing of a kmap'ed cmdbuf (non-IOMMU allocation) while patching the relocations in do_relocs(). Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/gem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index 424569b53e57..ca0d4439e97b 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -74,6 +74,9 @@ static void *tegra_bo_kmap(struct host1x_bo *bo, unsigned int page) { struct tegra_bo *obj = host1x_to_tegra_bo(bo); + if (page * PAGE_SIZE >= obj->gem.size) + return NULL; + if (obj->vaddr) return obj->vaddr + page * PAGE_SIZE; else if (obj->gem.import_attach)