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>] [day] [month] [year] [list]
Message-ID: <6c4afcdc-fa86-4f0a-a6c1-ec8265190fd0@web.de>
Date: Thu, 26 Sep 2024 15:30:12 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: kernel-janitors@...r.kernel.org, Barret Rhoden <brho@...gle.com>,
 Ben Segall <bsegall@...gle.com>, David Vernet <void@...ifault.com>,
 Dietmar Eggemann <dietmar.eggemann@....com>, Ingo Molnar <mingo@...hat.com>,
 Josh Don <joshdon@...gle.com>, Juri Lelli <juri.lelli@...hat.com>,
 Hao Luo <haoluo@...gle.com>, Mel Gorman <mgorman@...e.de>,
 Peter Zijlstra <peterz@...radead.org>, Steven Rostedt <rostedt@...dmis.org>,
 Tejun Heo <tj@...nel.org>, Valentin Schneider <vschneid@...hat.com>,
 Vincent Guittot <vincent.guittot@...aro.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
 Andrea Righi <andrea.righi@...onical.com>
Subject: [PATCH] sched_ext: Call put_task_struct() only once in
 scx_ops_enable()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Thu, 26 Sep 2024 14:51:07 +0200

A put_task_struct() call was immediately used after a return value check
for a scx_ops_init_task() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 kernel/sched/ext.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 9ee5a9a261cc..4b89ea20e355 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -5091,8 +5091,8 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 		spin_unlock_irq(&scx_tasks_lock);

 		ret = scx_ops_init_task(p, task_group(p), false);
+		put_task_struct(p);
 		if (ret) {
-			put_task_struct(p);
 			spin_lock_irq(&scx_tasks_lock);
 			scx_task_iter_exit(&sti);
 			spin_unlock_irq(&scx_tasks_lock);
@@ -5101,7 +5101,6 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 			goto err_disable_unlock_all;
 		}

-		put_task_struct(p);
 		spin_lock_irq(&scx_tasks_lock);
 	}
 	scx_task_iter_exit(&sti);
--
2.46.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ