Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753703AbdLSTnP (ORCPT ); Tue, 19 Dec 2017 14:43:15 -0500 Received: from mga01.intel.com ([192.55.52.88]:17633 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753228AbdLSTg6 (ORCPT ); Tue, 19 Dec 2017 14:36:58 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,428,1508828400"; d="scan'208";a="4018610" From: Dongwon Kim To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, mateuszx.potrola@intel.com, dongwon.kim@intel.com Subject: [RFC PATCH 38/60] hyper_dmabuf: preventing self exporting of dma_buf Date: Tue, 19 Dec 2017 11:29:54 -0800 Message-Id: <1513711816-2618-38-git-send-email-dongwon.kim@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513711816-2618-1-git-send-email-dongwon.kim@intel.com> References: <1513711816-2618-1-git-send-email-dongwon.kim@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 975 Lines: 28 Adding ID check to make sure a dma-buf is exported externally since hyper_dmabuf only allows to export a dmabuf to a different VM. Signed-off-by: Dongwon Kim --- drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c index 12f7ce4..b77b156 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c @@ -103,6 +103,12 @@ static int hyper_dmabuf_export_remote_ioctl(struct file *filp, void *data) export_remote_attr = (struct ioctl_hyper_dmabuf_export_remote *)data; + if (hyper_dmabuf_private.domid == export_remote_attr->remote_domain) { + dev_err(hyper_dmabuf_private.device, + "exporting to the same VM is not permitted\n"); + return -EINVAL; + } + dma_buf = dma_buf_get(export_remote_attr->dmabuf_fd); if (IS_ERR(dma_buf)) { -- 2.7.4