lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 26 Mar 2021 11:15:11 +0800
From:   Zeng Tao <prime.zeng@...ilicon.com>
To:     <mingo@...hat.com>, <peterz@...radead.org>,
        <juri.lelli@...hat.com>, <vincent.guittot@...aro.org>
CC:     <linuxarm@...wei.com>, Zeng Tao <prime.zeng@...ilicon.com>,
        "Dietmar Eggemann" <dietmar.eggemann@....com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
        "Daniel Bristot de Oliveira" <bristot@...hat.com>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH] sched/cpupri: fix the task priority BUG_ON checks

The BUG_ON checks are intended to check if the task priotity is valid,
but in the function convert_prio, if the task priority is not valid, it
will be converted to an uninitialized stack variable. Fix it by moving
the BUG_ON checks to the default branch of convert_prio.

Fixes: 934fc3314b39 ("sched/cpupri: Remap CPUPRI_NORMAL to MAX_RT_PRIO-1")
Signed-off-by: Zeng Tao <prime.zeng@...ilicon.com>
---
 kernel/sched/cpupri.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index ec9be78..c5a0e6e 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -60,6 +60,8 @@ static int convert_prio(int prio)
 	case MAX_RT_PRIO:
 		cpupri = CPUPRI_HIGHER;		/* 100 */
 		break;
+	default:
+		BUG();
 	}
 
 	return cpupri;
@@ -148,8 +150,6 @@ int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p,
 	int task_pri = convert_prio(p->prio);
 	int idx, cpu;
 
-	BUG_ON(task_pri >= CPUPRI_NR_PRIORITIES);
-
 	for (idx = 0; idx < task_pri; idx++) {
 
 		if (!__cpupri_find(cp, p, lowest_mask, idx))
@@ -215,8 +215,6 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri)
 
 	newpri = convert_prio(newpri);
 
-	BUG_ON(newpri >= CPUPRI_NR_PRIORITIES);
-
 	if (newpri == oldpri)
 		return;
 
-- 
2.8.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ