aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiaochen Shen <xiaochen.shen@intel.com>2017-11-10 14:16:24 -0500
committerThomas Gleixner <tglx@linutronix.de>2017-11-12 03:01:40 -0500
commit2244645ab194fe45ffcbaa08f235c8f0c7fb54fc (patch)
treebc04fef616b292f1e3c31d43d75dcb307bf197b1
parent87943db7dfb0c5ee5aa74a9ac06346fadd9695c8 (diff)
x86/intel_rdt: Fix a silent failure when writing zero value schemata
Writing an invalid schemata with no domain values (e.g., "(L3|MB):"), results in a silent failure, i.e. the last_cmd_status returns OK, Check for an empty value and set the result string with a proper error message and return -EINVAL. Before the fix: # mkdir /sys/fs/resctrl/p1 # echo "L3:" > /sys/fs/resctrl/p1/schemata (silent failure) # cat /sys/fs/resctrl/info/last_cmd_status ok # echo "MB:" > /sys/fs/resctrl/p1/schemata (silent failure) # cat /sys/fs/resctrl/info/last_cmd_status ok After the fix: # mkdir /sys/fs/resctrl/p1 # echo "L3:" > /sys/fs/resctrl/p1/schemata -bash: echo: write error: Invalid argument # cat /sys/fs/resctrl/info/last_cmd_status Missing 'L3' value # echo "MB:" > /sys/fs/resctrl/p1/schemata -bash: echo: write error: Invalid argument # cat /sys/fs/resctrl/info/last_cmd_status Missing 'MB' value [ Tony: This is an unintended side effect of the patch earlier to allow the user to just write the value they want to change. While allowing user to specify less than all of the values, it also allows an empty value. ] Fixes: c4026b7b95a4 ("x86/intel_rdt: Implement "update" mode when writing schemata file") Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Vikas Shivappa <vikas.shivappa@linux.intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Link: https://lkml.kernel.org/r/20171110191624.20280-1-tony.luck@intel.com
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
index 30aeb267cbd2..23e1d5c249c6 100644
--- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
@@ -257,6 +257,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
257 ret = -EINVAL; 257 ret = -EINVAL;
258 goto out; 258 goto out;
259 } 259 }
260 if (tok[0] == '\0') {
261 rdt_last_cmd_printf("Missing '%s' value\n", resname);
262 ret = -EINVAL;
263 goto out;
264 }
260 ret = rdtgroup_parse_resource(resname, tok, closid); 265 ret = rdtgroup_parse_resource(resname, tok, closid);
261 if (ret) 266 if (ret)
262 goto out; 267 goto out;