From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753852AbdKJTQc (ORCPT ); Fri, 10 Nov 2017 14:16:32 -0500 Received: from mga06.intel.com ([134.134.136.31]:54568 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753610AbdKJTQb (ORCPT ); Fri, 10 Nov 2017 14:16:31 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,375,1505804400"; d="scan'208";a="179609" From: Tony Luck To: Thomas Gleixner Cc: Xiaochen Shen , Tony Luck , linux-kernel@vger.kernel.org, Vikas Shivappa , Fenghua Yu Subject: [PATCH] x86/intel_rdt: Fix a silent failure when writing zero value schemata Date: Fri, 10 Nov 2017 11:16:24 -0800 Message-Id: <20171110191624.20280-1-tony.luck@intel.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaochen Shen 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 Signed-off-by: Tony Luck --- [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