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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <152474044955.29458.13116121113099868575.stgit@localhost.localdomain>
Date:   Thu, 26 Apr 2018 14:00:49 +0300
From:   Kirill Tkhai <ktkhai@...tuozzo.com>
To:     akpm@...ux-foundation.org, peterz@...radead.org, oleg@...hat.com,
        viro@...iv.linux.org.uk, mingo@...nel.org,
        paulmck@...ux.vnet.ibm.com, keescook@...omium.org, riel@...hat.com,
        mhocko@...e.com, tglx@...utronix.de,
        kirill.shutemov@...ux.intel.com, marcos.souza.org@...il.com,
        hoeun.ryu@...il.com, pasha.tatashin@...cle.com, gs051095@...il.com,
        ebiederm@...ssion.com, dhowells@...hat.com,
        rppt@...ux.vnet.ibm.com, linux-kernel@...r.kernel.org,
        ktkhai@...tuozzo.com
Subject: [PATCH 2/4] exit: Use rcu instead of get_task_struct() in
 mm_update_next_owner()

Since release_task() puts final task_struct::usage counter
at least one rcu grace period after removing from task list:

	__exit_signal()
	  __unhash_process()
	call_rcu(&p->rcu, delayed_put_task_struct)

rcu_read_lock() guarantees nobody release task_struct memory.
So, it's possible to use this primitive instead of get_task_struct().

Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
---
 kernel/exit.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 9fb7b699bdeb..5c42a9b9c1d7 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -464,7 +464,7 @@ void mm_update_next_owner(struct mm_struct *mm)
 	return;
 
 assign_new_owner:
-	get_task_struct(c);
+	rcu_read_lock();
 	read_unlock(&tasklist_lock);
 	BUG_ON(c == p);
 
@@ -475,12 +475,12 @@ void mm_update_next_owner(struct mm_struct *mm)
 	task_lock(c);
 	if (c->mm != mm) {
 		task_unlock(c);
-		put_task_struct(c);
+		rcu_read_unlock();
 		goto retry;
 	}
 	mm->owner = c;
 	task_unlock(c);
-	put_task_struct(c);
+	rcu_read_unlock();
 }
 #endif /* CONFIG_MEMCG */
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ