Skip to contentSkip to conversation

vfs: fix RCU-lockdep false positive due to /proc access

PATCH New Paul E. McKenney 1 participant 2 messages May 11, 2010 – Jun 17, 2010 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfs: fix RCU-lockdep false positive due to /proc access

If a single-threaded process does a file-descriptor operation, and some other process accesses that same file descriptor via /proc, the current rcu_dereference_check_fdtable() can give a false-positive RCU-lockdep splat due to the reference count being increased by the /proc access after the reference-count check in fget_light() but before the check in rcu_dereference_check_fdtable().

This commit prevents this false positive by checking for a single-threaded process. To avoid #include hell, this commit uses the wrapper for thread_group_empty(current) defined by rcu_my_thread_group_empty() provided in a separate commit.

---
 fdtable.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/fdtable.h +2 -1
index 013dc52..d147461 100644
@@ -61,7 +61,8 @@ struct files_struct {
 	(rcu_dereference_check((fdtfd), \
 			       rcu_read_lock_held() || \
 			       lockdep_is_held(&(files)->file_lock) || \
-			       atomic_read(&(files)->count) == 1))
+			       atomic_read(&(files)->count) == 1 || \
+			       rcu_my_thread_group_empty()))
 
 #define files_fdtable(files) \
 		(rcu_dereference_check_fdtable((files), (files)->fdt))
#1 lore raw

PATCH 1/1 vfs repost: fix RCU-lockdep false positive due to /proc access

If a single-threaded process does a file-descriptor operation, and some other process accesses that same file descriptor via /proc, the current rcu_dereference_check_fdtable() can give a false-positive RCU-lockdep splat due to the reference count being increased by the /proc access after the reference-count check in fget_light() but before the check in rcu_dereference_check_fdtable().

This commit prevents this false positive by checking for a single-threaded process. To avoid #include hell, this commit uses the wrapper for thread_group_empty(current) defined by rcu_my_thread_group_empty() provided in a separate commit.

---
 fdtable.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/fdtable.h +2 -1
index 013dc52..d147461 100644
@@ -61,7 +61,8 @@ struct files_struct {
 	(rcu_dereference_check((fdtfd), \
 			       rcu_read_lock_held() || \
 			       lockdep_is_held(&(files)->file_lock) || \
-			       atomic_read(&(files)->count) == 1))
+			       atomic_read(&(files)->count) == 1 || \
+			       rcu_my_thread_group_empty()))
 
 #define files_fdtable(files) \
 		(rcu_dereference_check_fdtable((files), (files)->fdt))