summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morell <rmorell@nvidia.com>2010-11-02 10:31:31 -0700
committerNiket Sirsi <nsirsi@nvidia.com>2011-01-28 19:55:11 -0800
commit9c689e66aaf955a838c7477b5671021c154ab037 (patch)
tree58a66e0cc71833ab0dd69670a0a94d6b88b9e7cc
parentcb96d40b1a3665235a564e078a305d0e419266e1 (diff)
nvmap: Optionally check global list for IOC_GET_ID
For NVMAP_IOC_GET_ID, if the requested handle isn't found in the client-private list, check the device-wide handles if allowed (global handles or superuser). The proper way to share memory between clients is to first call IOC_GET_ID from the client who owns the memory, pass the resulting ID to the new client, and then use IOC_FROM_ID in the new client to get a handle. However, some (broken) legacy applications did both IOC_GET_ID and IOC_FROM_ID steps in the new client. To support those applications but hopefully prevent new applications from growing the same behavior, the NVMAP_SEARCH_GLOBAL_HANDLES config option was added that restores the old behavior (default N). Note that even with this option enabled, the client issuing the IOC_GET_ID call must be privileged to access the handle provided. In practice, this means the global list search only works for clients who have opened the /dev/knvmap super device node. Change-Id: I6a4490de922864d9119b24e610cfa127ec64bdc7 Signed-off-by: Robert Morell <rmorell@nvidia.com> Reviewed-on: http://git-master/r/14431 Reviewed-by: Niket Sirsi <nsirsi@nvidia.com> Tested-by: Niket Sirsi <nsirsi@nvidia.com>
-rw-r--r--drivers/video/tegra/Kconfig11
-rw-r--r--drivers/video/tegra/nvmap/nvmap_ioctl.c10
2 files changed, 21 insertions, 0 deletions
diff --git a/drivers/video/tegra/Kconfig b/drivers/video/tegra/Kconfig
index 9968738777fd..c9e5f21a69c2 100644
--- a/drivers/video/tegra/Kconfig
+++ b/drivers/video/tegra/Kconfig
@@ -77,5 +77,16 @@ config NVMAP_CARVEOUT_KILLER
processes. This will kill the largest consumers of lowest priority
first.
+config NVMAP_SEARCH_GLOBAL_HANDLES
+ bool "Check global handle list when generating memory IDs"
+ depends on TEGRA_NVMAP
+ default n
+ help
+ Say Y here to allow the system to search through memory handles not
+ owned by the caller when generating a memory ID. This shouldn't be
+ necessary for well-written applications, but is provided for
+ compatibility with legacy applications.
+ If unsure, say N.
+
endif
diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c
index b943065a44c0..0c772f81ffa8 100644
--- a/drivers/video/tegra/nvmap/nvmap_ioctl.c
+++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c
@@ -143,6 +143,16 @@ int nvmap_ioctl_getid(struct file *filp, void __user *arg)
h = nvmap_get_handle_id(client, op.handle);
+#ifdef CONFIG_NVMAP_SEARCH_GLOBAL_HANDLES
+ /*
+ * Check for device-wide global handles. This may be needed in broken
+ * memory sharing scenarios when handles are passed from client to
+ * client instead of the memory IDs.
+ */
+ if (!h)
+ h = nvmap_validate_get(client, op.handle);
+#endif
+
if (!h)
return -EPERM;