lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1413474876-28544-4-git-send-email-a.motakis@virtualopensystems.com>
Date:	Thu, 16 Oct 2014 17:54:35 +0200
From:	Antonios Motakis <a.motakis@...tualopensystems.com>
To:	kvmarm@...ts.cs.columbia.edu, iommu@...ts.linux-foundation.org,
	alex.williamson@...hat.com
Cc:	tech@...tualopensystems.com, christoffer.dall@...aro.org,
	eric.auger@...aro.org, kim.phillips@...escale.com,
	Antonios Motakis <a.motakis@...tualopensystems.com>,
	kvm@...r.kernel.org (open list:VFIO DRIVER),
	linux-kernel@...r.kernel.org (open list)
Subject: [RFC PATCH v2 3/4] vfio: platform: devtree: access property as a list of strings

Certain device tree properties (e.g. the device node name, the compatible
string), are available as a list of strings (separated by the null
terminating character). Let the VFIO user query this type of properties.

Signed-off-by: Antonios Motakis <a.motakis@...tualopensystems.com>
---
 drivers/vfio/platform/devtree.c | 43 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/platform/devtree.c b/drivers/vfio/platform/devtree.c
index 032ee16..6d25f97 100644
--- a/drivers/vfio/platform/devtree.c
+++ b/drivers/vfio/platform/devtree.c
@@ -45,11 +45,52 @@ static int devtree_get_prop_list(struct device_node *np, unsigned *lenp,
 	return ret;
 }
 
+static int devtree_get_full_name(struct device_node *np, unsigned *lenp,
+				 void __user *datap, unsigned long datasz)
+{
+	int len = strlen(np->full_name) + 1;
+
+	if (lenp)
+		*lenp = len;
+
+	if (len > datasz)
+		return -EAGAIN;
+
+	if (copy_to_user(datap, np->full_name, len))
+		return -EFAULT;
+
+	return 0;
+}
+
 static int devtree_get_strings(struct device_node *np,
 			       char *name, unsigned *lenp,
 			       void __user *datap, unsigned long datasz)
 {
-	return -EINVAL;
+	struct property *prop;
+	int len;
+
+	prop = of_find_property(np, name, &len);
+
+	if (!prop) {
+		/* special case full_name as a property that is not on the fdt,
+		 * but we wish to return to the user as it includes the full
+		 * path of the device */
+		if (!strcmp(name, "full_name"))
+			return devtree_get_full_name(np, lenp, datap, datasz);
+		else
+			return -EINVAL;
+	}
+
+	if (lenp)
+		*lenp = len;
+
+	if (len > datasz)
+		return -EAGAIN;
+
+	if (copy_to_user(datap, prop->value, len))
+		return -EFAULT;
+
+	return 0;
 }
 
 static int devtree_get_uint(struct device_node *np, char *name,
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ