From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753018AbdKLIGQ (ORCPT ); Sun, 12 Nov 2017 03:06:16 -0500 Received: from terminus.zytor.com ([65.50.211.136]:50323 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751323AbdKLIGO (ORCPT ); Sun, 12 Nov 2017 03:06:14 -0500 Date: Sun, 12 Nov 2017 00:04:00 -0800 From: tip-bot for Xiaochen Shen Message-ID: Cc: tony.luck@intel.com, xiaochen.shen@intel.com, fenghua.yu@intel.com, hpa@zytor.com, tglx@linutronix.de, vikas.shivappa@linux.intel.com, linux-kernel@vger.kernel.org, mingo@kernel.org Reply-To: hpa@zytor.com, xiaochen.shen@intel.com, fenghua.yu@intel.com, tony.luck@intel.com, mingo@kernel.org, linux-kernel@vger.kernel.org, vikas.shivappa@linux.intel.com, tglx@linutronix.de In-Reply-To: <20171110191624.20280-1-tony.luck@intel.com> References: <20171110191624.20280-1-tony.luck@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Fix a silent failure when writing zero value schemata Git-Commit-ID: 2244645ab194fe45ffcbaa08f235c8f0c7fb54fc X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2244645ab194fe45ffcbaa08f235c8f0c7fb54fc Gitweb: https://git.kernel.org/tip/2244645ab194fe45ffcbaa08f235c8f0c7fb54fc Author: Xiaochen Shen AuthorDate: Fri, 10 Nov 2017 11:16:24 -0800 Committer: Thomas Gleixner CommitDate: Sun, 12 Nov 2017 09:01:40 +0100 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 Signed-off-by: Tony Luck Signed-off-by: Thomas Gleixner Cc: Vikas Shivappa Cc: Fenghua Yu Link: https://lkml.kernel.org/r/20171110191624.20280-1-tony.luck@intel.com --- 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 30aeb26..23e1d5c 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;