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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 18 Aug 2020 11:54:15 -0700
From:   Elliot Berman <eberman@...eaurora.org>
To:     Sebastian Reichel <sre@...nel.org>,
        Andy Yan <andy.yan@...k-chips.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Andy Gross <agross@...nel.org>,
        Rob Herring <robh+dt@...nel.org>
Cc:     Elliot Berman <eberman@...eaurora.org>, linux-pm@...r.kernel.org,
        linux-arm-msm@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, Trilok Soni <tsoni@...eaurora.org>,
        Prasad Sodagudi <psodagud@...eaurora.org>
Subject: [RESEND PATCH v1 3/4] power: reset: Add support for reboot mode alternate properties

Reboot mode driver does not currently support reboot commands with
spaces in them [1]. Add an optional new node "reboot-mode-names" and
"reboot-mode-magic" which add an array of strings and u32s, respectively
which would permit any string in this framework.

Signed-off-by: Elliot Berman <eberman@...eaurora.org>
---
 drivers/power/reset/reboot-mode.c | 42 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index b4076b1..363734d 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -64,8 +64,9 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
 	struct mode_info *info;
 	struct property *prop;
 	struct device_node *np = reboot->dev->of_node;
+	const char *mode_name;
 	size_t len = strlen(PREFIX);
-	int ret;
+	int ret, count, i;
 
 	INIT_LIST_HEAD(&reboot->head);
 
@@ -101,6 +102,45 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
 		list_add_tail(&info->list, &reboot->head);
 	}
 
+	count = of_property_count_u32_elems(np, "reboot-mode-magic");
+	for (i = 0; i < count; i++) {
+		info = devm_kzalloc(reboot->dev, sizeof(*info), GFP_KERNEL);
+		if (!info) {
+			ret = -ENOMEM;
+			goto error;
+		}
+
+		if (of_property_read_string_index(np, "reboot-mode-names", i,
+						  &mode_name)) {
+			dev_err(reboot->dev, "unable to read reboot-mode-names[%d]\n",
+				i);
+			ret = -EINVAL;
+			goto error;
+		}
+		info->mode = kstrdup_const(mode_name, GFP_KERNEL);
+		if (!info->mode) {
+			ret = -ENOMEM;
+			goto error;
+		} else if (info->mode[0] == '\0') {
+			dev_err(reboot->dev, "invalid reboot-mode-names[%d]: too short!\n",
+				i);
+			kfree_const(info->mode);
+			ret = -EINVAL;
+			goto error;
+		}
+
+		if (of_property_read_u32_index(np, "reboot-mode-magic", i,
+					       &info->magic)) {
+			dev_err(reboot->dev, "unable to read reboot-mode-magic[%d]\n",
+				i);
+			kfree_const(info->mode);
+			ret = -EINVAL;
+			goto error;
+		}
+
+		list_add_tail(&info->list, &reboot->head);
+	}
+
 	reboot->reboot_notifier.notifier_call = reboot_mode_notify;
 	register_reboot_notifier(&reboot->reboot_notifier);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ