The variable group in sched_domain_debug_one() is not checked
when firstly used in cpumask_test_cpu(cpu, sched_group_span(group)),
but it maybe NULL(checked later in the following while loop) and may
cause NULL pointer dereference without checking. We need to check it
before using to avoid NULL dereference.
Signed-off-by: Yi Wang <[email protected]>
Reviewed-by: Jiang Biao <[email protected]>
---
kernel/sched/topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 5ac724b..c7cf87c 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -53,7 +53,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
printk(KERN_ERR "ERROR: domain->span does not contain "
"CPU%d\n", cpu);
}
- if (!cpumask_test_cpu(cpu, sched_group_span(group))) {
+ if (group && !cpumask_test_cpu(cpu, sched_group_span(group))) {
printk(KERN_ERR "ERROR: domain->groups does not contain"
" CPU%d\n", cpu);
}
--
1.8.3.1
On Mon, Jul 23, 2018 at 12:19:07PM +0800, Yi Wang wrote:
> The variable group in sched_domain_debug_one() is not checked
> when firstly used in cpumask_test_cpu(cpu, sched_group_span(group)),
> but it maybe NULL(checked later in the following while loop) and may
> cause NULL pointer dereference without checking. We need to check it
> before using to avoid NULL dereference.
It being NULL really is a fairly severe error in construction; but sure.
This patch won't hurt.
> Signed-off-by: Yi Wang <[email protected]>
> Reviewed-by: Jiang Biao <[email protected]>
> ---
> kernel/sched/topology.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 5ac724b..c7cf87c 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -53,7 +53,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
> printk(KERN_ERR "ERROR: domain->span does not contain "
> "CPU%d\n", cpu);
> }
> - if (!cpumask_test_cpu(cpu, sched_group_span(group))) {
> + if (group && !cpumask_test_cpu(cpu, sched_group_span(group))) {
> printk(KERN_ERR "ERROR: domain->groups does not contain"
> " CPU%d\n", cpu);
> }
> --
> 1.8.3.1
>
Commit-ID: 6cd0c583b04b2bd9415e07b51b63ab799949dd66
Gitweb: https://git.kernel.org/tip/6cd0c583b04b2bd9415e07b51b63ab799949dd66
Author: Yi Wang <[email protected]>
AuthorDate: Mon, 23 Jul 2018 12:19:07 +0800
Committer: Ingo Molnar <[email protected]>
CommitDate: Wed, 25 Jul 2018 11:25:07 +0200
sched/topology: Check variable group before dereferencing it
The 'group' variable in sched_domain_debug_one() is not checked
when firstly used in cpumask_test_cpu(cpu, sched_group_span(group)),
but it might be NULL (it is checked later in the following while loop)
and may cause NULL pointer dereference.
We need to check it before using to avoid NULL dereference.
Signed-off-by: Yi Wang <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Jiang Biao <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
kernel/sched/topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 05a831427bc7..56a0fed30c0a 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -47,7 +47,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) {
printk(KERN_ERR "ERROR: domain->span does not contain CPU%d\n", cpu);
}
- if (!cpumask_test_cpu(cpu, sched_group_span(group))) {
+ if (group && !cpumask_test_cpu(cpu, sched_group_span(group))) {
printk(KERN_ERR "ERROR: domain->groups does not contain CPU%d\n", cpu);
}