]> git.baikalelectronics.ru Git - kernel.git/commit
x86/intel_rdt: Fix a silent failure when writing zero value schemata
authorXiaochen Shen <xiaochen.shen@intel.com>
Fri, 10 Nov 2017 19:16:24 +0000 (11:16 -0800)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 12 Nov 2017 08:01:40 +0000 (09:01 +0100)
commit05b383e21bb136aa35bc653be5360a4c68875df6
treebc04fef616b292f1e3c31d43d75dcb307bf197b1
parent10218bfdc3235147091c2cace7572b87df21d14b
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: fb9c1090ba02 ("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
arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c