Message ID | 20221110201349.351294-4-dmitry.osipenko@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp355681wru; Thu, 10 Nov 2022 12:16:59 -0800 (PST) X-Google-Smtp-Source: AMsMyM6JKg0d2B0m/uuNw7YZQ1s9Vg/3Mcm72bJfazOtutjHs4ECtkzYrsHWPLp7wLx+O6+DA6Dc X-Received: by 2002:a17:907:2d13:b0:78d:d4ca:21f7 with SMTP id gs19-20020a1709072d1300b0078dd4ca21f7mr3823070ejc.128.1668111419349; Thu, 10 Nov 2022 12:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668111419; cv=none; d=google.com; s=arc-20160816; b=DNb7a/tWse9Wknr39ZpCSQMIUgxV4LeJSuIFMDYN84a7Gmxxfz8ZDyYjzp+sy2UuYu LzWWf5t6qplnhWf+9jXYo5qjj+GOqDwe/0dBULVfzduALvk9HLCxoS1YLKRyltBzNzHy 5pOotih/HY2Ndl/Cmkow51j/CuqE2BDmc15PeVfB6CsZD+f5lO9++/ShLFkpzPxs7WXW tahJsQZN6pc65tN4N4pzVsA9+wPAlg1C9IgKUJqIizl9EGyGZeCanxogzM/Rb2m8E+nX ge8+cDCHeA/3e0EBRJr5GTKAM7uktd+QnpB9b/Mosvv3ImNcxgz1o4vOpYuihKgbhKOr OgkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ycaxoTYoP4GhyoT8zMmVSzMBy1GadJiA9aZMSS+tTxQ=; b=zoElozG0bm4jUdw9hRtr4SNvazTdV+oJpDNJxLRow76DuKHWCUpMlv+1P1R114ZvlB sz/33pfD60NLSEx6A1mGL5wfPqVYyjj/bgUqvFvG00KfeLCOEP2UEZuBYXRiMk3WByL+ A2kfCE3iWFOJOzD81YIXUJASwlDw0LDNhIw47UUAXXiQ2wixRO3XTwSElx/27VBTTbLf 3v+r4z+pelkZ3/r6qRC2alGtLaFApN2go7QObrCDbVqfzxS340C0pk94wZaFJYNI98TV ktTH48KCKHqH0SbfVtfnxA50cuo/hZcryKW32fbpVWAgR58+sEmRlQ6MgBzDbRozcyon Pe1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YvJFNfG0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a056402274a00b0044f288e02edsi662300edd.15.2022.11.10.12.16.33; Thu, 10 Nov 2022 12:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YvJFNfG0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbiKJUPK (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 15:15:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231522AbiKJUO4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 15:14:56 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62A0E50F1B; Thu, 10 Nov 2022 12:14:56 -0800 (PST) Received: from dimapc.. (unknown [109.252.117.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 69D8C6602A41; Thu, 10 Nov 2022 20:14:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1668111295; bh=Y9B9YrrEmHlNO1aEObVWaFh4UvP89E0LA68VwtlK5tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvJFNfG0veek5/GRaGa5nRrI/zKHIbyJmgP5Wf0I7nWHz14yHRQEDHx4U91zB4+XD DSZNDsmp1HtnE+QNOMSbxp9pUzx2JkuOF6lmfXmztWoOfbHEwP6SzHu/oMI5WkiuD4 oX6vaEzRzRW/siHAWBjRVqW6yjWzyJfTbPzG3MvfNQs8R1zP6AMq/0gU0aPQp1L80R yXf2zI9i9HIIVNTDlvjA7BXetRNrmgqF/RdqwW+1JMdVFVILpoEaFunwkrayKHghVS 4ZSMpbMXyeTxhUhFrD0LReNJC90DC/wylSo3H1ulvMs/kenG8FCVxr2YPwqlzXVQM0 QMcmyw/jqO+gQ== From: Dmitry Osipenko <dmitry.osipenko@collabora.com> To: Sumit Semwal <sumit.semwal@linaro.org>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Liam Mark <lmark@codeaurora.org>, Brian Starkey <Brian.Starkey@arm.com>, John Stultz <jstultz@google.com>, Gerd Hoffmann <kraxel@redhat.com>, Daniel Vetter <daniel@ffwll.ch>, Jani Nikula <jani.nikula@linux.intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, Tomi Valkeinen <tomba@kernel.org>, Thierry Reding <thierry.reding@gmail.com>, Tomasz Figa <tfiga@chromium.org>, Marek Szyprowski <m.szyprowski@samsung.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Amol Maheshwari <amahesh@qti.qualcomm.com> Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 3/6] udmabuf: Assert held reservation lock for dma-buf mmapping Date: Thu, 10 Nov 2022 23:13:46 +0300 Message-Id: <20221110201349.351294-4-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110201349.351294-1-dmitry.osipenko@collabora.com> References: <20221110201349.351294-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749141599550472921?= X-GMAIL-MSGID: =?utf-8?q?1749141599550472921?= |
Series |
Move dma_buf_mmap_internal() to dynamic locking specification
|
|
Commit Message
Dmitry Osipenko
Nov. 10, 2022, 8:13 p.m. UTC
When userspace mmaps dma-buf's fd, the dma-buf reservation lock must be
held. Add locking sanity check to the dma-buf mmaping callback to ensure
that the locking assumption won't regress in the future.
Suggested-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
drivers/dma-buf/udmabuf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 2bcdb935a3ac..283816fbd72f 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -2,6 +2,7 @@ #include <linux/cred.h> #include <linux/device.h> #include <linux/dma-buf.h> +#include <linux/dma-resv.h> #include <linux/highmem.h> #include <linux/init.h> #include <linux/kernel.h> @@ -49,6 +50,8 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma) { struct udmabuf *ubuf = buf->priv; + dma_resv_assert_held(buf->resv); + if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) return -EINVAL;