[PATCH 4/4] kcsan, debugfs: avoid updating white/blacklist with the same value

ran xiaokai posted 4 patches 2 months ago
[PATCH 4/4] kcsan, debugfs: avoid updating white/blacklist with the same value
Posted by ran xiaokai 2 months ago
From: Ran Xiaokai <ran.xiaokai@zte.com.cn>

When userspace passes a same white/blacklist value as it for now,
the update is actually not necessary.

Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
---
 kernel/kcsan/debugfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/kcsan/debugfs.c b/kernel/kcsan/debugfs.c
index d5e624c37125..6b05115d5b73 100644
--- a/kernel/kcsan/debugfs.c
+++ b/kernel/kcsan/debugfs.c
@@ -142,6 +142,9 @@ static ssize_t set_report_filterlist_whitelist(bool whitelist)
 	old_list = rcu_dereference_protected(rp_flist,
 					   lockdep_is_held(&rp_flist_mutex));
 
+	if (old_list->whitelist == whitelist)
+		goto out;
+
 	new_list = kzalloc(sizeof(*new_list), GFP_KERNEL);
 	if (!new_list) {
 		ret = -ENOMEM;
-- 
2.15.2
Re: [PATCH 4/4] kcsan, debugfs: avoid updating white/blacklist with the same value
Posted by Marco Elver 1 month, 4 weeks ago
On Wed, 25 Sept 2024 at 16:32, ran xiaokai <ranxiaokai627@163.com> wrote:
>
> From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
>
> When userspace passes a same white/blacklist value as it for now,
> the update is actually not necessary.
>
> Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> ---
>  kernel/kcsan/debugfs.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kernel/kcsan/debugfs.c b/kernel/kcsan/debugfs.c
> index d5e624c37125..6b05115d5b73 100644
> --- a/kernel/kcsan/debugfs.c
> +++ b/kernel/kcsan/debugfs.c
> @@ -142,6 +142,9 @@ static ssize_t set_report_filterlist_whitelist(bool whitelist)
>         old_list = rcu_dereference_protected(rp_flist,
>                                            lockdep_is_held(&rp_flist_mutex));
>
> +       if (old_list->whitelist == whitelist)
> +               goto out;

Why is this in this patch? It seems like it could just be in the previous one.