From: Tony Luck <tony.luck@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Xiaochen Shen <xiaochen.shen@intel.com>,
Tony Luck <tony.luck@intel.com>,
linux-kernel@vger.kernel.org,
Vikas Shivappa <vikas.shivappa@linux.intel.com>,
Fenghua Yu <fenghua.yu@intel.com>
Subject: [PATCH] x86/intel_rdt: Fix a silent failure when writing zero value schemata
Date: Fri, 10 Nov 2017 11:16:24 -0800 [thread overview]
Message-ID: <20171110191624.20280-1-tony.luck@intel.com> (raw)
From: Xiaochen Shen <xiaochen.shen@intel.com>
When writing an invalid schemata with no domain values (e.g., "(L3|MB):"), we
get a silent failure.
There isn't a good reason to allow writing zero value, we'd better
return error and set diagnostics information in last_cmd_status.
1. 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
2. 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 zero 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>
---
[apply to TIP x86/cache]
arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 5 +++++
1 file changed, 5 insertions(+)
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,
ret = -EINVAL;
goto out;
}
+ if (tok[0] == '\0') {
+ rdt_last_cmd_printf("Missing '%s' value\n", resname);
+ ret = -EINVAL;
+ goto out;
+ }
ret = rdtgroup_parse_resource(resname, tok, closid);
if (ret)
goto out;
--
2.14.1
next reply other threads:[~2017-11-10 19:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 19:16 Tony Luck [this message]
2017-11-12 8:04 ` [tip:x86/cache] " tip-bot for Xiaochen Shen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171110191624.20280-1-tony.luck@intel.com \
--to=tony.luck@intel.com \
--cc=fenghua.yu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=vikas.shivappa@linux.intel.com \
--cc=xiaochen.shen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome