Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'work.fdtable' into vfs.file

Bring in the fdtable changes for this cycle.

Signed-off-by: Christian Brauner <brauner@kernel.org>

+88 -198
+1 -3
arch/powerpc/platforms/cell/spufs/coredump.c
··· 73 73 return NULL; 74 74 *fd = n - 1; 75 75 76 - rcu_read_lock(); 77 - file = lookup_fdget_rcu(*fd); 78 - rcu_read_unlock(); 76 + file = fget_raw(*fd); 79 77 if (file) { 80 78 ctx = SPUFS_I(file_inode(file))->i_ctx; 81 79 get_spu_context(ctx);
-1
fs/fcntl.c
··· 12 12 #include <linux/fs.h> 13 13 #include <linux/filelock.h> 14 14 #include <linux/file.h> 15 - #include <linux/fdtable.h> 16 15 #include <linux/capability.h> 17 16 #include <linux/dnotify.h> 18 17 #include <linux/slab.h>
+78 -126
fs/file.c
··· 152 152 * 'unsigned long' in some places, but simply because that is how the Linux 153 153 * kernel bitmaps are defined to work: they are not "bits in an array of bytes", 154 154 * they are very much "bits in an array of unsigned long". 155 - * 156 - * The ALIGN(nr, BITS_PER_LONG) here is for clarity: since we just multiplied 157 - * by that "1024/sizeof(ptr)" before, we already know there are sufficient 158 - * clear low bits. Clang seems to realize that, gcc ends up being confused. 159 - * 160 - * On a 128-bit machine, the ALIGN() would actually matter. In the meantime, 161 - * let's consider it documentation (and maybe a test-case for gcc to improve 162 - * its code generation ;) 163 155 */ 164 - static struct fdtable * alloc_fdtable(unsigned int nr) 156 + static struct fdtable *alloc_fdtable(unsigned int slots_wanted) 165 157 { 166 158 struct fdtable *fdt; 159 + unsigned int nr; 167 160 void *data; 168 161 169 162 /* ··· 164 171 * Allocation steps are keyed to the size of the fdarray, since it 165 172 * grows far faster than any of the other dynamic data. We try to fit 166 173 * the fdarray into comfortable page-tuned chunks: starting at 1024B 167 - * and growing in powers of two from there on. 174 + * and growing in powers of two from there on. Since we called only 175 + * with slots_wanted > BITS_PER_LONG (embedded instance in files->fdtab 176 + * already gives BITS_PER_LONG slots), the above boils down to 177 + * 1. use the smallest power of two large enough to give us that many 178 + * slots. 179 + * 2. on 32bit skip 64 and 128 - the minimal capacity we want there is 180 + * 256 slots (i.e. 1Kb fd array). 181 + * 3. on 64bit don't skip anything, 1Kb fd array means 128 slots there 182 + * and we are never going to be asked for 64 or less. 168 183 */ 169 - nr /= (1024 / sizeof(struct file *)); 170 - nr = roundup_pow_of_two(nr + 1); 171 - nr *= (1024 / sizeof(struct file *)); 172 - nr = ALIGN(nr, BITS_PER_LONG); 184 + if (IS_ENABLED(CONFIG_32BIT) && slots_wanted < 256) 185 + nr = 256; 186 + else 187 + nr = roundup_pow_of_two(slots_wanted); 173 188 /* 174 189 * Note that this can drive nr *below* what we had passed if sysctl_nr_open 175 - * had been set lower between the check in expand_files() and here. Deal 176 - * with that in caller, it's cheaper that way. 190 + * had been set lower between the check in expand_files() and here. 177 191 * 178 192 * We make sure that nr remains a multiple of BITS_PER_LONG - otherwise 179 193 * bitmaps handling below becomes unpleasant, to put it mildly... 180 194 */ 181 - if (unlikely(nr > sysctl_nr_open)) 182 - nr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1; 195 + if (unlikely(nr > sysctl_nr_open)) { 196 + nr = round_down(sysctl_nr_open, BITS_PER_LONG); 197 + if (nr < slots_wanted) 198 + return ERR_PTR(-EMFILE); 199 + } 183 200 184 201 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT); 185 202 if (!fdt) ··· 218 215 out_fdt: 219 216 kfree(fdt); 220 217 out: 221 - return NULL; 218 + return ERR_PTR(-ENOMEM); 222 219 } 223 220 224 221 /* 225 222 * Expand the file descriptor table. 226 223 * This function will allocate a new fdtable and both fd array and fdset, of 227 224 * the given size. 228 - * Return <0 error code on error; 1 on successful completion. 225 + * Return <0 error code on error; 0 on successful completion. 229 226 * The files->file_lock should be held on entry, and will be held on exit. 230 227 */ 231 228 static int expand_fdtable(struct files_struct *files, unsigned int nr) ··· 235 232 struct fdtable *new_fdt, *cur_fdt; 236 233 237 234 spin_unlock(&files->file_lock); 238 - new_fdt = alloc_fdtable(nr); 235 + new_fdt = alloc_fdtable(nr + 1); 239 236 240 237 /* make sure all fd_install() have seen resize_in_progress 241 238 * or have finished their rcu_read_lock_sched() section. ··· 244 241 synchronize_rcu(); 245 242 246 243 spin_lock(&files->file_lock); 247 - if (!new_fdt) 248 - return -ENOMEM; 249 - /* 250 - * extremely unlikely race - sysctl_nr_open decreased between the check in 251 - * caller and alloc_fdtable(). Cheaper to catch it here... 252 - */ 253 - if (unlikely(new_fdt->max_fds <= nr)) { 254 - __free_fdtable(new_fdt); 255 - return -EMFILE; 256 - } 244 + if (IS_ERR(new_fdt)) 245 + return PTR_ERR(new_fdt); 257 246 cur_fdt = files_fdtable(files); 258 247 BUG_ON(nr < cur_fdt->max_fds); 259 248 copy_fdtable(new_fdt, cur_fdt); ··· 254 259 call_rcu(&cur_fdt->rcu, free_fdtable_rcu); 255 260 /* coupled with smp_rmb() in fd_install() */ 256 261 smp_wmb(); 257 - return 1; 262 + return 0; 258 263 } 259 264 260 265 /* 261 266 * Expand files. 262 267 * This function will expand the file structures, if the requested size exceeds 263 268 * the current capacity and there is room for expansion. 264 - * Return <0 error code on error; 0 when nothing done; 1 when files were 265 - * expanded and execution may have blocked. 269 + * Return <0 error code on error; 0 on success. 266 270 * The files->file_lock should be held on entry, and will be held on exit. 267 271 */ 268 272 static int expand_files(struct files_struct *files, unsigned int nr) ··· 269 275 __acquires(files->file_lock) 270 276 { 271 277 struct fdtable *fdt; 272 - int expanded = 0; 278 + int error; 273 279 274 280 repeat: 275 281 fdt = files_fdtable(files); 276 282 277 283 /* Do we need to expand? */ 278 284 if (nr < fdt->max_fds) 279 - return expanded; 285 + return 0; 280 286 281 287 /* Can we expand? */ 282 288 if (nr >= sysctl_nr_open) ··· 284 290 285 291 if (unlikely(files->resize_in_progress)) { 286 292 spin_unlock(&files->file_lock); 287 - expanded = 1; 288 293 wait_event(files->resize_wait, !files->resize_in_progress); 289 294 spin_lock(&files->file_lock); 290 295 goto repeat; ··· 291 298 292 299 /* All good, so we try */ 293 300 files->resize_in_progress = true; 294 - expanded = expand_fdtable(files, nr); 301 + error = expand_fdtable(files, nr); 295 302 files->resize_in_progress = false; 296 303 297 304 wake_up_all(&files->resize_wait); 298 - return expanded; 305 + return error; 299 306 } 300 307 301 - static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt) 308 + static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt, 309 + bool set) 302 310 { 303 - __set_bit(fd, fdt->close_on_exec); 311 + if (set) { 312 + __set_bit(fd, fdt->close_on_exec); 313 + } else { 314 + if (test_bit(fd, fdt->close_on_exec)) 315 + __clear_bit(fd, fdt->close_on_exec); 316 + } 304 317 } 305 318 306 - static inline void __clear_close_on_exec(unsigned int fd, struct fdtable *fdt) 307 - { 308 - if (test_bit(fd, fdt->close_on_exec)) 309 - __clear_bit(fd, fdt->close_on_exec); 310 - } 311 - 312 - static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt) 319 + static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt, bool set) 313 320 { 314 321 __set_bit(fd, fdt->open_fds); 322 + __set_close_on_exec(fd, fdt, set); 315 323 fd /= BITS_PER_LONG; 316 324 if (!~fdt->open_fds[fd]) 317 325 __set_bit(fd, fdt->full_fds_bits); ··· 321 327 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) 322 328 { 323 329 __clear_bit(fd, fdt->open_fds); 324 - __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); 330 + fd /= BITS_PER_LONG; 331 + if (test_bit(fd, fdt->full_fds_bits)) 332 + __clear_bit(fd, fdt->full_fds_bits); 325 333 } 326 334 327 335 static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt) ··· 365 369 struct file **old_fds, **new_fds; 366 370 unsigned int open_files, i; 367 371 struct fdtable *old_fdt, *new_fdt; 368 - int error; 369 372 370 373 newf = kmem_cache_alloc(files_cachep, GFP_KERNEL); 371 374 if (!newf) ··· 396 401 if (new_fdt != &newf->fdtab) 397 402 __free_fdtable(new_fdt); 398 403 399 - new_fdt = alloc_fdtable(open_files - 1); 400 - if (!new_fdt) { 401 - error = -ENOMEM; 402 - goto out_release; 403 - } 404 - 405 - /* beyond sysctl_nr_open; nothing to do */ 406 - if (unlikely(new_fdt->max_fds < open_files)) { 407 - __free_fdtable(new_fdt); 408 - error = -EMFILE; 409 - goto out_release; 404 + new_fdt = alloc_fdtable(open_files); 405 + if (IS_ERR(new_fdt)) { 406 + kmem_cache_free(files_cachep, newf); 407 + return ERR_CAST(new_fdt); 410 408 } 411 409 412 410 /* ··· 440 452 rcu_assign_pointer(newf->fdt, new_fdt); 441 453 442 454 return newf; 443 - 444 - out_release: 445 - kmem_cache_free(files_cachep, newf); 446 - return ERR_PTR(error); 447 455 } 448 456 449 457 static struct fdtable *close_files(struct files_struct * files) ··· 460 476 set = fdt->open_fds[j++]; 461 477 while (set) { 462 478 if (set & 1) { 463 - struct file * file = xchg(&fdt->fd[i], NULL); 479 + struct file *file = fdt->fd[i]; 464 480 if (file) { 465 481 filp_close(file, files); 466 482 cond_resched(); ··· 517 533 unsigned int maxfd = fdt->max_fds; /* always multiple of BITS_PER_LONG */ 518 534 unsigned int maxbit = maxfd / BITS_PER_LONG; 519 535 unsigned int bitbit = start / BITS_PER_LONG; 536 + unsigned int bit; 537 + 538 + /* 539 + * Try to avoid looking at the second level bitmap 540 + */ 541 + bit = find_next_zero_bit(&fdt->open_fds[bitbit], BITS_PER_LONG, 542 + start & (BITS_PER_LONG - 1)); 543 + if (bit < BITS_PER_LONG) 544 + return bit + bitbit * BITS_PER_LONG; 520 545 521 546 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; 522 547 if (bitbit >= maxfd) ··· 552 559 if (fd < files->next_fd) 553 560 fd = files->next_fd; 554 561 555 - if (fd < fdt->max_fds) 562 + if (likely(fd < fdt->max_fds)) 556 563 fd = find_next_fd(fdt, fd); 557 564 558 565 /* ··· 560 567 * will limit the total number of files that can be opened. 561 568 */ 562 569 error = -EMFILE; 563 - if (fd >= end) 570 + if (unlikely(fd >= end)) 564 571 goto out; 565 572 566 - error = expand_files(files, fd); 567 - if (error < 0) 568 - goto out; 573 + if (unlikely(fd >= fdt->max_fds)) { 574 + error = expand_files(files, fd); 575 + if (error < 0) 576 + goto out; 569 577 570 - /* 571 - * If we needed to expand the fs array we 572 - * might have blocked - try again. 573 - */ 574 - if (error) 575 578 goto repeat; 579 + } 576 580 577 581 if (start <= files->next_fd) 578 582 files->next_fd = fd + 1; 579 583 580 - __set_open_fd(fd, fdt); 581 - if (flags & O_CLOEXEC) 582 - __set_close_on_exec(fd, fdt); 583 - else 584 - __clear_close_on_exec(fd, fdt); 584 + __set_open_fd(fd, fdt, flags & O_CLOEXEC); 585 585 error = fd; 586 - #if 1 587 - /* Sanity check */ 588 - if (rcu_access_pointer(fdt->fd[fd]) != NULL) { 589 - printk(KERN_WARNING "alloc_fd: slot %d not NULL!\n", fd); 590 - rcu_assign_pointer(fdt->fd[fd], NULL); 591 - } 592 - #endif 593 586 594 587 out: 595 588 spin_unlock(&files->file_lock); ··· 641 662 rcu_read_unlock_sched(); 642 663 spin_lock(&files->file_lock); 643 664 fdt = files_fdtable(files); 644 - BUG_ON(fdt->fd[fd] != NULL); 665 + WARN_ON(fdt->fd[fd] != NULL); 645 666 rcu_assign_pointer(fdt->fd[fd], file); 646 667 spin_unlock(&files->file_lock); 647 668 return; ··· 755 776 } 756 777 757 778 /** 758 - * __close_range() - Close all file descriptors in a given range. 779 + * sys_close_range() - Close all file descriptors in a given range. 759 780 * 760 781 * @fd: starting file descriptor to close 761 782 * @max_fd: last file descriptor to close ··· 763 784 * 764 785 * This closes a range of file descriptors. All file descriptors 765 786 * from @fd up to and including @max_fd are closed. 787 + * Currently, errors to close a given file descriptor are ignored. 766 788 */ 767 - int __close_range(unsigned fd, unsigned max_fd, unsigned int flags) 789 + SYSCALL_DEFINE3(close_range, unsigned int, fd, unsigned int, max_fd, 790 + unsigned int, flags) 768 791 { 769 792 struct task_struct *me = current; 770 793 struct files_struct *cur_fds = me->files, *fds = NULL; ··· 1081 1100 return file; 1082 1101 } 1083 1102 1084 - struct file *lookup_fdget_rcu(unsigned int fd) 1085 - { 1086 - return __fget_files_rcu(current->files, fd, 0); 1087 - 1088 - } 1089 - EXPORT_SYMBOL_GPL(lookup_fdget_rcu); 1090 - 1091 - struct file *task_lookup_fdget_rcu(struct task_struct *task, unsigned int fd) 1092 - { 1093 - /* Must be called with rcu_read_lock held */ 1094 - struct files_struct *files; 1095 - struct file *file = NULL; 1096 - 1097 - task_lock(task); 1098 - files = task->files; 1099 - if (files) 1100 - file = __fget_files_rcu(files, fd, 0); 1101 - task_unlock(task); 1102 - 1103 - return file; 1104 - } 1105 - 1106 - struct file *task_lookup_next_fdget_rcu(struct task_struct *task, unsigned int *ret_fd) 1103 + struct file *fget_task_next(struct task_struct *task, unsigned int *ret_fd) 1107 1104 { 1108 1105 /* Must be called with rcu_read_lock held */ 1109 1106 struct files_struct *files; ··· 1091 1132 task_lock(task); 1092 1133 files = task->files; 1093 1134 if (files) { 1135 + rcu_read_lock(); 1094 1136 for (; fd < files_fdtable(files)->max_fds; fd++) { 1095 1137 file = __fget_files_rcu(files, fd, 0); 1096 1138 if (file) 1097 1139 break; 1098 1140 } 1141 + rcu_read_unlock(); 1099 1142 } 1100 1143 task_unlock(task); 1101 1144 *ret_fd = fd; 1102 1145 return file; 1103 1146 } 1104 - EXPORT_SYMBOL(task_lookup_next_fdget_rcu); 1147 + EXPORT_SYMBOL(fget_task_next); 1105 1148 1106 1149 /* 1107 1150 * Lightweight file lookup - no refcnt increment if fd table isn't shared. ··· 1200 1239 void set_close_on_exec(unsigned int fd, int flag) 1201 1240 { 1202 1241 struct files_struct *files = current->files; 1203 - struct fdtable *fdt; 1204 1242 spin_lock(&files->file_lock); 1205 - fdt = files_fdtable(files); 1206 - if (flag) 1207 - __set_close_on_exec(fd, fdt); 1208 - else 1209 - __clear_close_on_exec(fd, fdt); 1243 + __set_close_on_exec(fd, files_fdtable(files), flag); 1210 1244 spin_unlock(&files->file_lock); 1211 1245 } 1212 1246 ··· 1242 1286 goto Ebusy; 1243 1287 get_file(file); 1244 1288 rcu_assign_pointer(fdt->fd[fd], file); 1245 - __set_open_fd(fd, fdt); 1246 - if (flags & O_CLOEXEC) 1247 - __set_close_on_exec(fd, fdt); 1248 - else 1249 - __clear_close_on_exec(fd, fdt); 1289 + __set_open_fd(fd, fdt, flags & O_CLOEXEC); 1250 1290 spin_unlock(&files->file_lock); 1251 1291 1252 1292 if (tofree)
-1
fs/file_table.c
··· 9 9 #include <linux/string.h> 10 10 #include <linux/slab.h> 11 11 #include <linux/file.h> 12 - #include <linux/fdtable.h> 13 12 #include <linux/init.h> 14 13 #include <linux/module.h> 15 14 #include <linux/fs.h>
+2 -10
fs/gfs2/glock.c
··· 34 34 #include <linux/lockref.h> 35 35 #include <linux/rhashtable.h> 36 36 #include <linux/pid_namespace.h> 37 - #include <linux/fdtable.h> 38 37 #include <linux/file.h> 39 38 40 39 #include "gfs2.h" ··· 2767 2768 i->file = NULL; 2768 2769 } 2769 2770 2770 - rcu_read_lock(); 2771 2771 for(;; i->fd++) { 2772 - struct inode *inode; 2773 - 2774 - i->file = task_lookup_next_fdget_rcu(i->task, &i->fd); 2772 + i->file = fget_task_next(i->task, &i->fd); 2775 2773 if (!i->file) { 2776 2774 i->fd = 0; 2777 2775 break; 2778 2776 } 2779 2777 2780 - inode = file_inode(i->file); 2781 - if (inode->i_sb == i->sb) 2778 + if (file_inode(i->file)->i_sb == i->sb) 2782 2779 break; 2783 2780 2784 - rcu_read_unlock(); 2785 2781 fput(i->file); 2786 - rcu_read_lock(); 2787 2782 } 2788 - rcu_read_unlock(); 2789 2783 return i->file; 2790 2784 } 2791 2785
+1 -4
fs/notify/dnotify/dnotify.c
··· 16 16 #include <linux/security.h> 17 17 #include <linux/spinlock.h> 18 18 #include <linux/slab.h> 19 - #include <linux/fdtable.h> 20 19 #include <linux/fsnotify_backend.h> 21 20 22 21 static int dir_notify_enable __read_mostly = 1; ··· 346 347 new_fsn_mark = NULL; 347 348 } 348 349 349 - rcu_read_lock(); 350 - f = lookup_fdget_rcu(fd); 351 - rcu_read_unlock(); 350 + f = fget_raw(fd); 352 351 353 352 /* if (f != filp) means that we lost a race and another task/thread 354 353 * actually closed the fd we are still playing with before we grabbed
-1
fs/notify/fanotify/fanotify.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/fanotify.h> 3 - #include <linux/fdtable.h> 4 3 #include <linux/fsnotify_backend.h> 5 4 #include <linux/init.h> 6 5 #include <linux/jiffies.h>
-1
fs/notify/fanotify/fanotify_user.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/fanotify.h> 3 3 #include <linux/fcntl.h> 4 - #include <linux/fdtable.h> 5 4 #include <linux/file.h> 6 5 #include <linux/fs.h> 7 6 #include <linux/anon_inodes.h>
-17
fs/open.c
··· 1574 1574 return retval; 1575 1575 } 1576 1576 1577 - /** 1578 - * sys_close_range() - Close all file descriptors in a given range. 1579 - * 1580 - * @fd: starting file descriptor to close 1581 - * @max_fd: last file descriptor to close 1582 - * @flags: reserved for future extensions 1583 - * 1584 - * This closes a range of file descriptors. All file descriptors 1585 - * from @fd up to and including @max_fd are closed. 1586 - * Currently, errors to close a given file descriptor are ignored. 1587 - */ 1588 - SYSCALL_DEFINE3(close_range, unsigned int, fd, unsigned int, max_fd, 1589 - unsigned int, flags) 1590 - { 1591 - return __close_range(fd, max_fd, flags); 1592 - } 1593 - 1594 1577 /* 1595 1578 * This routine simulates a hangup on the tty, to arrange that users 1596 1579 * are given clean terminals at login time.
-1
fs/overlayfs/copy_up.c
··· 16 16 #include <linux/sched/signal.h> 17 17 #include <linux/cred.h> 18 18 #include <linux/namei.h> 19 - #include <linux/fdtable.h> 20 19 #include <linux/ratelimit.h> 21 20 #include <linux/exportfs.h> 22 21 #include "overlayfs.h"
-1
fs/proc/base.c
··· 58 58 #include <linux/init.h> 59 59 #include <linux/capability.h> 60 60 #include <linux/file.h> 61 - #include <linux/fdtable.h> 62 61 #include <linux/generic-radix-tree.h> 63 62 #include <linux/string.h> 64 63 #include <linux/seq_file.h>
+3 -9
fs/proc/fd.c
··· 116 116 { 117 117 struct file *file; 118 118 119 - rcu_read_lock(); 120 - file = task_lookup_fdget_rcu(task, fd); 121 - rcu_read_unlock(); 119 + file = fget_task(task, fd); 122 120 if (file) { 123 121 *mode = file->f_mode; 124 122 fput(file); ··· 256 258 if (!dir_emit_dots(file, ctx)) 257 259 goto out; 258 260 259 - rcu_read_lock(); 260 261 for (fd = ctx->pos - 2;; fd++) { 261 262 struct file *f; 262 263 struct fd_data data; 263 264 char name[10 + 1]; 264 265 unsigned int len; 265 266 266 - f = task_lookup_next_fdget_rcu(p, &fd); 267 + f = fget_task_next(p, &fd); 267 268 ctx->pos = fd + 2LL; 268 269 if (!f) 269 270 break; 270 271 data.mode = f->f_mode; 271 - rcu_read_unlock(); 272 272 fput(f); 273 273 data.fd = fd; 274 274 ··· 274 278 if (!proc_fill_cache(file, ctx, 275 279 name, len, instantiate, p, 276 280 &data)) 277 - goto out; 281 + break; 278 282 cond_resched(); 279 - rcu_read_lock(); 280 283 } 281 - rcu_read_unlock(); 282 284 out: 283 285 put_task_struct(p); 284 286 return 0;
-5
include/linux/fdtable.h
··· 92 92 return files_lookup_fd_raw(files, fd); 93 93 } 94 94 95 - struct file *lookup_fdget_rcu(unsigned int fd); 96 - struct file *task_lookup_fdget_rcu(struct task_struct *task, unsigned int fd); 97 - struct file *task_lookup_next_fdget_rcu(struct task_struct *task, unsigned int *fd); 98 - 99 95 static inline bool close_on_exec(unsigned int fd, const struct files_struct *files) 100 96 { 101 97 return test_bit(fd, files_fdtable(files)->close_on_exec); ··· 111 115 const void *); 112 116 113 117 extern int close_fd(unsigned int fd); 114 - extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags); 115 118 extern struct file *file_close_fd(unsigned int fd); 116 119 117 120 extern struct kmem_cache *files_cachep;
+1
include/linux/file.h
··· 72 72 extern struct file *fget(unsigned int fd); 73 73 extern struct file *fget_raw(unsigned int fd); 74 74 extern struct file *fget_task(struct task_struct *task, unsigned int fd); 75 + extern struct file *fget_task_next(struct task_struct *task, unsigned int *fd); 75 76 extern void __f_unlock_pos(struct file *); 76 77 77 78 struct fd fdget(unsigned int fd);
-1
io_uring/io_uring.c
··· 51 51 #include <linux/sched/signal.h> 52 52 #include <linux/fs.h> 53 53 #include <linux/file.h> 54 - #include <linux/fdtable.h> 55 54 #include <linux/mm.h> 56 55 #include <linux/mman.h> 57 56 #include <linux/percpu.h>
-1
kernel/bpf/bpf_inode_storage.c
··· 16 16 #include <uapi/linux/btf.h> 17 17 #include <linux/bpf_lsm.h> 18 18 #include <linux/btf_ids.h> 19 - #include <linux/fdtable.h> 20 19 #include <linux/rcupdate_trace.h> 21 20 22 21 DEFINE_BPF_STORAGE_CACHE(inode_cache);
-1
kernel/bpf/bpf_task_storage.c
··· 16 16 #include <linux/filter.h> 17 17 #include <uapi/linux/btf.h> 18 18 #include <linux/btf_ids.h> 19 - #include <linux/fdtable.h> 20 19 #include <linux/rcupdate_trace.h> 21 20 22 21 DEFINE_BPF_STORAGE_CACHE(task_cache);
+1 -5
kernel/bpf/task_iter.c
··· 5 5 #include <linux/namei.h> 6 6 #include <linux/pid_namespace.h> 7 7 #include <linux/fs.h> 8 - #include <linux/fdtable.h> 9 8 #include <linux/filter.h> 10 9 #include <linux/bpf_mem_alloc.h> 11 10 #include <linux/btf_ids.h> ··· 285 286 curr_fd = 0; 286 287 } 287 288 288 - rcu_read_lock(); 289 - f = task_lookup_next_fdget_rcu(curr_task, &curr_fd); 289 + f = fget_task_next(curr_task, &curr_fd); 290 290 if (f) { 291 291 /* set info->fd */ 292 292 info->fd = curr_fd; 293 - rcu_read_unlock(); 294 293 return f; 295 294 } 296 295 297 296 /* the current task is done, go to the next task */ 298 - rcu_read_unlock(); 299 297 put_task_struct(curr_task); 300 298 301 299 if (info->common.type == BPF_TASK_ITER_TID) {
-1
kernel/bpf/token.c
··· 1 1 #include <linux/bpf.h> 2 2 #include <linux/vmalloc.h> 3 - #include <linux/fdtable.h> 4 3 #include <linux/file.h> 5 4 #include <linux/fs.h> 6 5 #include <linux/kernel.h>
-1
kernel/exit.c
··· 25 25 #include <linux/acct.h> 26 26 #include <linux/tsacct_kern.h> 27 27 #include <linux/file.h> 28 - #include <linux/fdtable.h> 29 28 #include <linux/freezer.h> 30 29 #include <linux/binfmts.h> 31 30 #include <linux/nsproxy.h>
+1 -3
kernel/kcmp.c
··· 63 63 { 64 64 struct file *file; 65 65 66 - rcu_read_lock(); 67 - file = task_lookup_fdget_rcu(task, idx); 68 - rcu_read_unlock(); 66 + file = fget_task(task, idx); 69 67 if (file) 70 68 fput(file); 71 69
-1
kernel/module/dups.c
··· 18 18 #include <linux/completion.h> 19 19 #include <linux/cred.h> 20 20 #include <linux/file.h> 21 - #include <linux/fdtable.h> 22 21 #include <linux/workqueue.h> 23 22 #include <linux/security.h> 24 23 #include <linux/mount.h>
-1
kernel/module/kmod.c
··· 15 15 #include <linux/completion.h> 16 16 #include <linux/cred.h> 17 17 #include <linux/file.h> 18 - #include <linux/fdtable.h> 19 18 #include <linux/workqueue.h> 20 19 #include <linux/security.h> 21 20 #include <linux/mount.h>
-1
kernel/umh.c
··· 13 13 #include <linux/completion.h> 14 14 #include <linux/cred.h> 15 15 #include <linux/file.h> 16 - #include <linux/fdtable.h> 17 16 #include <linux/fs_struct.h> 18 17 #include <linux/workqueue.h> 19 18 #include <linux/security.h>
-1
net/handshake/request.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/skbuff.h> 15 15 #include <linux/inet.h> 16 - #include <linux/fdtable.h> 17 16 #include <linux/rhashtable.h> 18 17 19 18 #include <net/sock.h>
-1
security/apparmor/domain.c
··· 9 9 */ 10 10 11 11 #include <linux/errno.h> 12 - #include <linux/fdtable.h> 13 12 #include <linux/fs.h> 14 13 #include <linux/file.h> 15 14 #include <linux/mount.h>