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]
Message-Id: <20241127134256.2254851-6-mike.leach@linaro.org>
Date: Wed, 27 Nov 2024 13:42:52 +0000
From: Mike Leach <mike.leach@...aro.org>
To: linux-arm-kernel@...ts.infradead.org,
	coresight@...ts.linaro.org,
	linux-kernel@...r.kernel.org
Cc: suzuki.poulose@....com,
	james.clark@....com,
	Mike Leach <mike.leach@...aro.org>
Subject: [PATCH v7 5/9] coresight: configfs: Add attributes for unload operations

Add attributes to view last loaded configuration, and to unload
last loaded configuration, if it was loaded as a dynamic config table.

Signed-off-by: Mike Leach <mike.leach@...aro.org>
---
 .../coresight/coresight-syscfg-configfs.c     | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c b/drivers/hwtracing/coresight/coresight-syscfg-configfs.c
index 83da4820be6d..d7883fe802b5 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c
+++ b/drivers/hwtracing/coresight/coresight-syscfg-configfs.c
@@ -790,9 +790,71 @@ static void cscfg_destroy_feature_group(struct config_group *feat_group)
 	kfree(feat_view);
 }
 
+/* Attributes in configfs that allow load and unload of configuration tables */
+
+static ssize_t
+cscfg_cfg_unload_last_table_store(struct config_item *item, const char *page, size_t count)
+{
+	int err;
+	unsigned long val;
+
+	err = kstrtoul(page, 0, &val);
+	if (err)
+		return err;
+
+	if (val > 0) {
+		/* schedule unload of last dynamic loaded configuration */
+		err = cscfg_sched_dyn_unload_cfg_table();
+		if (!err)
+			err = count;
+	} else
+		err = -EINVAL;
+
+	return err;
+}
+CONFIGFS_ATTR_WO(cscfg_cfg_, unload_last_table);
+
+static ssize_t cscfg_cfg_show_last_load_show(struct config_item *item, char *page)
+{
+	struct cscfg_load_owner_info *owner_info = 0;
+	ssize_t size = 0;
+
+	/* ensure we cannot read last load while loading / unloading */
+	if (!mutex_trylock(&cfs_mutex))
+		return -EBUSY;
+
+	/* check dyn load / unload ops are permitted & no ongoing unload */
+	if (!cscfg_load_ops_permitted()) {
+		size = -EBUSY;
+		goto exit_unlock;
+	}
+
+	/* find the last loaded owner info block */
+	owner_info = cscfg_find_last_loaded_cfg_owner();
+	if (!owner_info) {
+		size = scnprintf(page, PAGE_SIZE,
+				 "Failed to find any loaded configuration\n");
+		goto exit_unlock;
+	}
+
+	/* get string desc of last unload configuration from owner info */
+	size = cscfg_get_owner_info_str(owner_info, page, PAGE_SIZE);
+
+exit_unlock:
+	mutex_unlock(&cfs_mutex);
+	return size;
+}
+CONFIGFS_ATTR_RO(cscfg_cfg_, show_last_load);
+
+static struct configfs_attribute *cscfg_config_configfs_attrs[] = {
+	&cscfg_cfg_attr_unload_last_table,
+	&cscfg_cfg_attr_show_last_load,
+	NULL,
+};
 
 static struct config_item_type cscfg_configs_load_type = {
 	.ct_owner = THIS_MODULE,
+	.ct_attrs = cscfg_config_configfs_attrs,
 };
 
 /* configurations group */
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ