Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9294666rwb; Thu, 24 Nov 2022 10:34:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6QV56qIH7LoF5mMXji2PgDV23ObKvs6IveBPvpG6nJ5hgoN1BINnZ2UeiySIXon95z7iFp X-Received: by 2002:a65:58ca:0:b0:470:2c91:9579 with SMTP id e10-20020a6558ca000000b004702c919579mr12478361pgu.22.1669314860919; Thu, 24 Nov 2022 10:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669314860; cv=none; d=google.com; s=arc-20160816; b=yFk3+2R3w3zB9e3c8jBDf9kFaZDHVQ9TIAHstzxEPu9miLG5rbGx8RRcj+N2ChJP3E JuBnnOvhowc5KdL5RLKC6f2tWMx0uSeIw+oZv6TZtz6gdNfwTFBv4f0SRs47DRofGYFS ItMTCYt53fmJ1fzmFUBprVm5SJaEE7XZYIMO+Zm322uV5liHJ7+eUplIi3WKZ4Qp02Fr jhIlZULynstikje6qnQxO6VbQMe9XEJJJIB37qbRAJjbFyPI9XlTaZAYRpYBIVd/S+sx LbcCYrIExAhflK+grz3XhTgJMAcoak4SX64qnXSXZxlB4/pLixSQTWMxlTGiBcIuvR5+ FaVg== 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=WwNxnTC0a1IPalPxtww27IAv5/GUzCtpz/69xMVLEK0=; b=DbpULr/Lk85Ol7u3Eg+RcfeaJ3MO/mabfPidM7Of2vEzR+pNPN50F8dGgz1FBw1lMA /lYfOGP6tp4gyuJVhSOypS3J/DOu8goT3YMlagHe10hNo+DDNjdFO4Ffw6hcujUm4JXN tnqrsQeBMZ3kipEuoUeP4AGE3/nwog0EcLfSCUE/5ZzJmZjLWmJi6mZg6wKMxagHQTwC blzLW9BjIZC6OJDa4wbRJH0elx0rjxKbZXAnOxjOPEIopTnhXjNaTaaSYgXpqrEB9JpU KeAn01lIIFSIa6Ej9UFn5P0zJi6xvOP7NGQmSTSqNluoEmFqqjrZTK0U7nBvhouHU9q6 ufkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="elT90pt/"; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a170902c11100b00178386d88c6si1498048pli.186.2022.11.24.10.34.09; Thu, 24 Nov 2022 10:34:20 -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=@linaro.org header.s=google header.b="elT90pt/"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbiKXRvn (ORCPT + 87 others); Thu, 24 Nov 2022 12:51:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiKXRvk (ORCPT ); Thu, 24 Nov 2022 12:51:40 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B34C1F77 for ; Thu, 24 Nov 2022 09:51:40 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id b12so3486028wrn.2 for ; Thu, 24 Nov 2022 09:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WwNxnTC0a1IPalPxtww27IAv5/GUzCtpz/69xMVLEK0=; b=elT90pt/B9VByyHA/3c/7e0czDBA6h96oQ6bzTZ/E9XFY5M5gxv23hxIUyh1QQlesE XyImgwvR/6oqSjKG9BccPVC2jGn8ywdqpAHBAwLj8gM38e7X9x58gUnuXOqPLclOV6G1 rl/DVSU+/7TUojQHXwd2q4ZJ9f114gOGY5KFD2rfI2HYx/4/Mpp2xnV8cxDFeEVzwr8y 2wknpZruJkzTsp31lunPCOpw5J7lZ24I6SrWxkchpOI0VrFQX0kUphdaXAPEdgaBbKul MqUZMDAnWtUyVTn6lOQMw44l+t7FIctgohnuadps0ZbN12Y8R7vEBEBPgQSeTiiJYJbV MB/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WwNxnTC0a1IPalPxtww27IAv5/GUzCtpz/69xMVLEK0=; b=1rvIhUiFkTDShSi9+bSS7LVVW/1DOqBHFNyeiWEZLJyUrLQDPI9X3VyzOTsbTpkxgd 7M7yKCNHBjO/8GUGXmUdVzYBKRF5d30vXBwAiZXXbxmbgheasRySuLBvxRhLDVcN8sIQ Toi+thDq5MWAzU3LayVBrT5qfb9yRJpzXQPAveV+aVpOO+V/m917P2idtsl0ik/VgilC Jfw/MC0ByNLcVAXSD/B1GXPg8soH27pZk8pdvHYrjhjrSkRIJbGcAy3RWfqECV2hicmF 25DCg3jbAnndSIfMq1r8NaTfqCPySHJPj6Z5zDp5UiiRq3EgOPLxhMhf/Umbt+o8Gmvz 2UmA== X-Gm-Message-State: ANoB5plmS4ZNhGCNFpTB18qUOqVwTuvUTAPlE749x1u5cwtUY5ObnxxG 7EtnH+9oH8WAAytJEbCiMoMlHBt7lqRtiA== X-Received: by 2002:a5d:4584:0:b0:241:ec41:9f1f with SMTP id p4-20020a5d4584000000b00241ec419f1fmr5453331wrq.162.1669312298504; Thu, 24 Nov 2022 09:51:38 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:37 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Dmitry Osipenko , Daniel Vetter , Srinivas Kandagatla Subject: [PATCH 01/11] misc: fastrpc: Assert held reservation lock for dma-buf mmapping Date: Thu, 24 Nov 2022 17:51:15 +0000 Message-Id: <20221124175125.418702-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> 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,RCVD_IN_DNSWL_NONE, 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 From: Dmitry Osipenko 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 Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 80811e852d8f..c6b9ddaa698b 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -692,6 +693,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.25.1