mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Bernard Zhao <bernard@vivo.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Valentin Schneider <vschneid@redhat.com>,
	linux-kernel@vger.kernel.org, zhaojunkui2008@126.com
Subject: Re: [PATCH] kernel/sched: fix KMSAN uninit-value error
Date: Mon, 5 Sep 2022 11:14:27 -0400	[thread overview]
Message-ID: <20220905111427.57d3262b@gandalf.local.home> (raw)
In-Reply-To: <20220905023715.1920088-1-bernard@vivo.com>

On Sun,  4 Sep 2022 19:37:14 -0700
Bernard Zhao <bernard@vivo.com> wrote:

> syzbot link:
> https://syzkaller.appspot.com/bug?id=d04c5407207d11e46007775517b97764174bc45d
> 
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>  kernel/sched/psi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index ecb4b4ff4ce0..46f048121520 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
> @@ -195,6 +195,9 @@ static void group_init(struct psi_group *group)
>  	init_waitqueue_head(&group->poll_wait);
>  	timer_setup(&group->poll_timer, poll_timer_fn, 0);
>  	rcu_assign_pointer(group->poll_task, NULL);
> +	memset(group->avg_total, 0, sizeof(group->avg_total));
> +	memset(group->total, 0, sizeof(group->total));
> +	memset(group->avg, 0, sizeof(group->avg));
>  }

group_init() is only called in two places. One for a static variable which
will already have all the non-set fields initialized to zero. The other can
have kmalloc() converted to kzalloc() and not worry about zeroing any of
the fields in initialization.

-- Steve

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index ec66b40bdd40..00d62681ea6a 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -957,7 +957,7 @@ int psi_cgroup_alloc(struct cgroup *cgroup)
 	if (static_branch_likely(&psi_disabled))
 		return 0;
 
-	cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL);
+	cgroup->psi = kzalloc(sizeof(struct psi_group), GFP_KERNEL);
 	if (!cgroup->psi)
 		return -ENOMEM;
 

      parent reply	other threads:[~2022-09-05 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05  2:37 Bernard Zhao
2022-09-05  6:41 ` Chengming Zhou
2022-09-05  7:12   ` 答复: " 赵军奎
2022-09-05 15:14 ` Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220905111427.57d3262b@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=bernard@vivo.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=surenb@google.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=zhaojunkui2008@126.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®