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: <20230612033505.8148-1-zegao@tencent.com>
Date:   Mon, 12 Jun 2023 11:35:05 +0800
From:   Ze Gao <zegao2021@...il.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ben Segall <bsegall@...gle.com>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Ingo Molnar <mingo@...hat.com>,
        Juri Lelli <juri.lelli@...hat.com>,
        Mel Gorman <mgorman@...e.de>,
        Steven Rostedt <rostedt@...dmis.org>,
        Valentin Schneider <vschneid@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        linux-kernel@...r.kernel.org, Ze Gao <zegao@...cent.com>
Subject: [PATCH] sched_fork: Use READ_ONCE() for lockless read of current->normal_prio

The current->normal_prio is locklessly accessed from sched_fork and
child's scheduler related initialization procedures heavily rely on
the value loaded. Thus we mark this load as READ_ONCE in case of
possible load tearing due to concurrent access from other paths, for
example if changes of parent's normal_prio happens to be requested
via some syscall.

Signed-off-by: Ze Gao <zegao@...cent.com>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 944c3ae39861..37a13e4b734d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4699,7 +4699,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
 	/*
 	 * Make sure we do not leak PI boosting priority to the child.
 	 */
-	p->prio = current->normal_prio;
+	p->prio = READ_ONCE(current->normal_prio);
 
 	uclamp_fork(p);
 
-- 
2.40.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ