On 11/5/2024 13:21, Borislav Petkov wrote:
On Wed, Oct 23, 2024 at 05:21:50PM +0000, Yazen Ghannam wrote:
+static ssize_t smn_value_write(struct file *file, const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ u32 val;
+ int ret;
+
+ ret = kstrtouint_from_user(userbuf, count, 0, &val);
+ if (ret)
+ return ret;
+
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
That looks like a TAINT_CPU_OUT_OF_SPEC to me.
Makes sense.
+ ret = amd_smn_write(debug_node, debug_address, val);
+ if (ret)
+ return ret;
+
+ return count;
+}
+
+DEFINE_SHOW_STORE_ATTRIBUTE(smn_node);
+DEFINE_SHOW_STORE_ATTRIBUTE(smn_address);
+DEFINE_SHOW_STORE_ATTRIBUTE(smn_value);
+
static int amd_cache_roots(void)
{
u16 node, num_nodes = amd_num_nodes();
@@ -180,6 +257,12 @@ static int __init amd_smn_init(void)
if (err)
return err;
+ debugfs_dir = debugfs_create_dir("amd_smn", arch_debugfs_dir);
+
+ debugfs_create_file("node", 0600, debugfs_dir, NULL, &smn_node_fops);
+ debugfs_create_file("address", 0600, debugfs_dir, NULL, &smn_address_fops);
+ debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops);
Can we pls stick this behind a module param which is off by default? I don't
want that crap exposed even in debugfs, by default.
Thx.
Why the worry about it being in debugfs by default?