Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1224858rwb; Thu, 10 Nov 2022 13:03:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf6A69TdYqcHjKFm2wKrSKElrGSow5HFUzPAc6DcOyc+8bHGsNbe1wwKUOTzaJGmVzY4c1u1 X-Received: by 2002:a17:906:58d:b0:7ae:967a:50bb with SMTP id 13-20020a170906058d00b007ae967a50bbmr2881753ejn.383.1668114188584; Thu, 10 Nov 2022 13:03:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668114188; cv=none; d=google.com; s=arc-20160816; b=Hon5oLoRVuWbyKVjtgN2DIM7Xyc/HsJGQtU2ALBPPk9hv9uJABiBJ2V7/v7QVT9o9V FzVKiZ0ATMWKneAcxPUyXyrMJnkkn17a8nlflX5WQqRuJmusN1gBkXpzRenXG0cUqiY2 ZJ1hYFbn5W/XUIxP299wUQcvdL/j1+gyxsGsMMcDA157PDQCRvqHJODn7GrgxdihwSRV CIycWKqm8BzOG7m8i6qOrUHWUQah7s99+vsyL9/arwMJRbOgtr7hSOpOrQZiGLgXf3g0 NJE/9KwgWzBR4rgd4tRpYCo2YOeyNTzdm0DTJftb7/MGLF1OPlM3BkdXvexqDy0HOXPv WlFw== 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=hCWbiCriGeQN9gBElNQbuVMEDFpm5dza9KbMRykwe4M=; b=0dqdOJ4RSPcIIWyLlYriqdOga0Qx3mkHmKnN9uaFI83POTa260Oy/iBSqqwwaqsBT/ HzfNXdxnpgHGvZoX4ubfLNRA6YxA3qKm8pG1h0Q6PB5FEJIwDpM2thc/5nVyJUZrTxGg k8tjMzqbHvdxEvSqC47ep/79U6/A7BnOOe3SSl9q64PNDPJy8FDrVEM4oUokEmToLQvn kWifesIz9bZe3qNlH2EsBdPDSvO1yCrXxjAXgNdeEkQZPgtFrXlmQO7B/p6qu+KWaMJ0 IKUd3vKa0v4wxgTpAc8sxNTLPBcWQUth4FyWhPnywV+S4RZl2+OTtFn6OQqvmc2kG1JQ mFcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=d9Oc6F3W; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he30-20020a1709073d9e00b007ae743c61efsi219897ejc.1002.2022.11.10.13.02.45; Thu, 10 Nov 2022 13:03:08 -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=d9Oc6F3W; 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 S231648AbiKJUPX (ORCPT + 92 others); Thu, 10 Nov 2022 15:15:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbiKJUPJ (ORCPT ); Thu, 10 Nov 2022 15:15:09 -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 3E2D7450BF; Thu, 10 Nov 2022 12:15:03 -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 EC6C06602A5B; Thu, 10 Nov 2022 20:14:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1668111302; bh=ZEwQU+trheBVdqE6TGpypedbCXakkhcZVsK8qA6j2yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d9Oc6F3WYzPj3dGZ0Z8FGnzGG0wYRJFtxJc2Jwu4zZba66Ce7DO9bJCmxxGzdK8sH LmuUGE7hjzRo4MHk9K8Ca3m1dnE+hj+YOFgH2baYj2PR3Ag3vwtX5a8EIuEXFgHw3c oAkeKolGfN/290pp9LzmFPeXSNSgafD6LKaN53mBX2j/WwLTMaoUTPmVjTk0ngxWE4 feWYL0fGcO/o+ri5L/quUnrCH9zfVWruOb279HQQgKSZ4/U4HpDQD+ZeICx5+y1xhs D/06ybLcxJH7/2ILy8VMC5ue8ubgIaXjNOX3iZyDtlyWQmSlm/VL3AaQQBbLYZ821i Mh2baW/JznNPQ== From: Dmitry Osipenko To: Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Benjamin Gaignard , Liam Mark , Brian Starkey , John Stultz , Gerd Hoffmann , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Thomas Zimmermann , Tomi Valkeinen , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Srinivas Kandagatla , Amol Maheshwari 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 6/6] fastrpc: Assert held reservation lock for dma-buf mmapping Date: Thu, 10 Nov 2022 23:13:49 +0300 Message-Id: <20221110201349.351294-7-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: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Dmitry Osipenko --- drivers/misc/fastrpc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 1ad580865525..0f467a71b069 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -682,6 +683,8 @@ static int fastrpc_mmap(struct dma_buf *dmabuf, struct fastrpc_buf *buf = dmabuf->priv; size_t size = vma->vm_end - vma->vm_start; + dma_resv_assert_held(dmabuf->resv); + return dma_mmap_coherent(buf->dev, vma, buf->virt, FASTRPC_PHYS(buf->phys), size); } -- 2.37.3