提交 59bf2354 编写于 作者: L Liu Shixin 提交者: Zheng Zengkai

kfence: parse param before alloc kfence_pool

hulk inclusion
category: bugfix
bugzilla: 186414, https://gitee.com/openeuler/kernel/issues/I53YXV
CVE: NA

--------------------------------

Patch 1919867e8bad advanced the allocation of kfence_pool to setup_arch().
Since the macro module_param_cb is parsed after setup_arch(), it's invalid
to set sample_interval and num_objects in cmdline. Add macro early_param
to parse the cmdline to make it effective before the allocation of
kfence_pool.

Fixes: 1919867e8bad ("arm64: remove page granularity limitation from KFENCE")
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 73764f0b
...@@ -86,6 +86,19 @@ static const struct kernel_param_ops sample_interval_param_ops = { ...@@ -86,6 +86,19 @@ static const struct kernel_param_ops sample_interval_param_ops = {
}; };
module_param_cb(sample_interval, &sample_interval_param_ops, &kfence_sample_interval, 0600); module_param_cb(sample_interval, &sample_interval_param_ops, &kfence_sample_interval, 0600);
#ifdef CONFIG_ARM64
static int __init parse_sample_interval(char *str)
{
unsigned long num;
if (kstrtoul(str, 0, &num) < 0)
return 0;
kfence_sample_interval = num;
return 0;
}
early_param("kfence.sample_interval", parse_sample_interval);
#endif
/* Pool usage% threshold when currently covered allocations are skipped. */ /* Pool usage% threshold when currently covered allocations are skipped. */
static unsigned long kfence_skip_covered_thresh __read_mostly = 75; static unsigned long kfence_skip_covered_thresh __read_mostly = 75;
module_param_named(skip_covered_thresh, kfence_skip_covered_thresh, ulong, 0644); module_param_named(skip_covered_thresh, kfence_skip_covered_thresh, ulong, 0644);
...@@ -139,6 +152,21 @@ static const struct kernel_param_ops num_objects_param_ops = { ...@@ -139,6 +152,21 @@ static const struct kernel_param_ops num_objects_param_ops = {
.get = param_get_num_objects, .get = param_get_num_objects,
}; };
module_param_cb(num_objects, &num_objects_param_ops, &kfence_num_objects, 0600); module_param_cb(num_objects, &num_objects_param_ops, &kfence_num_objects, 0600);
#ifdef CONFIG_ARM64
static int __init parse_num_objects(char *str)
{
unsigned long num;
if (kstrtoul(str, 0, &num) < 0)
return 0;
if (num < MIN_KFENCE_OBJECTS || num > MAX_KFENCE_OBJECTS)
return 0;
kfence_num_objects = num;
return 0;
}
early_param("kfence.num_objects", parse_num_objects);
#endif
#endif #endif
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册