scheduler: access to variable out of scope in sched_slice()
PATCH 1/1 scheduler: access to variable out of scope in sched_slice()
From: Christian Engelmayer <[email protected]>
Access to local variable lw is aliased by usage of pointer load. Access to pointer load in calc_delta_mine() happens when lw is already out of scope.
--
Reported by static code analysis.
kernel/sched_fair.c renamed from kernel/sched_fair.c.orig +2 -1
@@ -430,12 +430,13 @@ static u64 sched_slice(struct cfs_rq *cffor_each_sched_entity (se) {struct load_weight *load; +struct load_weight lw; cfs_rq =cfs_rq_of (se); load = &cfs_rq->load;if (unlikely (!se->on_rq)) { -struct load_weight lw = cfs_rq->load; + lw = cfs_rq->load;update_load_add (&lw, se->load.weight); load = &lw;
Quoted 16 lines · Christian Engelmayer
From: Christian Engelmayer <[email protected]>
Access to local variable lw is aliased by usage of pointer load. Access to pointer load in
calc_delta_mine()happens when lw is already out of scope.Signed-off-by Christian Engelmayer <[email protected]>--
Reported by static code analysis.kernel/sched_fair.c renamed from kernel/sched_fair.c.orig +1
-0@@ -430,12 +430,13 @@ static u64 sched_slice(struct cfs_rq *cffor_each_sched_entity (se) {struct load_weight *load; +struct load_weight lw;
kernel/sched_fair.c static u64 sched_slice(struct cfs_rq *cf · line 442
Quoted 10 lines
kernel/sched_fair.c renamed from kernel/sched_fair.c.orig +1
-1cfs_rq =cfs_rq_of (se); load = &cfs_rq->load;if (unlikely (!se->on_rq)) { -struct load_weight lw = cfs_rq->load; + lw = cfs_rq->load;update_load_add (&lw, se->load.weight); load = &lw;
Good one!
I suspect it doesnt matter in practice because GCC will just have them all on the same stack frame?
Ingo
[tip:sched/urgent] sched: Fix out of scope variable access in sched_slice()
In reply to Christian EngelmayerCommit-ID: 3104bf03a923c72043a9c5009d9cd56724304916 Gitweb: http://git.kernel.org/tip/3104bf03a923c72043a9c5009d9cd56724304916 Author: Christian Engelmayer <[email protected]> AuthorDate: Tue, 16 Jun 2009 10:35:12 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Jun 2009 18:37:54 +0200
sched: Fix out of scope variable access in sched_slice()
Access to local variable lw is aliased by usage of pointer load. Access to pointer load in calc_delta_mine() happens when lw is already out of scope.
[ Reported by static code analysis. ]
LKML-Reference: <[email protected]>
--- kernel/sched_fair.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/sched_fair.c +2 -1
@@ -430,12 +430,13 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)for_each_sched_entity (se) {struct load_weight *load; +struct load_weight lw; cfs_rq =cfs_rq_of (se); load = &cfs_rq->load;if (unlikely (!se->on_rq)) { -struct load_weight lw = cfs_rq->load; + lw = cfs_rq->load;update_load_add (&lw, se->load.weight); load = &lw;