diff options
Diffstat (limited to 'include/linux/fdtable.h')
| -rw-r--r-- | include/linux/fdtable.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index a2ec74bc4812..f59ed297b661 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/rcupdate.h> | 11 | #include <linux/rcupdate.h> |
| 12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
| 13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
| 14 | #include <linux/fs.h> | ||
| 14 | 15 | ||
| 15 | #include <asm/atomic.h> | 16 | #include <asm/atomic.h> |
| 16 | 17 | ||
| @@ -57,7 +58,15 @@ struct files_struct { | |||
| 57 | struct file * fd_array[NR_OPEN_DEFAULT]; | 58 | struct file * fd_array[NR_OPEN_DEFAULT]; |
| 58 | }; | 59 | }; |
| 59 | 60 | ||
| 60 | #define files_fdtable(files) (rcu_dereference((files)->fdt)) | 61 | #define rcu_dereference_check_fdtable(files, fdtfd) \ |
| 62 | (rcu_dereference_check((fdtfd), \ | ||
| 63 | rcu_read_lock_held() || \ | ||
| 64 | lockdep_is_held(&(files)->file_lock) || \ | ||
| 65 | atomic_read(&(files)->count) == 1 || \ | ||
| 66 | rcu_my_thread_group_empty())) | ||
| 67 | |||
| 68 | #define files_fdtable(files) \ | ||
| 69 | (rcu_dereference_check_fdtable((files), (files)->fdt)) | ||
| 61 | 70 | ||
| 62 | struct file_operations; | 71 | struct file_operations; |
| 63 | struct vfsmount; | 72 | struct vfsmount; |
| @@ -78,7 +87,7 @@ static inline struct file * fcheck_files(struct files_struct *files, unsigned in | |||
| 78 | struct fdtable *fdt = files_fdtable(files); | 87 | struct fdtable *fdt = files_fdtable(files); |
| 79 | 88 | ||
| 80 | if (fd < fdt->max_fds) | 89 | if (fd < fdt->max_fds) |
| 81 | file = rcu_dereference(fdt->fd[fd]); | 90 | file = rcu_dereference_check_fdtable(files, fdt->fd[fd]); |
| 82 | return file; | 91 | return file; |
| 83 | } | 92 | } |
| 84 | 93 | ||
