From: Yafang Shao <laoar.shao@gmail.com> To: Dan Carpenter <dan.carpenter@oracle.com> Cc: kbuild@lists.01.org, kbuild test robot <lkp@intel.com>, kbuild-all@lists.01.org, LKML <linux-kernel@vger.kernel.org>, Peter Zijlstra <peterz@infradead.org> Subject: Re: [peterz-queue:sched/core 13/19] kernel/sched/debug.c:453 print_cfs_group_stats() warn: variable dereferenced before check 'se' (see line 444) Date: Mon, 13 Sep 2021 19:04:14 +0800 [thread overview] Message-ID: <CALOAHbBqZ5MgQ958ZG2ne4T5xXw0YjcO2aKutGgS6WX2_+vYew@mail.gmail.com> (raw) In-Reply-To: <202109111001.XChyxkS3-lkp@intel.com> On Mon, Sep 13, 2021 at 4:48 PM Dan Carpenter <dan.carpenter@oracle.com> wrote: > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git sched/core > head: 2dfdb3d20ad50e2ae2cb84cbceb0f0fc75e79e5d > commit: 445d9e8ba05d5e9e4b26956b7fe529223e29d8d1 [13/19] sched: make struct sched_statistics independent of fair sched class > config: x86_64-randconfig-m001-20210910 (attached as .config) > compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@intel.com> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com> > > smatch warnings: > kernel/sched/debug.c:453 print_cfs_group_stats() warn: variable dereferenced before check 'se' (see line 444) > Sorry, my bad. Hi Peter, Could you pls. help amend below change to the original commit ? diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 52b4426414c0..d59f33ac06fe 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -440,11 +440,8 @@ void dirty_sched_domain_sysctl(int cpu) #ifdef CONFIG_FAIR_GROUP_SCHED static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) { - struct sched_statistics __maybe_unused *stats; struct sched_entity *se = tg->se[cpu]; - stats = __schedstats_from_se(se); - #define P(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F) #define P_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld\n", \ #F, (long long)schedstat_val(stats->F)) @@ -460,6 +457,8 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group PN(se->sum_exec_runtime); if (schedstat_enabled()) { + struct sched_statistics *stats = __schedstats_from_se(se); + PN_SCHEDSTAT(wait_start); PN_SCHEDSTAT(sleep_start); PN_SCHEDSTAT(block_start); > vim +/se +453 kernel/sched/debug.c > > 3866e845ed5222 kernel/sched/debug.c Steven Rostedt (Red Hat 2016-02-22 439) > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 440 #ifdef CONFIG_FAIR_GROUP_SCHED > 5091faa449ee0b kernel/sched_debug.c Mike Galbraith 2010-11-30 441 static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 442 { > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 443 struct sched_entity *se = tg->se[cpu]; > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 @444 struct sched_statistics *stats = __schedstats_from_se(se); > ^^ > New unchecked dereference. > > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 445 > 97fb7a0a8944bd kernel/sched/debug.c Ingo Molnar 2018-03-03 446 #define P(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F) > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 447 #define P_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld\n", \ > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 448 #F, (long long)schedstat_val(stats->F)) > 97fb7a0a8944bd kernel/sched/debug.c Ingo Molnar 2018-03-03 449 #define PN(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F)) > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 450 #define PN_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", \ > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 451 #F, SPLIT_NS((long long)schedstat_val(stats->F))) > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 452 > cd126afe838d7e kernel/sched/debug.c Yuyang Du 2015-07-15 @453 if (!se) > ^^^ > The old code assumed "se" can be NULL. > > 18bf2805d9b30c kernel/sched/debug.c Ben Segall 2012-10-04 454 return; > 18bf2805d9b30c kernel/sched/debug.c Ben Segall 2012-10-04 455 > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 456 PN(se->exec_start); > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 457 PN(se->vruntime); > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org > -- Thanks Yafang
WARNING: multiple messages have this Message-ID (diff)
From: Yafang Shao <laoar.shao@gmail.com> To: kbuild-all@lists.01.org Subject: Re: [peterz-queue:sched/core 13/19] kernel/sched/debug.c:453 print_cfs_group_stats() warn: variable dereferenced before check 'se' (see line 444) Date: Mon, 13 Sep 2021 19:04:14 +0800 [thread overview] Message-ID: <CALOAHbBqZ5MgQ958ZG2ne4T5xXw0YjcO2aKutGgS6WX2_+vYew@mail.gmail.com> (raw) In-Reply-To: <202109111001.XChyxkS3-lkp@intel.com> [-- Attachment #1: Type: text/plain, Size: 4723 bytes --] On Mon, Sep 13, 2021 at 4:48 PM Dan Carpenter <dan.carpenter@oracle.com> wrote: > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git sched/core > head: 2dfdb3d20ad50e2ae2cb84cbceb0f0fc75e79e5d > commit: 445d9e8ba05d5e9e4b26956b7fe529223e29d8d1 [13/19] sched: make struct sched_statistics independent of fair sched class > config: x86_64-randconfig-m001-20210910 (attached as .config) > compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@intel.com> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com> > > smatch warnings: > kernel/sched/debug.c:453 print_cfs_group_stats() warn: variable dereferenced before check 'se' (see line 444) > Sorry, my bad. Hi Peter, Could you pls. help amend below change to the original commit ? diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 52b4426414c0..d59f33ac06fe 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -440,11 +440,8 @@ void dirty_sched_domain_sysctl(int cpu) #ifdef CONFIG_FAIR_GROUP_SCHED static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) { - struct sched_statistics __maybe_unused *stats; struct sched_entity *se = tg->se[cpu]; - stats = __schedstats_from_se(se); - #define P(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F) #define P_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld\n", \ #F, (long long)schedstat_val(stats->F)) @@ -460,6 +457,8 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group PN(se->sum_exec_runtime); if (schedstat_enabled()) { + struct sched_statistics *stats = __schedstats_from_se(se); + PN_SCHEDSTAT(wait_start); PN_SCHEDSTAT(sleep_start); PN_SCHEDSTAT(block_start); > vim +/se +453 kernel/sched/debug.c > > 3866e845ed5222 kernel/sched/debug.c Steven Rostedt (Red Hat 2016-02-22 439) > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 440 #ifdef CONFIG_FAIR_GROUP_SCHED > 5091faa449ee0b kernel/sched_debug.c Mike Galbraith 2010-11-30 441 static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 442 { > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 443 struct sched_entity *se = tg->se[cpu]; > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 @444 struct sched_statistics *stats = __schedstats_from_se(se); > ^^ > New unchecked dereference. > > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 445 > 97fb7a0a8944bd kernel/sched/debug.c Ingo Molnar 2018-03-03 446 #define P(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F) > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 447 #define P_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld\n", \ > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 448 #F, (long long)schedstat_val(stats->F)) > 97fb7a0a8944bd kernel/sched/debug.c Ingo Molnar 2018-03-03 449 #define PN(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F)) > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 450 #define PN_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", \ > 445d9e8ba05d5e kernel/sched/debug.c Yafang Shao 2021-09-05 451 #F, SPLIT_NS((long long)schedstat_val(stats->F))) > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 452 > cd126afe838d7e kernel/sched/debug.c Yuyang Du 2015-07-15 @453 if (!se) > ^^^ > The old code assumed "se" can be NULL. > > 18bf2805d9b30c kernel/sched/debug.c Ben Segall 2012-10-04 454 return; > 18bf2805d9b30c kernel/sched/debug.c Ben Segall 2012-10-04 455 > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 456 PN(se->exec_start); > ff9b48c3598732 kernel/sched_debug.c Bharata B Rao 2008-11-10 457 PN(se->vruntime); > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org > -- Thanks Yafang
next prev parent reply other threads:[~2021-09-13 11:04 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-11 2:52 [peterz-queue:sched/core 13/19] kernel/sched/debug.c:453 print_cfs_group_stats() warn: variable dereferenced before check 'se' (see line 444) kernel test robot 2021-09-13 8:47 ` Dan Carpenter 2021-09-13 8:47 ` Dan Carpenter 2021-09-13 11:04 ` Yafang Shao [this message] 2021-09-13 11:04 ` Yafang Shao 2021-09-13 12:02 ` Peter Zijlstra 2021-09-13 12:02 ` Peter Zijlstra
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=CALOAHbBqZ5MgQ958ZG2ne4T5xXw0YjcO2aKutGgS6WX2_+vYew@mail.gmail.com \ --to=laoar.shao@gmail.com \ --cc=dan.carpenter@oracle.com \ --cc=kbuild-all@lists.01.org \ --cc=kbuild@lists.01.org \ --cc=linux-kernel@vger.kernel.org \ --cc=lkp@intel.com \ --cc=peterz@infradead.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.