hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDA7PH -------------------------------- Currently, resctrl lacks validation for the effectiveness of mount parameter during mounting. For example, when ACPI does not report L2 information, mounting with the -o l2 parameter can succeed, but L2 resources cannot actually be controlled, which may cause confusion for users. Add necessary validation for the legality of resctrl mount parameters to prevent successful mounting when the system configuration does not actually support the specified options. Fixes: 13e249bf4944 ("x86/resctrl: Move the filesystem portions of resctrl to live in '/fs/'") Signed-off-by: Quanmin Yan <yanquanmin1@huawei.com> --- fs/resctrl/rdtgroup.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 00e24d052650..cb139678fef0 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2809,6 +2809,7 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) { struct rdt_fs_context *ctx = rdt_fc2context(fc); struct fs_parse_result result; + struct rdt_resource *r; int opt; opt = fs_parse(fc, rdt_fs_parameters, param, &result); @@ -2817,9 +2818,15 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) switch (opt) { case Opt_cdp: + r = resctrl_arch_get_resource(RDT_RESOURCE_L3); + if (!r->alloc_capable) + return -EINVAL; ctx->enable_cdpl3 = true; return 0; case Opt_cdpl2: + r = resctrl_arch_get_resource(RDT_RESOURCE_L2); + if (!r->alloc_capable) + return -EINVAL; ctx->enable_cdpl2 = true; return 0; case Opt_mba_mbps: @@ -2831,6 +2838,9 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) ctx->enable_debug = true; return 0; case Opt_l2: + r = resctrl_arch_get_resource(RDT_RESOURCE_L2); + if (!r->alloc_capable) + return -EINVAL; ctx->enable_l2 = true; return 0; } -- 2.43.0