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-next>] [day] [month] [year] [list]
Message-Id: <20220203133134.6949-1-jandryuk@gmail.com>
Date:   Thu,  3 Feb 2022 08:31:34 -0500
From:   Jason Andryuk <jandryuk@...il.com>
To:     linux-kernel@...r.kernel.org
Cc:     "Eric W . Biederman" <ebiederm@...ssion.com>,
        Cyrill Gorcunov <gorcunov@...il.com>,
        Jason Andryuk <jandryuk@...il.com>
Subject: [PATCH v2] kcmp: Comment get_file_raw_ptr() RCU usage

This usage of RCU appears wrong since the pointer is passed outside the
RCU region.  However, it is only used as a number and not dereferenced,
so it is okay.  Leave a comment for the next reader.

Without a reference, these comparisons are racy, but even with their use
inside an RCU region, the result could go stale.

Signed-off-by: Jason Andryuk <jandryuk@...il.com>
---
v2:
Rephrase comment and tweak commit message.  (Cyrill)

 kernel/kcmp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/kcmp.c b/kernel/kcmp.c
index 5353edfad8e1..04874c7ac0ab 100644
--- a/kernel/kcmp.c
+++ b/kernel/kcmp.c
@@ -63,6 +63,11 @@ get_file_raw_ptr(struct task_struct *task, unsigned int idx)
 {
 	struct file *file;
 
+	/*
+	 * Fetch file pointers inside RCU read-lock section, but
+	 * skip additional locking for speed.  The pointer values
+	 * will be used as integers and must not be dereferenced.
+	 */
 	rcu_read_lock();
 	file = task_lookup_fd_rcu(task, idx);
 	rcu_read_unlock();
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ