Pull 'struct fd' updates from Al Viro: "Just the 'struct fd' layout change, with conversion to accessor helpers" * tag 'pull-stable-struct_fd' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: add struct fd constructors, get rid of __to_fd() struct fd: representation change introduce fd_file(), convert all accessors to it.
Unified · Split
| @@ -160,10 +160,10 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd, · 159 unmodified lines | |||
| 160 | .count = count | 160 | .count = count |
| 161 | }; | 161 | }; |
| 162 | 162 | ||
| 163 | if (!arg.file) | 163 | if (!fd_file(arg)) |
| 164 | return -EBADF; | 164 | return -EBADF; |
| 165 | 165 | ||
| 166 | error = iterate_dir(arg.file, &buf.ctx); | 166 | error = iterate_dir(fd_file(arg), &buf.ctx); |
| 167 | if (error >= 0) | 167 | if (error >= 0) |
| 168 | error = buf.error; | 168 | error = buf.error; |
| 169 | if (count != buf.count) | 169 | if (count != buf.count) |
| @@ -239,19 +239,19 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, · 238 unmodified lines | |||
| 239 | struct flock64 flock; | 239 | struct flock64 flock; |
| 240 | long err = -EBADF; | 240 | long err = -EBADF; |
| 241 | 241 | ||
| 242 | if (!f.file) | 242 | if (!fd_file(f)) |
| 243 | goto out; | 243 | goto out; |
| 244 | 244 | ||
| 245 | switch (cmd) { | 245 | switch (cmd) { |
| 246 | case F_GETLK64: | 246 | case F_GETLK64: |
| 247 | case F_OFD_GETLK: | 247 | case F_OFD_GETLK: |
| 248 | err = security_file_fcntl(f.file, cmd, arg); | 248 | err = security_file_fcntl(fd_file(f), cmd, arg); |
| 249 | if (err) | 249 | if (err) |
| 250 | break; | 250 | break; |
| 251 | err = get_oabi_flock(&flock, argp); | 251 | err = get_oabi_flock(&flock, argp); |
| 252 | if (err) | 252 | if (err) |
| 253 | break; | 253 | break; |
| 254 | err = fcntl_getlk64(f.file, cmd, &flock); | 254 | err = fcntl_getlk64(fd_file(f), cmd, &flock); |
| 255 | if (!err) | 255 | if (!err) |
| 256 | err = put_oabi_flock(&flock, argp); | 256 | err = put_oabi_flock(&flock, argp); |
| 257 | break; | 257 | break; |
| @@ -259,13 +259,13 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, · 1 unmodified line | |||
| 259 | case F_SETLKW64: | 259 | case F_SETLKW64: |
| 260 | case F_OFD_SETLK: | 260 | case F_OFD_SETLK: |
| 261 | case F_OFD_SETLKW: | 261 | case F_OFD_SETLKW: |
| 262 | err = security_file_fcntl(f.file, cmd, arg); | 262 | err = security_file_fcntl(fd_file(f), cmd, arg); |
| 263 | if (err) | 263 | if (err) |
| 264 | break; | 264 | break; |
| 265 | err = get_oabi_flock(&flock, argp); | 265 | err = get_oabi_flock(&flock, argp); |
| 266 | if (err) | 266 | if (err) |
| 267 | break; | 267 | break; |
| 268 | err = fcntl_setlk64(fd, f.file, cmd, &flock); | 268 | err = fcntl_setlk64(fd, fd_file(f), cmd, &flock); |
| 269 | break; | 269 | break; |
| 270 | default: | 270 | default: |
| 271 | err = sys_fcntl64(fd, cmd, arg); | 271 | err = sys_fcntl64(fd, cmd, arg); |
| @@ -118,12 +118,12 @@ long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd, · 117 unmodified lines | |||
| 118 | struct fd f; | 118 | struct fd f; |
| 119 | 119 | ||
| 120 | f = fdget(tablefd); | 120 | f = fdget(tablefd); |
| 121 | if (!f.file) | 121 | if (!fd_file(f)) |
| 122 | return -EBADF; | 122 | return -EBADF; |
| 123 | 123 | ||
| 124 | rcu_read_lock(); | 124 | rcu_read_lock(); |
| 125 | list_for_each_entry_rcu(stt, &kvm->arch.spapr_tce_tables, list) { | 125 | list_for_each_entry_rcu(stt, &kvm->arch.spapr_tce_tables, list) { |
| 126 | if (stt == f.file->private_data) { | 126 | if (stt == fd_file(f)->private_data) { |
| 127 | found = true; | 127 | found = true; |
| 128 | break; | 128 | break; |
| 129 | } | 129 | } |
| @@ -1938,11 +1938,11 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 1937 unmodified lines | |||
| 1938 | 1938 | ||
| 1939 | r = -EBADF; | 1939 | r = -EBADF; |
| 1940 | f = fdget(cap->args[0]); | 1940 | f = fdget(cap->args[0]); |
| 1941 | if (!f.file) | 1941 | if (!fd_file(f)) |
| 1942 | break; | 1942 | break; |
| 1943 | 1943 | ||
| 1944 | r = -EPERM; | 1944 | r = -EPERM; |
| 1945 | dev = kvm_device_from_filp(f.file); | 1945 | dev = kvm_device_from_filp(fd_file(f)); |
| 1946 | if (dev) | 1946 | if (dev) |
| 1947 | r = kvmppc_mpic_connect_vcpu(dev, vcpu, cap->args[1]); | 1947 | r = kvmppc_mpic_connect_vcpu(dev, vcpu, cap->args[1]); |
| 1948 | 1948 | ||
| @@ -1957,11 +1957,11 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 8 unmodified lines | |||
| 1957 | 1957 | ||
| 1958 | r = -EBADF; | 1958 | r = -EBADF; |
| 1959 | f = fdget(cap->args[0]); | 1959 | f = fdget(cap->args[0]); |
| 1960 | if (!f.file) | 1960 | if (!fd_file(f)) |
| 1961 | break; | 1961 | break; |
| 1962 | 1962 | ||
| 1963 | r = -EPERM; | 1963 | r = -EPERM; |
| 1964 | dev = kvm_device_from_filp(f.file); | 1964 | dev = kvm_device_from_filp(fd_file(f)); |
| 1965 | if (dev) { | 1965 | if (dev) { |
| 1966 | if (xics_on_xive()) | 1966 | if (xics_on_xive()) |
| 1967 | r = kvmppc_xive_connect_vcpu(dev, vcpu, cap->args[1]); | 1967 | r = kvmppc_xive_connect_vcpu(dev, vcpu, cap->args[1]); |
| @@ -1980,7 +1980,7 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 12 unmodified lines | |||
| 1980 | 1980 | ||
| 1981 | r = -EBADF; | 1981 | r = -EBADF; |
| 1982 | f = fdget(cap->args[0]); | 1982 | f = fdget(cap->args[0]); |
| 1983 | if (!f.file) | 1983 | if (!fd_file(f)) |
| 1984 | break; | 1984 | break; |
| 1985 | 1985 | ||
| 1986 | r = -ENXIO; | 1986 | r = -ENXIO; |
| @@ -1990,7 +1990,7 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 3 unmodified lines | |||
| 1990 | } | 1990 | } |
| 1991 | 1991 | ||
| 1992 | r = -EPERM; | 1992 | r = -EPERM; |
| 1993 | dev = kvm_device_from_filp(f.file); | 1993 | dev = kvm_device_from_filp(fd_file(f)); |
| 1994 | if (dev) | 1994 | if (dev) |
| 1995 | r = kvmppc_xive_native_connect_vcpu(dev, vcpu, | 1995 | r = kvmppc_xive_native_connect_vcpu(dev, vcpu, |
| 1996 | cap->args[1]); | 1996 | cap->args[1]); |
| @@ -66,8 +66,8 @@ SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags, · 65 unmodified lines | |||
| 66 | if (flags & SPU_CREATE_AFFINITY_SPU) { | 66 | if (flags & SPU_CREATE_AFFINITY_SPU) { |
| 67 | struct fd neighbor = fdget(neighbor_fd); | 67 | struct fd neighbor = fdget(neighbor_fd); |
| 68 | ret = -EBADF; | 68 | ret = -EBADF; |
| 69 | if (neighbor.file) { | 69 | if (fd_file(neighbor)) { |
| 70 | ret = calls->create_thread(name, flags, mode, neighbor.file); | 70 | ret = calls->create_thread(name, flags, mode, fd_file(neighbor)); |
| 71 | fdput(neighbor); | 71 | fdput(neighbor); |
| 72 | } | 72 | } |
| 73 | } else | 73 | } else |
| @@ -89,8 +89,8 @@ SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, ustatus) · 15 unmodified lines | |||
| 89 | 89 | ||
| 90 | ret = -EBADF; | 90 | ret = -EBADF; |
| 91 | arg = fdget(fd); | 91 | arg = fdget(fd); |
| 92 | if (arg.file) { | 92 | if (fd_file(arg)) { |
| 93 | ret = calls->spu_run(arg.file, unpc, ustatus); | 93 | ret = calls->spu_run(fd_file(arg), unpc, ustatus); |
| 94 | fdput(arg); | 94 | fdput(arg); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| @@ -903,10 +903,10 @@ int sgx_set_attribute(unsigned long *allowed_attributes, · 902 unmodified lines | |||
| 903 | { | 903 | { |
| 904 | struct fd f = fdget(attribute_fd); | 904 | struct fd f = fdget(attribute_fd); |
| 905 | 905 | ||
| 906 | if (!f.file) | 906 | if (!fd_file(f)) |
| 907 | return -EINVAL; | 907 | return -EINVAL; |
| 908 | 908 | ||
| 909 | if (f.file->f_op != &sgx_provision_fops) { | 909 | if (fd_file(f)->f_op != &sgx_provision_fops) { |
| 910 | fdput(f); | 910 | fdput(f); |
| 911 | return -EINVAL; | 911 | return -EINVAL; |
| 912 | } | 912 | } |
| @@ -534,10 +534,10 @@ static int __sev_issue_cmd(int fd, int id, void *data, int *error) · 533 unmodified lines | |||
| 534 | int ret; | 534 | int ret; |
| 535 | 535 | ||
| 536 | f = fdget(fd); | 536 | f = fdget(fd); |
| 537 | if (!f.file) | 537 | if (!fd_file(f)) |
| 538 | return -EBADF; | 538 | return -EBADF; |
| 539 | 539 | ||
| 540 | ret = sev_issue_cmd_external_user(f.file, id, data, error); | 540 | ret = sev_issue_cmd_external_user(fd_file(f), id, data, error); |
| 541 | 541 | ||
| 542 | fdput(f); | 542 | fdput(f); |
| 543 | return ret; | 543 | return ret; |
| @@ -2078,15 +2078,15 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) · 1534 unmodified lines | |||
| 2078 | bool charged = false; | 2078 | bool charged = false; |
| 2079 | int ret; | 2079 | int ret; |
| 2080 | 2080 | ||
| 2081 | if (!f.file) | 2081 | if (!fd_file(f)) |
| 2082 | return -EBADF; | 2082 | return -EBADF; |
| 2083 | 2083 | ||
| 2084 | if (!file_is_kvm(f.file)) { | 2084 | if (!file_is_kvm(fd_file(f))) { |
| 2085 | ret = -EBADF; | 2085 | ret = -EBADF; |
| 2086 | goto out_fput; | 2086 | goto out_fput; |
| 2087 | } | 2087 | } |
| 2088 | 2088 | ||
| 2089 | source_kvm = f.file->private_data; | 2089 | source_kvm = fd_file(f)->private_data; |
| 2090 | ret = sev_lock_two_vms(kvm, source_kvm); | 2090 | ret = sev_lock_two_vms(kvm, source_kvm); |
| 2091 | if (ret) | 2091 | if (ret) |
| 2092 | goto out_fput; | 2092 | goto out_fput; |
| @@ -2803,15 +2803,15 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd) · 710 unmodified lines | |||
| 2803 | struct kvm_sev_info *source_sev, *mirror_sev; | 2803 | struct kvm_sev_info *source_sev, *mirror_sev; |
| 2804 | int ret; | 2804 | int ret; |
| 2805 | 2805 | ||
| 2806 | if (!f.file) | 2806 | if (!fd_file(f)) |
| 2807 | return -EBADF; | 2807 | return -EBADF; |
| 2808 | 2808 | ||
| 2809 | if (!file_is_kvm(f.file)) { | 2809 | if (!file_is_kvm(fd_file(f))) { |
| 2810 | ret = -EBADF; | 2810 | ret = -EBADF; |
| 2811 | goto e_source_fput; | 2811 | goto e_source_fput; |
| 2812 | } | 2812 | } |
| 2813 | 2813 | ||
| 2814 | source_kvm = f.file->private_data; | 2814 | source_kvm = fd_file(f)->private_data; |
| 2815 | ret = sev_lock_two_vms(kvm, source_kvm); | 2815 | ret = sev_lock_two_vms(kvm, source_kvm); |
| 2816 | if (ret) | 2816 | if (ret) |
| 2817 | goto e_source_fput; | 2817 | goto e_source_fput; |
| @@ -42,10 +42,10 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, · 41 unmodified lines | |||
| 42 | uint32_t id; | 42 | uint32_t id; |
| 43 | int r; | 43 | int r; |
| 44 | 44 | ||
| 45 | if (!f.file) | 45 | if (!fd_file(f)) |
| 46 | return -EINVAL; | 46 | return -EINVAL; |
| 47 | 47 | ||
| 48 | r = amdgpu_file_to_fpriv(f.file, &fpriv); | 48 | r = amdgpu_file_to_fpriv(fd_file(f), &fpriv); |
| 49 | if (r) { | 49 | if (r) { |
| 50 | fdput(f); | 50 | fdput(f); |
| 51 | return r; | 51 | return r; |
| @@ -71,10 +71,10 @@ static int amdgpu_sched_context_priority_override(struct amdgpu_device *adev, · 19 unmodified lines | |||
| 71 | struct amdgpu_ctx *ctx; | 71 | struct amdgpu_ctx *ctx; |
| 72 | int r; | 72 | int r; |
| 73 | 73 | ||
| 74 | if (!f.file) | 74 | if (!fd_file(f)) |
| 75 | return -EINVAL; | 75 | return -EINVAL; |
| 76 | 76 | ||
| 77 | r = amdgpu_file_to_fpriv(f.file, &fpriv); | 77 | r = amdgpu_file_to_fpriv(fd_file(f), &fpriv); |
| 78 | if (r) { | 78 | if (r) { |
| 79 | fdput(f); | 79 | fdput(f); |
| 80 | return r; | 80 | return r; |
| @@ -715,16 +715,16 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private, · 714 unmodified lines | |||
| 715 | struct fd f = fdget(fd); | 715 | struct fd f = fdget(fd); |
| 716 | int ret; | 716 | int ret; |
| 717 | 717 | ||
| 718 | if (!f.file) | 718 | if (!fd_file(f)) |
| 719 | return -EINVAL; | 719 | return -EINVAL; |
| 720 | 720 | ||
| 721 | if (f.file->f_op != &drm_syncobj_file_fops) { | 721 | if (fd_file(f)->f_op != &drm_syncobj_file_fops) { |
| 722 | fdput(f); | 722 | fdput(f); |
| 723 | return -EINVAL; | 723 | return -EINVAL; |
| 724 | } | 724 | } |
| 725 | 725 | ||
| 726 | /* take a reference to put in the idr */ | 726 | /* take a reference to put in the idr */ |
| 727 | syncobj = f.file->private_data; | 727 | syncobj = fd_file(f)->private_data; |
| 728 | drm_syncobj_get(syncobj); | 728 | drm_syncobj_get(syncobj); |
| 729 | 729 | ||
| 730 | idr_preload(GFP_KERNEL); | 730 | idr_preload(GFP_KERNEL); |
| @@ -1624,13 +1624,13 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file, · 1623 unmodified lines | |||
| 1624 | 1624 | ||
| 1625 | /* Get current fd to protect against it being closed */ | 1625 | /* Get current fd to protect against it being closed */ |
| 1626 | f = fdget(cmd.fd); | 1626 | f = fdget(cmd.fd); |
| 1627 | if (!f.file) | 1627 | if (!fd_file(f)) |
| 1628 | return -ENOENT; | 1628 | return -ENOENT; |
| 1629 | if (f.file->f_op != &ucma_fops) { | 1629 | if (fd_file(f)->f_op != &ucma_fops) { |
| 1630 | ret = -EINVAL; | 1630 | ret = -EINVAL; |
| 1631 | goto file_put; | 1631 | goto file_put; |
| 1632 | } | 1632 | } |
| 1633 | cur_file = f.file->private_data; | 1633 | cur_file = fd_file(f)->private_data; |
| 1634 | 1634 | ||
| 1635 | /* Validate current fd and prevent destruction of id. */ | 1635 | /* Validate current fd and prevent destruction of id. */ |
| 1636 | ctx = ucma_get_ctx(cur_file, cmd.id); | 1636 | ctx = ucma_get_ctx(cur_file, cmd.id); |
| @@ -572,7 +572,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) · 571 unmodified lines | |||
| 572 | struct inode *inode = NULL; | 572 | struct inode *inode = NULL; |
| 573 | int new_xrcd = 0; | 573 | int new_xrcd = 0; |
| 574 | struct ib_device *ib_dev; | 574 | struct ib_device *ib_dev; |
| 575 | struct fd f = {}; | 575 | struct fd f = EMPTY_FD; |
| 576 | int ret; | 576 | int ret; |
| 577 | 577 | ||
| 578 | ret = uverbs_request(attrs, &cmd, sizeof(cmd)); | 578 | ret = uverbs_request(attrs, &cmd, sizeof(cmd)); |
| @@ -584,12 +584,12 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) · 5 unmodified lines | |||
| 584 | if (cmd.fd != -1) { | 584 | if (cmd.fd != -1) { |
| 585 | /* search for file descriptor */ | 585 | /* search for file descriptor */ |
| 586 | f = fdget(cmd.fd); | 586 | f = fdget(cmd.fd); |
| 587 | if (!f.file) { | 587 | if (!fd_file(f)) { |
| 588 | ret = -EBADF; | 588 | ret = -EBADF; |
| 589 | goto err_tree_mutex_unlock; | 589 | goto err_tree_mutex_unlock; |
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | inode = file_inode(f.file); | 592 | inode = file_inode(fd_file(f)); |
| 593 | xrcd = find_xrcd(ibudev, inode); | 593 | xrcd = find_xrcd(ibudev, inode); |
| 594 | if (!xrcd && !(cmd.oflags & O_CREAT)) { | 594 | if (!xrcd && !(cmd.oflags & O_CREAT)) { |
| 595 | /* no file descriptor. Need CREATE flag */ | 595 | /* no file descriptor. Need CREATE flag */ |
| @@ -632,7 +632,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) · 36 unmodified lines | |||
| 632 | atomic_inc(&xrcd->usecnt); | 632 | atomic_inc(&xrcd->usecnt); |
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | if (f.file) | 635 | if (fd_file(f)) |
| 636 | fdput(f); | 636 | fdput(f); |
| 637 | 637 | ||
| 638 | mutex_unlock(&ibudev->xrcd_tree_mutex); | 638 | mutex_unlock(&ibudev->xrcd_tree_mutex); |
| @@ -648,7 +648,7 @@ err: · 9 unmodified lines | |||
| 648 | uobj_alloc_abort(&obj->uobject, attrs); | 648 | uobj_alloc_abort(&obj->uobject, attrs); |
| 649 | 649 | ||
| 650 | err_tree_mutex_unlock: | 650 | err_tree_mutex_unlock: |
| 651 | if (f.file) | 651 | if (fd_file(f)) |
| 652 | fdput(f); | 652 | fdput(f); |
| 653 | 653 | ||
| 654 | mutex_unlock(&ibudev->xrcd_tree_mutex); | 654 | mutex_unlock(&ibudev->xrcd_tree_mutex); |
| @@ -254,12 +254,12 @@ media_request_get_by_fd(struct media_device *mdev, int request_fd) · 253 unmodified lines | |||
| 254 | return ERR_PTR(-EBADR); | 254 | return ERR_PTR(-EBADR); |
| 255 | 255 | ||
| 256 | f = fdget(request_fd); | 256 | f = fdget(request_fd); |
| 257 | if (!f.file) | 257 | if (!fd_file(f)) |
| 258 | goto err_no_req_fd; | 258 | goto err_no_req_fd; |
| 259 | 259 | ||
| 260 | if (f.file->f_op != &request_fops) | 260 | if (fd_file(f)->f_op != &request_fops) |
| 261 | goto err_fput; | 261 | goto err_fput; |
| 262 | req = f.file->private_data; | 262 | req = fd_file(f)->private_data; |
| 263 | if (req->mdev != mdev) | 263 | if (req->mdev != mdev) |
| 264 | goto err_fput; | 264 | goto err_fput; |
| 265 | 265 | ||
| @@ -820,20 +820,20 @@ struct rc_dev *rc_dev_get_from_fd(int fd, bool write) · 819 unmodified lines | |||
| 820 | struct lirc_fh *fh; | 820 | struct lirc_fh *fh; |
| 821 | struct rc_dev *dev; | 821 | struct rc_dev *dev; |
| 822 | 822 | ||
| 823 | if (!f.file) | 823 | if (!fd_file(f)) |
| 824 | return ERR_PTR(-EBADF); | 824 | return ERR_PTR(-EBADF); |
| 825 | 825 | ||
| 826 | if (f.file->f_op != &lirc_fops) { | 826 | if (fd_file(f)->f_op != &lirc_fops) { |
| 827 | fdput(f); | 827 | fdput(f); |
| 828 | return ERR_PTR(-EINVAL); | 828 | return ERR_PTR(-EINVAL); |
| 829 | } | 829 | } |
| 830 | 830 | ||
| 831 | if (write && !(f.file->f_mode & FMODE_WRITE)) { | 831 | if (write && !(fd_file(f)->f_mode & FMODE_WRITE)) { |
| 832 | fdput(f); | 832 | fdput(f); |
| 833 | return ERR_PTR(-EPERM); | 833 | return ERR_PTR(-EPERM); |
| 834 | } | 834 | } |
| 835 | 835 | ||
| 836 | fh = f.file->private_data; | 836 | fh = fd_file(f)->private_data; |
| 837 | dev = fh->rc; | 837 | dev = fh->rc; |
| 838 | 838 | ||
| 839 | get_device(&dev->dev); | 839 | get_device(&dev->dev); |
| @@ -112,7 +112,7 @@ static int vfio_group_ioctl_set_container(struct vfio_group *group, · 111 unmodified lines | |||
| 112 | return -EFAULT; | 112 | return -EFAULT; |
| 113 | 113 | ||
| 114 | f = fdget(fd); | 114 | f = fdget(fd); |
| 115 | if (!f.file) | 115 | if (!fd_file(f)) |
| 116 | return -EBADF; | 116 | return -EBADF; |
| 117 | 117 | ||
| 118 | mutex_lock(&group->group_lock); | 118 | mutex_lock(&group->group_lock); |
| @@ -125,13 +125,13 @@ static int vfio_group_ioctl_set_container(struct vfio_group *group, · 6 unmodified lines | |||
| 125 | goto out_unlock; | 125 | goto out_unlock; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | container = vfio_container_from_file(f.file); | 128 | container = vfio_container_from_file(fd_file(f)); |
| 129 | if (container) { | 129 | if (container) { |
| 130 | ret = vfio_container_attach_group(container, group); | 130 | ret = vfio_container_attach_group(container, group); |
| 131 | goto out_unlock; | 131 | goto out_unlock; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | iommufd = iommufd_ctx_from_file(f.file); | 134 | iommufd = iommufd_ctx_from_file(fd_file(f)); |
| 135 | if (!IS_ERR(iommufd)) { | 135 | if (!IS_ERR(iommufd)) { |
| 136 | if (IS_ENABLED(CONFIG_VFIO_NOIOMMU) && | 136 | if (IS_ENABLED(CONFIG_VFIO_NOIOMMU) && |
| 137 | group->type == VFIO_NO_IOMMU) | 137 | group->type == VFIO_NO_IOMMU) |
| @@ -134,12 +134,12 @@ int vfio_virqfd_enable(void *opaque, · 133 unmodified lines | |||
| 134 | INIT_WORK(&virqfd->flush_inject, virqfd_flush_inject); | 134 | INIT_WORK(&virqfd->flush_inject, virqfd_flush_inject); |
| 135 | 135 | ||
| 136 | irqfd = fdget(fd); | 136 | irqfd = fdget(fd); |
| 137 | if (!irqfd.file) { | 137 | if (!fd_file(irqfd)) { |
| 138 | ret = -EBADF; | 138 | ret = -EBADF; |
| 139 | goto err_fd; | 139 | goto err_fd; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | ctx = eventfd_ctx_fileget(irqfd.file); | 142 | ctx = eventfd_ctx_fileget(fd_file(irqfd)); |
| 143 | if (IS_ERR(ctx)) { | 143 | if (IS_ERR(ctx)) { |
| 144 | ret = PTR_ERR(ctx); | 144 | ret = PTR_ERR(ctx); |
| 145 | goto err_ctx; | 145 | goto err_ctx; |
| @@ -171,7 +171,7 @@ int vfio_virqfd_enable(void *opaque, · 25 unmodified lines | |||
| 171 | init_waitqueue_func_entry(&virqfd->wait, virqfd_wakeup); | 171 | init_waitqueue_func_entry(&virqfd->wait, virqfd_wakeup); |
| 172 | init_poll_funcptr(&virqfd->pt, virqfd_ptable_queue_proc); | 172 | init_poll_funcptr(&virqfd->pt, virqfd_ptable_queue_proc); |
| 173 | 173 | ||
| 174 | events = vfs_poll(irqfd.file, &virqfd->pt); | 174 | events = vfs_poll(fd_file(irqfd), &virqfd->pt); |
| 175 | 175 | ||
| 176 | /* | 176 | /* |
| 177 | * Check if there was an event already pending on the eventfd | 177 | * Check if there was an event already pending on the eventfd |
| @@ -125,12 +125,12 @@ static int acrn_irqfd_assign(struct acrn_vm *vm, struct acrn_irqfd *args) · 124 unmodified lines | |||
| 125 | INIT_WORK(&irqfd->shutdown, hsm_irqfd_shutdown_work); | 125 | INIT_WORK(&irqfd->shutdown, hsm_irqfd_shutdown_work); |
| 126 | 126 | ||
| 127 | f = fdget(args->fd); | 127 | f = fdget(args->fd); |
| 128 | if (!f.file) { | 128 | if (!fd_file(f)) { |
| 129 | ret = -EBADF; | 129 | ret = -EBADF; |
| 130 | goto out; | 130 | goto out; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | eventfd = eventfd_ctx_fileget(f.file); | 133 | eventfd = eventfd_ctx_fileget(fd_file(f)); |
| 134 | if (IS_ERR(eventfd)) { | 134 | if (IS_ERR(eventfd)) { |
| 135 | ret = PTR_ERR(eventfd); | 135 | ret = PTR_ERR(eventfd); |
| 136 | goto fail; | 136 | goto fail; |
| @@ -157,7 +157,7 @@ static int acrn_irqfd_assign(struct acrn_vm *vm, struct acrn_irqfd *args) · 20 unmodified lines | |||
| 157 | mutex_unlock(&vm->irqfds_lock); | 157 | mutex_unlock(&vm->irqfds_lock); |
| 158 | 158 | ||
| 159 | /* Check the pending event in this stage */ | 159 | /* Check the pending event in this stage */ |
| 160 | events = vfs_poll(f.file, &irqfd->pt); | 160 | events = vfs_poll(fd_file(f), &irqfd->pt); |
| 161 | 161 | ||
| 162 | if (events & EPOLLIN) | 162 | if (events & EPOLLIN) |
| 163 | acrn_irqfd_inject(irqfd); | 163 | acrn_irqfd_inject(irqfd); |
| @@ -959,12 +959,12 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 958 unmodified lines | |||
| 959 | INIT_WORK(&kirqfd->shutdown, irqfd_shutdown); | 959 | INIT_WORK(&kirqfd->shutdown, irqfd_shutdown); |
| 960 | 960 | ||
| 961 | f = fdget(irqfd->fd); | 961 | f = fdget(irqfd->fd); |
| 962 | if (!f.file) { | 962 | if (!fd_file(f)) { |
| 963 | ret = -EBADF; | 963 | ret = -EBADF; |
| 964 | goto error_kfree; | 964 | goto error_kfree; |
| 965 | } | 965 | } |
| 966 | 966 | ||
| 967 | kirqfd->eventfd = eventfd_ctx_fileget(f.file); | 967 | kirqfd->eventfd = eventfd_ctx_fileget(fd_file(f)); |
| 968 | if (IS_ERR(kirqfd->eventfd)) { | 968 | if (IS_ERR(kirqfd->eventfd)) { |
| 969 | ret = PTR_ERR(kirqfd->eventfd); | 969 | ret = PTR_ERR(kirqfd->eventfd); |
| 970 | goto error_fd_put; | 970 | goto error_fd_put; |
| @@ -995,7 +995,7 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 24 unmodified lines | |||
| 995 | * Check if there was an event already pending on the eventfd before we | 995 | * Check if there was an event already pending on the eventfd before we |
| 996 | * registered, and trigger it as if we didn't miss it. | 996 | * registered, and trigger it as if we didn't miss it. |
| 997 | */ | 997 | */ |
| 998 | events = vfs_poll(f.file, &kirqfd->pt); | 998 | events = vfs_poll(fd_file(f), &kirqfd->pt); |
| 999 | if (events & EPOLLIN) | 999 | if (events & EPOLLIN) |
| 1000 | irqfd_inject(kirqfd); | 1000 | irqfd_inject(kirqfd); |
| 1001 | 1001 | ||
| @@ -1345,12 +1345,12 @@ static int privcmd_ioeventfd_assign(struct privcmd_ioeventfd *ioeventfd) · 343 unmodified lines | |||
| 1345 | return -ENOMEM; | 1345 | return -ENOMEM; |
| 1346 | 1346 | ||
| 1347 | f = fdget(ioeventfd->event_fd); | 1347 | f = fdget(ioeventfd->event_fd); |
| 1348 | if (!f.file) { | 1348 | if (!fd_file(f)) { |
| 1349 | ret = -EBADF; | 1349 | ret = -EBADF; |
| 1350 | goto error_kfree; | 1350 | goto error_kfree; |
| 1351 | } | 1351 | } |
| 1352 | 1352 | ||
| 1353 | kioeventfd->eventfd = eventfd_ctx_fileget(f.file); | 1353 | kioeventfd->eventfd = eventfd_ctx_fileget(fd_file(f)); |
| 1354 | fdput(f); | 1354 | fdput(f); |
| 1355 | 1355 | ||
| 1356 | if (IS_ERR(kioeventfd->eventfd)) { | 1356 | if (IS_ERR(kioeventfd->eventfd)) { |
| @@ -1310,12 +1310,12 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file, · 1309 unmodified lines | |||
| 1310 | } else { | 1310 | } else { |
| 1311 | struct fd src = fdget(fd); | 1311 | struct fd src = fdget(fd); |
| 1312 | struct inode *src_inode; | 1312 | struct inode *src_inode; |
| 1313 | if (!src.file) { | 1313 | if (!fd_file(src)) { |
| 1314 | ret = -EINVAL; | 1314 | ret = -EINVAL; |
| 1315 | goto out_drop_write; | 1315 | goto out_drop_write; |
| 1316 | } | 1316 | } |
| 1317 | 1317 | ||
| 1318 | src_inode = file_inode(src.file); | 1318 | src_inode = file_inode(fd_file(src)); |
| 1319 | if (src_inode->i_sb != file_inode(file)->i_sb) { | 1319 | if (src_inode->i_sb != file_inode(file)->i_sb) { |
| 1320 | btrfs_info(BTRFS_I(file_inode(file))->root->fs_info, | 1320 | btrfs_info(BTRFS_I(file_inode(file))->root->fs_info, |
| 1321 | "Snapshot src from another FS"); | 1321 | "Snapshot src from another FS"); |
| @@ -349,9 +349,9 @@ struct eventfd_ctx *eventfd_ctx_fdget(int fd) · 348 unmodified lines | |||
| 349 | { | 349 | { |
| 350 | struct eventfd_ctx *ctx; | 350 | struct eventfd_ctx *ctx; |
| 351 | struct fd f = fdget(fd); | 351 | struct fd f = fdget(fd); |
| 352 | if (!f.file) | 352 | if (!fd_file(f)) |
| 353 | return ERR_PTR(-EBADF); | 353 | return ERR_PTR(-EBADF); |
| 354 | ctx = eventfd_ctx_fileget(f.file); | 354 | ctx = eventfd_ctx_fileget(fd_file(f)); |
| 355 | fdput(f); | 355 | fdput(f); |
| 356 | return ctx; | 356 | return ctx; |
| 357 | } | 357 | } |
| @@ -2261,17 +2261,17 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 2260 unmodified lines | |||
| 2261 | 2261 | ||
| 2262 | error = -EBADF; | 2262 | error = -EBADF; |
| 2263 | f = fdget(epfd); | 2263 | f = fdget(epfd); |
| 2264 | if (!f.file) | 2264 | if (!fd_file(f)) |
| 2265 | goto error_return; | 2265 | goto error_return; |
| 2266 | 2266 | ||
| 2267 | /* Get the "struct file *" for the target file */ | 2267 | /* Get the "struct file *" for the target file */ |
| 2268 | tf = fdget(fd); | 2268 | tf = fdget(fd); |
| 2269 | if (!tf.file) | 2269 | if (!fd_file(tf)) |
| 2270 | goto error_fput; | 2270 | goto error_fput; |
| 2271 | 2271 | ||
| 2272 | /* The target file descriptor must support poll */ | 2272 | /* The target file descriptor must support poll */ |
| 2273 | error = -EPERM; | 2273 | error = -EPERM; |
| 2274 | if (!file_can_poll(tf.file)) | 2274 | if (!file_can_poll(fd_file(tf))) |
| 2275 | goto error_tgt_fput; | 2275 | goto error_tgt_fput; |
| 2276 | 2276 | ||
| 2277 | /* Check if EPOLLWAKEUP is allowed */ | 2277 | /* Check if EPOLLWAKEUP is allowed */ |
| @@ -2284,7 +2284,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 6 unmodified lines | |||
| 2284 | * adding an epoll file descriptor inside itself. | 2284 | * adding an epoll file descriptor inside itself. |
| 2285 | */ | 2285 | */ |
| 2286 | error = -EINVAL; | 2286 | error = -EINVAL; |
| 2287 | if (f.file == tf.file || !is_file_epoll(f.file)) | 2287 | if (fd_file(f) == fd_file(tf) || !is_file_epoll(fd_file(f))) |
| 2288 | goto error_tgt_fput; | 2288 | goto error_tgt_fput; |
| 2289 | 2289 | ||
| 2290 | /* | 2290 | /* |
| @@ -2295,7 +2295,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 4 unmodified lines | |||
| 2295 | if (ep_op_has_event(op) && (epds->events & EPOLLEXCLUSIVE)) { | 2295 | if (ep_op_has_event(op) && (epds->events & EPOLLEXCLUSIVE)) { |
| 2296 | if (op == EPOLL_CTL_MOD) | 2296 | if (op == EPOLL_CTL_MOD) |
| 2297 | goto error_tgt_fput; | 2297 | goto error_tgt_fput; |
| 2298 | if (op == EPOLL_CTL_ADD && (is_file_epoll(tf.file) || | 2298 | if (op == EPOLL_CTL_ADD && (is_file_epoll(fd_file(tf)) || |
| 2299 | (epds->events & ~EPOLLEXCLUSIVE_OK_BITS))) | 2299 | (epds->events & ~EPOLLEXCLUSIVE_OK_BITS))) |
| 2300 | goto error_tgt_fput; | 2300 | goto error_tgt_fput; |
| 2301 | } | 2301 | } |
| @@ -2304,7 +2304,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 2 unmodified lines | |||
| 2304 | * At this point it is safe to assume that the "private_data" contains | 2304 | * At this point it is safe to assume that the "private_data" contains |
| 2305 | * our own data structure. | 2305 | * our own data structure. |
| 2306 | */ | 2306 | */ |
| 2307 | ep = f.file->private_data; | 2307 | ep = fd_file(f)->private_data; |
| 2308 | 2308 | ||
| 2309 | /* | 2309 | /* |
| 2310 | * When we insert an epoll file descriptor inside another epoll file | 2310 | * When we insert an epoll file descriptor inside another epoll file |
| @@ -2325,16 +2325,16 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 14 unmodified lines | |||
| 2325 | if (error) | 2325 | if (error) |
| 2326 | goto error_tgt_fput; | 2326 | goto error_tgt_fput; |
| 2327 | if (op == EPOLL_CTL_ADD) { | 2327 | if (op == EPOLL_CTL_ADD) { |
| 2328 | if (READ_ONCE(f.file->f_ep) || ep->gen == loop_check_gen || | 2328 | if (READ_ONCE(fd_file(f)->f_ep) || ep->gen == loop_check_gen || |
| 2329 | is_file_epoll(tf.file)) { | 2329 | is_file_epoll(fd_file(tf))) { |
| 2330 | mutex_unlock(&ep->mtx); | 2330 | mutex_unlock(&ep->mtx); |
| 2331 | error = epoll_mutex_lock(&epnested_mutex, 0, nonblock); | 2331 | error = epoll_mutex_lock(&epnested_mutex, 0, nonblock); |
| 2332 | if (error) | 2332 | if (error) |
| 2333 | goto error_tgt_fput; | 2333 | goto error_tgt_fput; |
| 2334 | loop_check_gen++; | 2334 | loop_check_gen++; |
| 2335 | full_check = 1; | 2335 | full_check = 1; |
| 2336 | if (is_file_epoll(tf.file)) { | 2336 | if (is_file_epoll(fd_file(tf))) { |
| 2337 | tep = tf.file->private_data; | 2337 | tep = fd_file(tf)->private_data; |
| 2338 | error = -ELOOP; | 2338 | error = -ELOOP; |
| 2339 | if (ep_loop_check(ep, tep) != 0) | 2339 | if (ep_loop_check(ep, tep) != 0) |
| 2340 | goto error_tgt_fput; | 2340 | goto error_tgt_fput; |
| @@ -2350,14 +2350,14 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 9 unmodified lines | |||
| 2350 | * above, we can be sure to be able to use the item looked up by | 2350 | * above, we can be sure to be able to use the item looked up by |
| 2351 | * ep_find() till we release the mutex. | 2351 | * ep_find() till we release the mutex. |
| 2352 | */ | 2352 | */ |
| 2353 | epi = ep_find(ep, tf.file, fd); | 2353 | epi = ep_find(ep, fd_file(tf), fd); |
| 2354 | 2354 | ||
| 2355 | error = -EINVAL; | 2355 | error = -EINVAL; |
| 2356 | switch (op) { | 2356 | switch (op) { |
| 2357 | case EPOLL_CTL_ADD: | 2357 | case EPOLL_CTL_ADD: |
| 2358 | if (!epi) { | 2358 | if (!epi) { |
| 2359 | epds->events |= EPOLLERR | EPOLLHUP; | 2359 | epds->events |= EPOLLERR | EPOLLHUP; |
| 2360 | error = ep_insert(ep, epds, tf.file, fd, full_check); | 2360 | error = ep_insert(ep, epds, fd_file(tf), fd, full_check); |
| 2361 | } else | 2361 | } else |
| 2362 | error = -EEXIST; | 2362 | error = -EEXIST; |
| 2363 | break; | 2363 | break; |
| @@ -2438,7 +2438,7 @@ static int do_epoll_wait(int epfd, struct epoll_event __user *events, · 74 unmodified lines | |||
| 2438 | 2438 | ||
| 2439 | /* Get the "struct file *" for the eventpoll file */ | 2439 | /* Get the "struct file *" for the eventpoll file */ |
| 2440 | f = fdget(epfd); | 2440 | f = fdget(epfd); |
| 2441 | if (!f.file) | 2441 | if (!fd_file(f)) |
| 2442 | return -EBADF; | 2442 | return -EBADF; |
| 2443 | 2443 | ||
| 2444 | /* | 2444 | /* |
| @@ -2446,14 +2446,14 @@ static int do_epoll_wait(int epfd, struct epoll_event __user *events, · 1 unmodified line | |||
| 2446 | * the user passed to us _is_ an eventpoll file. | 2446 | * the user passed to us _is_ an eventpoll file. |
| 2447 | */ | 2447 | */ |
| 2448 | error = -EINVAL; | 2448 | error = -EINVAL; |
| 2449 | if (!is_file_epoll(f.file)) | 2449 | if (!is_file_epoll(fd_file(f))) |
| 2450 | goto error_fput; | 2450 | goto error_fput; |
| 2451 | 2451 | ||
| 2452 | /* | 2452 | /* |
| 2453 | * At this point it is safe to assume that the "private_data" contains | 2453 | * At this point it is safe to assume that the "private_data" contains |
| 2454 | * our own data structure. | 2454 | * our own data structure. |
| 2455 | */ | 2455 | */ |
| 2456 | ep = f.file->private_data; | 2456 | ep = fd_file(f)->private_data; |
| 2457 | 2457 | ||
| 2458 | /* Time to fish for events ... */ | 2458 | /* Time to fish for events ... */ |
| 2459 | error = ep_poll(ep, events, maxevents, to); | 2459 | error = ep_poll(ep, events, maxevents, to); |
| @@ -1343,10 +1343,10 @@ group_extend_out: · 1342 unmodified lines | |||
| 1343 | me.moved_len = 0; | 1343 | me.moved_len = 0; |
| 1344 | 1344 | ||
| 1345 | donor = fdget(me.donor_fd); | 1345 | donor = fdget(me.donor_fd); |
| 1346 | if (!donor.file) | 1346 | if (!fd_file(donor)) |
| 1347 | return -EBADF; | 1347 | return -EBADF; |
| 1348 | 1348 | ||
| 1349 | if (!(donor.file->f_mode & FMODE_WRITE)) { | 1349 | if (!(fd_file(donor)->f_mode & FMODE_WRITE)) { |
| 1350 | err = -EBADF; | 1350 | err = -EBADF; |
| 1351 | goto mext_out; | 1351 | goto mext_out; |
| 1352 | } | 1352 | } |
| @@ -1367,7 +1367,7 @@ group_extend_out: · 14 unmodified lines | |||
| 1367 | if (err) | 1367 | if (err) |
| 1368 | goto mext_out; | 1368 | goto mext_out; |
| 1369 | 1369 | ||
| 1370 | err = ext4_move_extents(filp, donor.file, me.orig_start, | 1370 | err = ext4_move_extents(filp, fd_file(donor), me.orig_start, |
| 1371 | me.donor_start, me.len, &me.moved_len); | 1371 | me.donor_start, me.len, &me.moved_len); |
| 1372 | mnt_drop_write_file(filp); | 1372 | mnt_drop_write_file(filp); |
| 1373 | 1373 | ||
| @@ -3014,10 +3014,10 @@ static int __f2fs_ioc_move_range(struct file *filp, · 3013 unmodified lines | |||
| 3014 | return -EBADF; | 3014 | return -EBADF; |
| 3015 | 3015 | ||
| 3016 | dst = fdget(range->dst_fd); | 3016 | dst = fdget(range->dst_fd); |
| 3017 | if (!dst.file) | 3017 | if (!fd_file(dst)) |
| 3018 | return -EBADF; | 3018 | return -EBADF; |
| 3019 | 3019 | ||
| 3020 | if (!(dst.file->f_mode & FMODE_WRITE)) { | 3020 | if (!(fd_file(dst)->f_mode & FMODE_WRITE)) { |
| 3021 | err = -EBADF; | 3021 | err = -EBADF; |
| 3022 | goto err_out; | 3022 | goto err_out; |
| 3023 | } | 3023 | } |
| @@ -3026,7 +3026,7 @@ static int __f2fs_ioc_move_range(struct file *filp, · 2 unmodified lines | |||
| 3026 | if (err) | 3026 | if (err) |
| 3027 | goto err_out; | 3027 | goto err_out; |
| 3028 | 3028 | ||
| 3029 | err = f2fs_move_file_range(filp, range->pos_in, dst.file, | 3029 | err = f2fs_move_file_range(filp, range->pos_in, fd_file(dst), |
| 3030 | range->pos_out, range->len); | 3030 | range->pos_out, range->len); |
| 3031 | 3031 | ||
| 3032 | mnt_drop_write_file(filp); | 3032 | mnt_drop_write_file(filp); |
| @@ -405,7 +405,7 @@ static long f_dupfd_query(int fd, struct file *filp) · 404 unmodified lines | |||
| 405 | * overkill, but given our lockless file pointer lookup, the | 405 | * overkill, but given our lockless file pointer lookup, the |
| 406 | * alternatives are complicated. | 406 | * alternatives are complicated. |
| 407 | */ | 407 | */ |
| 408 | return f.file == filp; | 408 | return fd_file(f) == filp; |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | /* Let the caller figure out whether a given file was just created. */ | 411 | /* Let the caller figure out whether a given file was just created. */ |
| @@ -573,17 +573,17 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) · 161 unmodified lines | |||
| 573 | struct fd f = fdget_raw(fd); | 573 | struct fd f = fdget_raw(fd); |
| 574 | long err = -EBADF; | 574 | long err = -EBADF; |
| 575 | 575 | ||
| 576 | if (!f.file) | 576 | if (!fd_file(f)) |
| 577 | goto out; | 577 | goto out; |
| 578 | 578 | ||
| 579 | if (unlikely(f.file->f_mode & FMODE_PATH)) { | 579 | if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) { |
| 580 | if (!check_fcntl_cmd(cmd)) | 580 | if (!check_fcntl_cmd(cmd)) |
| 581 | goto out1; | 581 | goto out1; |
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | err = security_file_fcntl(f.file, cmd, arg); | 584 | err = security_file_fcntl(fd_file(f), cmd, arg); |
| 585 | if (!err) | 585 | if (!err) |
| 586 | err = do_fcntl(fd, cmd, arg, f.file); | 586 | err = do_fcntl(fd, cmd, arg, fd_file(f)); |
| 587 | 587 | ||
| 588 | out1: | 588 | out1: |
| 589 | fdput(f); | 589 | fdput(f); |
| @@ -600,15 +600,15 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 10 unmodified lines | |||
| 600 | struct flock64 flock; | 600 | struct flock64 flock; |
| 601 | long err = -EBADF; | 601 | long err = -EBADF; |
| 602 | 602 | ||
| 603 | if (!f.file) | 603 | if (!fd_file(f)) |
| 604 | goto out; | 604 | goto out; |
| 605 | 605 | ||
| 606 | if (unlikely(f.file->f_mode & FMODE_PATH)) { | 606 | if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) { |
| 607 | if (!check_fcntl_cmd(cmd)) | 607 | if (!check_fcntl_cmd(cmd)) |
| 608 | goto out1; | 608 | goto out1; |
| 609 | } | 609 | } |
| 610 | 610 | ||
| 611 | err = security_file_fcntl(f.file, cmd, arg); | 611 | err = security_file_fcntl(fd_file(f), cmd, arg); |
| 612 | if (err) | 612 | if (err) |
| 613 | goto out1; | 613 | goto out1; |
| 614 | 614 | ||
| @@ -618,7 +618,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 3 unmodified lines | |||
| 618 | err = -EFAULT; | 618 | err = -EFAULT; |
| 619 | if (copy_from_user(&flock, argp, sizeof(flock))) | 619 | if (copy_from_user(&flock, argp, sizeof(flock))) |
| 620 | break; | 620 | break; |
| 621 | err = fcntl_getlk64(f.file, cmd, &flock); | 621 | err = fcntl_getlk64(fd_file(f), cmd, &flock); |
| 622 | if (!err && copy_to_user(argp, &flock, sizeof(flock))) | 622 | if (!err && copy_to_user(argp, &flock, sizeof(flock))) |
| 623 | err = -EFAULT; | 623 | err = -EFAULT; |
| 624 | break; | 624 | break; |
| @@ -629,10 +629,10 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 4 unmodified lines | |||
| 629 | err = -EFAULT; | 629 | err = -EFAULT; |
| 630 | if (copy_from_user(&flock, argp, sizeof(flock))) | 630 | if (copy_from_user(&flock, argp, sizeof(flock))) |
| 631 | break; | 631 | break; |
| 632 | err = fcntl_setlk64(fd, f.file, cmd, &flock); | 632 | err = fcntl_setlk64(fd, fd_file(f), cmd, &flock); |
| 633 | break; | 633 | break; |
| 634 | default: | 634 | default: |
| 635 | err = do_fcntl(fd, cmd, arg, f.file); | 635 | err = do_fcntl(fd, cmd, arg, fd_file(f)); |
| 636 | break; | 636 | break; |
| 637 | } | 637 | } |
| 638 | out1: | 638 | out1: |
| @@ -737,15 +737,15 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 98 unmodified lines | |||
| 737 | struct flock flock; | 737 | struct flock flock; |
| 738 | long err = -EBADF; | 738 | long err = -EBADF; |
| 739 | 739 | ||
| 740 | if (!f.file) | 740 | if (!fd_file(f)) |
| 741 | return err; | 741 | return err; |
| 742 | 742 | ||
| 743 | if (unlikely(f.file->f_mode & FMODE_PATH)) { | 743 | if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) { |
| 744 | if (!check_fcntl_cmd(cmd)) | 744 | if (!check_fcntl_cmd(cmd)) |
| 745 | goto out_put; | 745 | goto out_put; |
| 746 | } | 746 | } |
| 747 | 747 | ||
| 748 | err = security_file_fcntl(f.file, cmd, arg); | 748 | err = security_file_fcntl(fd_file(f), cmd, arg); |
| 749 | if (err) | 749 | if (err) |
| 750 | goto out_put; | 750 | goto out_put; |
| 751 | 751 | ||
| @@ -754,7 +754,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines | |||
| 754 | err = get_compat_flock(&flock, compat_ptr(arg)); | 754 | err = get_compat_flock(&flock, compat_ptr(arg)); |
| 755 | if (err) | 755 | if (err) |
| 756 | break; | 756 | break; |
| 757 | err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); | 757 | err = fcntl_getlk(fd_file(f), convert_fcntl_cmd(cmd), &flock); |
| 758 | if (err) | 758 | if (err) |
| 759 | break; | 759 | break; |
| 760 | err = fixup_compat_flock(&flock); | 760 | err = fixup_compat_flock(&flock); |
| @@ -766,7 +766,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 5 unmodified lines | |||
| 766 | err = get_compat_flock64(&flock, compat_ptr(arg)); | 766 | err = get_compat_flock64(&flock, compat_ptr(arg)); |
| 767 | if (err) | 767 | if (err) |
| 768 | break; | 768 | break; |
| 769 | err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); | 769 | err = fcntl_getlk(fd_file(f), convert_fcntl_cmd(cmd), &flock); |
| 770 | if (!err) | 770 | if (!err) |
| 771 | err = put_compat_flock64(&flock, compat_ptr(arg)); | 771 | err = put_compat_flock64(&flock, compat_ptr(arg)); |
| 772 | break; | 772 | break; |
| @@ -775,7 +775,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines | |||
| 775 | err = get_compat_flock(&flock, compat_ptr(arg)); | 775 | err = get_compat_flock(&flock, compat_ptr(arg)); |
| 776 | if (err) | 776 | if (err) |
| 777 | break; | 777 | break; |
| 778 | err = fcntl_setlk(fd, f.file, convert_fcntl_cmd(cmd), &flock); | 778 | err = fcntl_setlk(fd, fd_file(f), convert_fcntl_cmd(cmd), &flock); |
| 779 | break; | 779 | break; |
| 780 | case F_SETLK64: | 780 | case F_SETLK64: |
| 781 | case F_SETLKW64: | 781 | case F_SETLKW64: |
| @@ -784,10 +784,10 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines | |||
| 784 | err = get_compat_flock64(&flock, compat_ptr(arg)); | 784 | err = get_compat_flock64(&flock, compat_ptr(arg)); |
| 785 | if (err) | 785 | if (err) |
| 786 | break; | 786 | break; |
| 787 | err = fcntl_setlk(fd, f.file, convert_fcntl_cmd(cmd), &flock); | 787 | err = fcntl_setlk(fd, fd_file(f), convert_fcntl_cmd(cmd), &flock); |
| 788 | break; | 788 | break; |
| 789 | default: | 789 | default: |
| 790 | err = do_fcntl(fd, cmd, arg, f.file); | 790 | err = do_fcntl(fd, cmd, arg, fd_file(f)); |
| 791 | break; | 791 | break; |
| 792 | } | 792 | } |
| 793 | out_put: | 793 | out_put: |
| @@ -140,9 +140,9 @@ static int get_path_from_fd(int fd, struct path *root) · 139 unmodified lines | |||
| 140 | spin_unlock(&fs->lock); | 140 | spin_unlock(&fs->lock); |
| 141 | } else { | 141 | } else { |
| 142 | struct fd f = fdget(fd); | 142 | struct fd f = fdget(fd); |
| 143 | if (!f.file) | 143 | if (!fd_file(f)) |
| 144 | return -EBADF; | 144 | return -EBADF; |
| 145 | *root = f.file->f_path; | 145 | *root = fd_file(f)->f_path; |
| 146 | path_get(root); | 146 | path_get(root); |
| 147 | fdput(f); | 147 | fdput(f); |
| 148 | } | 148 | } |
| @@ -1124,7 +1124,7 @@ EXPORT_SYMBOL(task_lookup_next_fdget_rcu); · 1123 unmodified lines | |||
| 1124 | * The fput_needed flag returned by fget_light should be passed to the | 1124 | * The fput_needed flag returned by fget_light should be passed to the |
| 1125 | * corresponding fput_light. | 1125 | * corresponding fput_light. |
| 1126 | */ | 1126 | */ |
| 1127 | static unsigned long __fget_light(unsigned int fd, fmode_t mask) | 1127 | static inline struct fd __fget_light(unsigned int fd, fmode_t mask) |
| 1128 | { | 1128 | { |
| 1129 | struct files_struct *files = current->files; | 1129 | struct files_struct *files = current->files; |
| 1130 | struct file *file; | 1130 | struct file *file; |
| @@ -1141,22 +1141,22 @@ static unsigned long __fget_light(unsigned int fd, fmode_t mask) · 10 unmodified lines | |||
| 1141 | if (likely(atomic_read_acquire(&files->count) == 1)) { | 1141 | if (likely(atomic_read_acquire(&files->count) == 1)) { |
| 1142 | file = files_lookup_fd_raw(files, fd); | 1142 | file = files_lookup_fd_raw(files, fd); |
| 1143 | if (!file || unlikely(file->f_mode & mask)) | 1143 | if (!file || unlikely(file->f_mode & mask)) |
| 1144 | return 0; | 1144 | return EMPTY_FD; |
| 1145 | return (unsigned long)file; | 1145 | return BORROWED_FD(file); |
| 1146 | } else { | 1146 | } else { |
| 1147 | file = __fget_files(files, fd, mask); | 1147 | file = __fget_files(files, fd, mask); |
| 1148 | if (!file) | 1148 | if (!file) |
| 1149 | return 0; | 1149 | return EMPTY_FD; |
| 1150 | return FDPUT_FPUT | (unsigned long)file; | 1150 | return CLONED_FD(file); |
| 1151 | } | 1151 | } |
| 1152 | } | 1152 | } |
| 1153 | unsigned long __fdget(unsigned int fd) | 1153 | struct fd fdget(unsigned int fd) |
| 1154 | { | 1154 | { |
| 1155 | return __fget_light(fd, FMODE_PATH); | 1155 | return __fget_light(fd, FMODE_PATH); |
| 1156 | } | 1156 | } |
| 1157 | EXPORT_SYMBOL(__fdget); | 1157 | EXPORT_SYMBOL(fdget); |
| 1158 | 1158 | ||
| 1159 | unsigned long __fdget_raw(unsigned int fd) | 1159 | struct fd fdget_raw(unsigned int fd) |
| 1160 | { | 1160 | { |
| 1161 | return __fget_light(fd, 0); | 1161 | return __fget_light(fd, 0); |
| 1162 | } | 1162 | } |
| @@ -1177,16 +1177,16 @@ static inline bool file_needs_f_pos_lock(struct file *file) · 14 unmodified lines | |||
| 1177 | (file_count(file) > 1 || file->f_op->iterate_shared); | 1177 | (file_count(file) > 1 || file->f_op->iterate_shared); |
| 1178 | } | 1178 | } |
| 1179 | 1179 | ||
| 1180 | unsigned long __fdget_pos(unsigned int fd) | 1180 | struct fd fdget_pos(unsigned int fd) |
| 1181 | { | 1181 | { |
| 1182 | unsigned long v = __fdget(fd); | 1182 | struct fd f = fdget(fd); |
| 1183 | struct file *file = (struct file *)(v & ~3); | 1183 | struct file *file = fd_file(f); |
| 1184 | 1184 | ||
| 1185 | if (file && file_needs_f_pos_lock(file)) { | 1185 | if (file && file_needs_f_pos_lock(file)) { |
| 1186 | v |= FDPUT_POS_UNLOCK; | 1186 | f.word |= FDPUT_POS_UNLOCK; |
| 1187 | mutex_lock(&file->f_pos_lock); | 1187 | mutex_lock(&file->f_pos_lock); |
| 1188 | } | 1188 | } |
| 1189 | return v; | 1189 | return f; |
| 1190 | } | 1190 | } |
| 1191 | 1191 | ||
| 1192 | void __f_unlock_pos(struct file *f) | 1192 | void __f_unlock_pos(struct file *f) |
| @@ -394,13 +394,13 @@ SYSCALL_DEFINE5(fsconfig, · 393 unmodified lines | |||
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | f = fdget(fd); | 396 | f = fdget(fd); |
| 397 | if (!f.file) | 397 | if (!fd_file(f)) |
| 398 | return -EBADF; | 398 | return -EBADF; |
| 399 | ret = -EINVAL; | 399 | ret = -EINVAL; |
| 400 | if (f.file->f_op != &fscontext_fops) | 400 | if (fd_file(f)->f_op != &fscontext_fops) |
| 401 | goto out_f; | 401 | goto out_f; |
| 402 | 402 | ||
| 403 | fc = f.file->private_data; | 403 | fc = fd_file(f)->private_data; |
| 404 | if (fc->ops == &legacy_fs_context_ops) { | 404 | if (fc->ops == &legacy_fs_context_ops) { |
| 405 | switch (cmd) { | 405 | switch (cmd) { |
| 406 | case FSCONFIG_SET_BINARY: | 406 | case FSCONFIG_SET_BINARY: |
| @@ -2329,15 +2329,15 @@ static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp) · 2328 unmodified lines | |||
| 2329 | return -EFAULT; | 2329 | return -EFAULT; |
| 2330 | 2330 | ||
| 2331 | f = fdget(oldfd); | 2331 | f = fdget(oldfd); |
| 2332 | if (!f.file) | 2332 | if (!fd_file(f)) |
| 2333 | return -EINVAL; | 2333 | return -EINVAL; |
| 2334 | 2334 | ||
| 2335 | /* | 2335 | /* |
| 2336 | * Check against file->f_op because CUSE | 2336 | * Check against file->f_op because CUSE |
| 2337 | * uses the same ioctl handler. | 2337 | * uses the same ioctl handler. |
| 2338 | */ | 2338 | */ |
| 2339 | if (f.file->f_op == file->f_op) | 2339 | if (fd_file(f)->f_op == file->f_op) |
| 2340 | fud = fuse_get_dev(f.file); | 2340 | fud = fuse_get_dev(fd_file(f)); |
| 2341 | 2341 | ||
| 2342 | res = -EINVAL; | 2342 | res = -EINVAL; |
| 2343 | if (fud) { | 2343 | if (fud) { |
| @@ -235,9 +235,9 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, · 234 unmodified lines | |||
| 235 | loff_t cloned; | 235 | loff_t cloned; |
| 236 | int ret; | 236 | int ret; |
| 237 | 237 | ||
| 238 | if (!src_file.file) | 238 | if (!fd_file(src_file)) |
| 239 | return -EBADF; | 239 | return -EBADF; |
| 240 | cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff, | 240 | cloned = vfs_clone_file_range(fd_file(src_file), off, dst_file, destoff, |
| 241 | olen, 0); | 241 | olen, 0); |
| 242 | if (cloned < 0) | 242 | if (cloned < 0) |
| 243 | ret = cloned; | 243 | ret = cloned; |
| @@ -895,16 +895,16 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) · 651 unmodified lines | |||
| 895 | struct fd f = fdget(fd); | 895 | struct fd f = fdget(fd); |
| 896 | int error; | 896 | int error; |
| 897 | 897 | ||
| 898 | if (!f.file) | 898 | if (!fd_file(f)) |
| 899 | return -EBADF; | 899 | return -EBADF; |
| 900 | 900 | ||
| 901 | error = security_file_ioctl(f.file, cmd, arg); | 901 | error = security_file_ioctl(fd_file(f), cmd, arg); |
| 902 | if (error) | 902 | if (error) |
| 903 | goto out; | 903 | goto out; |
| 904 | 904 | ||
| 905 | error = do_vfs_ioctl(f.file, fd, cmd, arg); | 905 | error = do_vfs_ioctl(fd_file(f), fd, cmd, arg); |
| 906 | if (error == -ENOIOCTLCMD) | 906 | if (error == -ENOIOCTLCMD) |
| 907 | error = vfs_ioctl(f.file, cmd, arg); | 907 | error = vfs_ioctl(fd_file(f), cmd, arg); |
| 908 | 908 | ||
| 909 | out: | 909 | out: |
| 910 | fdput(f); | 910 | fdput(f); |
| @@ -953,32 +953,32 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, · 42 unmodified lines | |||
| 953 | struct fd f = fdget(fd); | 953 | struct fd f = fdget(fd); |
| 954 | int error; | 954 | int error; |
| 955 | 955 | ||
| 956 | if (!f.file) | 956 | if (!fd_file(f)) |
| 957 | return -EBADF; | 957 | return -EBADF; |
| 958 | 958 | ||
| 959 | error = security_file_ioctl_compat(f.file, cmd, arg); | 959 | error = security_file_ioctl_compat(fd_file(f), cmd, arg); |
| 960 | if (error) | 960 | if (error) |
| 961 | goto out; | 961 | goto out; |
| 962 | 962 | ||
| 963 | switch (cmd) { | 963 | switch (cmd) { |
| 964 | /* FICLONE takes an int argument, so don't use compat_ptr() */ | 964 | /* FICLONE takes an int argument, so don't use compat_ptr() */ |
| 965 | case FICLONE: | 965 | case FICLONE: |
| 966 | error = ioctl_file_clone(f.file, arg, 0, 0, 0); | 966 | error = ioctl_file_clone(fd_file(f), arg, 0, 0, 0); |
| 967 | break; | 967 | break; |
| 968 | 968 | ||
| 969 | #if defined(CONFIG_X86_64) | 969 | #if defined(CONFIG_X86_64) |
| 970 | /* these get messy on amd64 due to alignment differences */ | 970 | /* these get messy on amd64 due to alignment differences */ |
| 971 | case FS_IOC_RESVSP_32: | 971 | case FS_IOC_RESVSP_32: |
| 972 | case FS_IOC_RESVSP64_32: | 972 | case FS_IOC_RESVSP64_32: |
| 973 | error = compat_ioctl_preallocate(f.file, 0, compat_ptr(arg)); | 973 | error = compat_ioctl_preallocate(fd_file(f), 0, compat_ptr(arg)); |
| 974 | break; | 974 | break; |
| 975 | case FS_IOC_UNRESVSP_32: | 975 | case FS_IOC_UNRESVSP_32: |
| 976 | case FS_IOC_UNRESVSP64_32: | 976 | case FS_IOC_UNRESVSP64_32: |
| 977 | error = compat_ioctl_preallocate(f.file, FALLOC_FL_PUNCH_HOLE, | 977 | error = compat_ioctl_preallocate(fd_file(f), FALLOC_FL_PUNCH_HOLE, |
| 978 | compat_ptr(arg)); | 978 | compat_ptr(arg)); |
| 979 | break; | 979 | break; |
| 980 | case FS_IOC_ZERO_RANGE_32: | 980 | case FS_IOC_ZERO_RANGE_32: |
| 981 | error = compat_ioctl_preallocate(f.file, FALLOC_FL_ZERO_RANGE, | 981 | error = compat_ioctl_preallocate(fd_file(f), FALLOC_FL_ZERO_RANGE, |
| 982 | compat_ptr(arg)); | 982 | compat_ptr(arg)); |
| 983 | break; | 983 | break; |
| 984 | #endif | 984 | #endif |
| @@ -998,13 +998,13 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, · 13 unmodified lines | |||
| 998 | * argument. | 998 | * argument. |
| 999 | */ | 999 | */ |
| 1000 | default: | 1000 | default: |
| 1001 | error = do_vfs_ioctl(f.file, fd, cmd, | 1001 | error = do_vfs_ioctl(fd_file(f), fd, cmd, |
| 1002 | (unsigned long)compat_ptr(arg)); | 1002 | (unsigned long)compat_ptr(arg)); |
| 1003 | if (error != -ENOIOCTLCMD) | 1003 | if (error != -ENOIOCTLCMD) |
| 1004 | break; | 1004 | break; |
| 1005 | 1005 | ||
| 1006 | if (f.file->f_op->compat_ioctl) | 1006 | if (fd_file(f)->f_op->compat_ioctl) |
| 1007 | error = f.file->f_op->compat_ioctl(f.file, cmd, arg); | 1007 | error = fd_file(f)->f_op->compat_ioctl(fd_file(f), cmd, arg); |
| 1008 | if (error == -ENOIOCTLCMD) | 1008 | if (error == -ENOIOCTLCMD) |
| 1009 | error = -ENOTTY; | 1009 | error = -ENOTTY; |
| 1010 | break; | 1010 | break; |
| @@ -178,10 +178,10 @@ ssize_t kernel_read_file_from_fd(int fd, loff_t offset, void **buf, · 177 unmodified lines | |||
| 178 | struct fd f = fdget(fd); | 178 | struct fd f = fdget(fd); |
| 179 | ssize_t ret = -EBADF; | 179 | ssize_t ret = -EBADF; |
| 180 | 180 | ||
| 181 | if (!f.file || !(f.file->f_mode & FMODE_READ)) | 181 | if (!fd_file(f) || !(fd_file(f)->f_mode & FMODE_READ)) |
| 182 | goto out; | 182 | goto out; |
| 183 | 183 | ||
| 184 | ret = kernel_read_file(f.file, offset, buf, buf_size, file_size, id); | 184 | ret = kernel_read_file(fd_file(f), offset, buf, buf_size, file_size, id); |
| 185 | out: | 185 | out: |
| 186 | fdput(f); | 186 | fdput(f); |
| 187 | return ret; | 187 | return ret; |
| @@ -2157,15 +2157,15 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) · 2156 unmodified lines | |||
| 2157 | 2157 | ||
| 2158 | error = -EBADF; | 2158 | error = -EBADF; |
| 2159 | f = fdget(fd); | 2159 | f = fdget(fd); |
| 2160 | if (!f.file) | 2160 | if (!fd_file(f)) |
| 2161 | return error; | 2161 | return error; |
| 2162 | 2162 | ||
| 2163 | if (type != F_UNLCK && !(f.file->f_mode & (FMODE_READ | FMODE_WRITE))) | 2163 | if (type != F_UNLCK && !(fd_file(f)->f_mode & (FMODE_READ | FMODE_WRITE))) |
| 2164 | goto out_putf; | 2164 | goto out_putf; |
| 2165 | 2165 | ||
| 2166 | flock_make_lock(f.file, &fl, type); | 2166 | flock_make_lock(fd_file(f), &fl, type); |
| 2167 | 2167 | ||
| 2168 | error = security_file_lock(f.file, fl.c.flc_type); | 2168 | error = security_file_lock(fd_file(f), fl.c.flc_type); |
| 2169 | if (error) | 2169 | if (error) |
| 2170 | goto out_putf; | 2170 | goto out_putf; |
| 2171 | 2171 | ||
| @@ -2173,12 +2173,12 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) · 1 unmodified line | |||
| 2173 | if (can_sleep) | 2173 | if (can_sleep) |
| 2174 | fl.c.flc_flags |= FL_SLEEP; | 2174 | fl.c.flc_flags |= FL_SLEEP; |
| 2175 | 2175 | ||
| 2176 | if (f.file->f_op->flock) | 2176 | if (fd_file(f)->f_op->flock) |
| 2177 | error = f.file->f_op->flock(f.file, | 2177 | error = fd_file(f)->f_op->flock(fd_file(f), |
| 2178 | (can_sleep) ? F_SETLKW : F_SETLK, | 2178 | (can_sleep) ? F_SETLKW : F_SETLK, |
| 2179 | &fl); | 2179 | &fl); |
| 2180 | else | 2180 | else |
| 2181 | error = locks_lock_file_wait(f.file, &fl); | 2181 | error = locks_lock_file_wait(fd_file(f), &fl); |
| 2182 | 2182 | ||
| 2183 | locks_release_private(&fl); | 2183 | locks_release_private(&fl); |
| 2184 | out_putf: | 2184 | out_putf: |
| @@ -2506,25 +2506,25 @@ static const char *path_init(struct nameidata *nd, unsigned flags) · 2505 unmodified lines | |||
| 2506 | struct fd f = fdget_raw(nd->dfd); | 2506 | struct fd f = fdget_raw(nd->dfd); |
| 2507 | struct dentry *dentry; | 2507 | struct dentry *dentry; |
| 2508 | 2508 | ||
| 2509 | if (!f.file) | 2509 | if (!fd_file(f)) |
| 2510 | return ERR_PTR(-EBADF); | 2510 | return ERR_PTR(-EBADF); |
| 2511 | 2511 | ||
| 2512 | if (flags & LOOKUP_LINKAT_EMPTY) { | 2512 | if (flags & LOOKUP_LINKAT_EMPTY) { |
| 2513 | if (f.file->f_cred != current_cred() && | 2513 | if (fd_file(f)->f_cred != current_cred() && |
| 2514 | !ns_capable(f.file->f_cred->user_ns, CAP_DAC_READ_SEARCH)) { | 2514 | !ns_capable(fd_file(f)->f_cred->user_ns, CAP_DAC_READ_SEARCH)) { |
| 2515 | fdput(f); | 2515 | fdput(f); |
| 2516 | return ERR_PTR(-ENOENT); | 2516 | return ERR_PTR(-ENOENT); |
| 2517 | } | 2517 | } |
| 2518 | } | 2518 | } |
| 2519 | 2519 | ||
| 2520 | dentry = f.file->f_path.dentry; | 2520 | dentry = fd_file(f)->f_path.dentry; |
| 2521 | 2521 | ||
| 2522 | if (*s && unlikely(!d_can_lookup(dentry))) { | 2522 | if (*s && unlikely(!d_can_lookup(dentry))) { |
| 2523 | fdput(f); | 2523 | fdput(f); |
| 2524 | return ERR_PTR(-ENOTDIR); | 2524 | return ERR_PTR(-ENOTDIR); |
| 2525 | } | 2525 | } |
| 2526 | 2526 | ||
| 2527 | nd->path = f.file->f_path; | 2527 | nd->path = fd_file(f)->f_path; |
| 2528 | if (flags & LOOKUP_RCU) { | 2528 | if (flags & LOOKUP_RCU) { |
| 2529 | nd->inode = nd->path.dentry->d_inode; | 2529 | nd->inode = nd->path.dentry->d_inode; |
| 2530 | nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); | 2530 | nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); |
| @@ -4134,14 +4134,14 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, · 4133 unmodified lines | |||
| 4134 | } | 4134 | } |
| 4135 | 4135 | ||
| 4136 | f = fdget(fs_fd); | 4136 | f = fdget(fs_fd); |
| 4137 | if (!f.file) | 4137 | if (!fd_file(f)) |
| 4138 | return -EBADF; | 4138 | return -EBADF; |
| 4139 | 4139 | ||
| 4140 | ret = -EINVAL; | 4140 | ret = -EINVAL; |
| 4141 | if (f.file->f_op != &fscontext_fops) | 4141 | if (fd_file(f)->f_op != &fscontext_fops) |
| 4142 | goto err_fsfd; | 4142 | goto err_fsfd; |
| 4143 | 4143 | ||
| 4144 | fc = f.file->private_data; | 4144 | fc = fd_file(f)->private_data; |
| 4145 | 4145 | ||
| 4146 | ret = mutex_lock_interruptible(&fc->uapi_mutex); | 4146 | ret = mutex_lock_interruptible(&fc->uapi_mutex); |
| 4147 | if (ret < 0) | 4147 | if (ret < 0) |
| @@ -4684,15 +4684,15 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize, · 536 unmodified lines | |||
| 4684 | return -EINVAL; | 4684 | return -EINVAL; |
| 4685 | 4685 | ||
| 4686 | f = fdget(attr->userns_fd); | 4686 | f = fdget(attr->userns_fd); |
| 4687 | if (!f.file) | 4687 | if (!fd_file(f)) |
| 4688 | return -EBADF; | 4688 | return -EBADF; |
| 4689 | 4689 | ||
| 4690 | if (!proc_ns_file(f.file)) { | 4690 | if (!proc_ns_file(fd_file(f))) { |
| 4691 | err = -EINVAL; | 4691 | err = -EINVAL; |
| 4692 | goto out_fput; | 4692 | goto out_fput; |
| 4693 | } | 4693 | } |
| 4694 | 4694 | ||
| 4695 | ns = get_proc_ns(file_inode(f.file)); | 4695 | ns = get_proc_ns(file_inode(fd_file(f))); |
| 4696 | if (ns->ops->type != CLONE_NEWUSER) { | 4696 | if (ns->ops->type != CLONE_NEWUSER) { |
| 4697 | err = -EINVAL; | 4697 | err = -EINVAL; |
| 4698 | goto out_fput; | 4698 | goto out_fput; |
| @@ -5292,13 +5292,13 @@ static struct mnt_namespace *grab_requested_mnt_ns(const struct mnt_id_req *kreq · 593 unmodified lines | |||
| 5292 | struct ns_common *ns; | 5292 | struct ns_common *ns; |
| 5293 | 5293 | ||
| 5294 | CLASS(fd, f)(kreq->spare); | 5294 | CLASS(fd, f)(kreq->spare); |
| 5295 | if (!f.file) | 5295 | if (fd_empty(f)) |
| 5296 | return ERR_PTR(-EBADF); | 5296 | return ERR_PTR(-EBADF); |
| 5297 | 5297 | ||
| 5298 | if (!proc_ns_file(f.file)) | 5298 | if (!proc_ns_file(fd_file(f))) |
| 5299 | return ERR_PTR(-EINVAL); | 5299 | return ERR_PTR(-EINVAL); |
| 5300 | 5300 | ||
| 5301 | ns = get_proc_ns(file_inode(f.file)); | 5301 | ns = get_proc_ns(file_inode(fd_file(f))); |
| 5302 | if (ns->ops->type != CLONE_NEWNS) | 5302 | if (ns->ops->type != CLONE_NEWNS) |
| 5303 | return ERR_PTR(-EINVAL); | 5303 | return ERR_PTR(-EINVAL); |
| 5304 | 5304 | ||
| @@ -1006,17 +1006,17 @@ static int fanotify_find_path(int dfd, const char __user *filename, · 1005 unmodified lines | |||
| 1006 | struct fd f = fdget(dfd); | 1006 | struct fd f = fdget(dfd); |
| 1007 | 1007 | ||
| 1008 | ret = -EBADF; | 1008 | ret = -EBADF; |
| 1009 | if (!f.file) | 1009 | if (!fd_file(f)) |
| 1010 | goto out; | 1010 | goto out; |
| 1011 | 1011 | ||
| 1012 | ret = -ENOTDIR; | 1012 | ret = -ENOTDIR; |
| 1013 | if ((flags & FAN_MARK_ONLYDIR) && | 1013 | if ((flags & FAN_MARK_ONLYDIR) && |
| 1014 | !(S_ISDIR(file_inode(f.file)->i_mode))) { | 1014 | !(S_ISDIR(file_inode(fd_file(f))->i_mode))) { |
| 1015 | fdput(f); | 1015 | fdput(f); |
| 1016 | goto out; | 1016 | goto out; |
| 1017 | } | 1017 | } |
| 1018 | 1018 | ||
| 1019 | *path = f.file->f_path; | 1019 | *path = fd_file(f)->f_path; |
| 1020 | path_get(path); | 1020 | path_get(path); |
| 1021 | fdput(f); | 1021 | fdput(f); |
| 1022 | } else { | 1022 | } else { |
| @@ -1753,14 +1753,14 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, · 730 unmodified lines | |||
| 1753 | } | 1753 | } |
| 1754 | 1754 | ||
| 1755 | f = fdget(fanotify_fd); | 1755 | f = fdget(fanotify_fd); |
| 1756 | if (unlikely(!f.file)) | 1756 | if (unlikely(!fd_file(f))) |
| 1757 | return -EBADF; | 1757 | return -EBADF; |
| 1758 | 1758 | ||
| 1759 | /* verify that this is indeed an fanotify instance */ | 1759 | /* verify that this is indeed an fanotify instance */ |
| 1760 | ret = -EINVAL; | 1760 | ret = -EINVAL; |
| 1761 | if (unlikely(f.file->f_op != &fanotify_fops)) | 1761 | if (unlikely(fd_file(f)->f_op != &fanotify_fops)) |
| 1762 | goto fput_and_out; | 1762 | goto fput_and_out; |
| 1763 | group = f.file->private_data; | 1763 | group = fd_file(f)->private_data; |
| 1764 | 1764 | ||
| 1765 | /* | 1765 | /* |
| 1766 | * An unprivileged user is not allowed to setup mount nor filesystem | 1766 | * An unprivileged user is not allowed to setup mount nor filesystem |
| @@ -753,7 +753,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, · 752 unmodified lines | |||
| 753 | return -EINVAL; | 753 | return -EINVAL; |
| 754 | 754 | ||
| 755 | f = fdget(fd); | 755 | f = fdget(fd); |
| 756 | if (unlikely(!f.file)) | 756 | if (unlikely(!fd_file(f))) |
| 757 | return -EBADF; | 757 | return -EBADF; |
| 758 | 758 | ||
| 759 | /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */ | 759 | /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */ |
| @@ -763,7 +763,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, · 3 unmodified lines | |||
| 763 | } | 763 | } |
| 764 | 764 | ||
| 765 | /* verify that this is indeed an inotify instance */ | 765 | /* verify that this is indeed an inotify instance */ |
| 766 | if (unlikely(f.file->f_op != &inotify_fops)) { | 766 | if (unlikely(fd_file(f)->f_op != &inotify_fops)) { |
| 767 | ret = -EINVAL; | 767 | ret = -EINVAL; |
| 768 | goto fput_and_out; | 768 | goto fput_and_out; |
| 769 | } | 769 | } |
| @@ -780,7 +780,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, · 10 unmodified lines | |||
| 780 | 780 | ||
| 781 | /* inode held in place by reference to path; group by fget on fd */ | 781 | /* inode held in place by reference to path; group by fget on fd */ |
| 782 | inode = path.dentry->d_inode; | 782 | inode = path.dentry->d_inode; |
| 783 | group = f.file->private_data; | 783 | group = fd_file(f)->private_data; |
| 784 | 784 | ||
| 785 | /* create/update an inode mark */ | 785 | /* create/update an inode mark */ |
| 786 | ret = inotify_update_watch(group, inode, mask); | 786 | ret = inotify_update_watch(group, inode, mask); |
| @@ -798,14 +798,14 @@ SYSCALL_DEFINE2(inotify_rm_watch, int, fd, __s32, wd) · 11 unmodified lines | |||
| 798 | int ret = -EINVAL; | 798 | int ret = -EINVAL; |
| 799 | 799 | ||
| 800 | f = fdget(fd); | 800 | f = fdget(fd); |
| 801 | if (unlikely(!f.file)) | 801 | if (unlikely(!fd_file(f))) |
| 802 | return -EBADF; | 802 | return -EBADF; |
| 803 | 803 | ||
| 804 | /* verify that this is indeed an inotify instance */ | 804 | /* verify that this is indeed an inotify instance */ |
| 805 | if (unlikely(f.file->f_op != &inotify_fops)) | 805 | if (unlikely(fd_file(f)->f_op != &inotify_fops)) |
| 806 | goto out; | 806 | goto out; |
| 807 | 807 | ||
| 808 | group = f.file->private_data; | 808 | group = fd_file(f)->private_data; |
| 809 | 809 | ||
| 810 | i_mark = inotify_idr_find(group, wd); | 810 | i_mark = inotify_idr_find(group, wd); |
| 811 | if (unlikely(!i_mark)) | 811 | if (unlikely(!i_mark)) |
| @@ -1785,17 +1785,17 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, · 1784 unmodified lines | |||
| 1785 | goto out; | 1785 | goto out; |
| 1786 | 1786 | ||
| 1787 | f = fdget(fd); | 1787 | f = fdget(fd); |
| 1788 | if (f.file == NULL) | 1788 | if (fd_file(f) == NULL) |
| 1789 | goto out; | 1789 | goto out; |
| 1790 | 1790 | ||
| 1791 | if (reg->hr_blocks == 0 || reg->hr_start_block == 0 || | 1791 | if (reg->hr_blocks == 0 || reg->hr_start_block == 0 || |
| 1792 | reg->hr_block_bytes == 0) | 1792 | reg->hr_block_bytes == 0) |
| 1793 | goto out2; | 1793 | goto out2; |
| 1794 | 1794 | ||
| 1795 | if (!S_ISBLK(f.file->f_mapping->host->i_mode)) | 1795 | if (!S_ISBLK(fd_file(f)->f_mapping->host->i_mode)) |
| 1796 | goto out2; | 1796 | goto out2; |
| 1797 | 1797 | ||
| 1798 | reg->hr_bdev_file = bdev_file_open_by_dev(f.file->f_mapping->host->i_rdev, | 1798 | reg->hr_bdev_file = bdev_file_open_by_dev(fd_file(f)->f_mapping->host->i_rdev, |
| 1799 | BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, NULL); | 1799 | BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, NULL); |
| 1800 | if (IS_ERR(reg->hr_bdev_file)) { | 1800 | if (IS_ERR(reg->hr_bdev_file)) { |
| 1801 | ret = PTR_ERR(reg->hr_bdev_file); | 1801 | ret = PTR_ERR(reg->hr_bdev_file); |
| @@ -193,10 +193,10 @@ long do_sys_ftruncate(unsigned int fd, loff_t length, int small) · 192 unmodified lines | |||
| 193 | if (length < 0) | 193 | if (length < 0) |
| 194 | return -EINVAL; | 194 | return -EINVAL; |
| 195 | f = fdget(fd); | 195 | f = fdget(fd); |
| 196 | if (!f.file) | 196 | if (!fd_file(f)) |
| 197 | return -EBADF; | 197 | return -EBADF; |
| 198 | 198 | ||
| 199 | error = do_ftruncate(f.file, length, small); | 199 | error = do_ftruncate(fd_file(f), length, small); |
| 200 | 200 | ||
| 201 | fdput(f); | 201 | fdput(f); |
| 202 | return error; | 202 | return error; |
| @@ -352,8 +352,8 @@ int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len) · 149 unmodified lines | |||
| 352 | struct fd f = fdget(fd); | 352 | struct fd f = fdget(fd); |
| 353 | int error = -EBADF; | 353 | int error = -EBADF; |
| 354 | 354 | ||
| 355 | if (f.file) { | 355 | if (fd_file(f)) { |
| 356 | error = vfs_fallocate(f.file, mode, offset, len); | 356 | error = vfs_fallocate(fd_file(f), mode, offset, len); |
| 357 | fdput(f); | 357 | fdput(f); |
| 358 | } | 358 | } |
| 359 | return error; | 359 | return error; |
| @@ -584,16 +584,16 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd) · 224 unmodified lines | |||
| 584 | int error; | 584 | int error; |
| 585 | 585 | ||
| 586 | error = -EBADF; | 586 | error = -EBADF; |
| 587 | if (!f.file) | 587 | if (!fd_file(f)) |
| 588 | goto out; | 588 | goto out; |
| 589 | 589 | ||
| 590 | error = -ENOTDIR; | 590 | error = -ENOTDIR; |
| 591 | if (!d_can_lookup(f.file->f_path.dentry)) | 591 | if (!d_can_lookup(fd_file(f)->f_path.dentry)) |
| 592 | goto out_putf; | 592 | goto out_putf; |
| 593 | 593 | ||
| 594 | error = file_permission(f.file, MAY_EXEC | MAY_CHDIR); | 594 | error = file_permission(fd_file(f), MAY_EXEC | MAY_CHDIR); |
| 595 | if (!error) | 595 | if (!error) |
| 596 | set_fs_pwd(current->fs, &f.file->f_path); | 596 | set_fs_pwd(current->fs, &fd_file(f)->f_path); |
| 597 | out_putf: | 597 | out_putf: |
| 598 | fdput(f); | 598 | fdput(f); |
| 599 | out: | 599 | out: |
| @@ -674,8 +674,8 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) · 74 unmodified lines | |||
| 674 | struct fd f = fdget(fd); | 674 | struct fd f = fdget(fd); |
| 675 | int err = -EBADF; | 675 | int err = -EBADF; |
| 676 | 676 | ||
| 677 | if (f.file) { | 677 | if (fd_file(f)) { |
| 678 | err = vfs_fchmod(f.file, mode); | 678 | err = vfs_fchmod(fd_file(f), mode); |
| 679 | fdput(f); | 679 | fdput(f); |
| 680 | } | 680 | } |
| 681 | return err; | 681 | return err; |
| @@ -868,8 +868,8 @@ int ksys_fchown(unsigned int fd, uid_t user, gid_t group) · 186 unmodified lines | |||
| 868 | struct fd f = fdget(fd); | 868 | struct fd f = fdget(fd); |
| 869 | int error = -EBADF; | 869 | int error = -EBADF; |
| 870 | 870 | ||
| 871 | if (f.file) { | 871 | if (fd_file(f)) { |
| 872 | error = vfs_fchown(f.file, user, group); | 872 | error = vfs_fchown(fd_file(f), user, group); |
| 873 | fdput(f); | 873 | fdput(f); |
| 874 | } | 874 | } |
| 875 | return error; | 875 | return error; |
| @@ -93,11 +93,11 @@ static int ovl_real_fdget_meta(const struct file *file, struct fd *real, · 92 unmodified lines | |||
| 93 | bool allow_meta) | 93 | bool allow_meta) |
| 94 | { | 94 | { |
| 95 | struct dentry *dentry = file_dentry(file); | 95 | struct dentry *dentry = file_dentry(file); |
| 96 | struct file *realfile = file->private_data; | ||
| 96 | struct path realpath; | 97 | struct path realpath; |
| 97 | int err; | 98 | int err; |
| 98 | 99 | ||
| 99 | real->flags = 0; | 100 | real->word = (unsigned long)realfile; |
| 100 | real->file = file->private_data; | ||
| 101 | 101 | ||
| 102 | if (allow_meta) { | 102 | if (allow_meta) { |
| 103 | ovl_path_real(dentry, &realpath); | 103 | ovl_path_real(dentry, &realpath); |
| @@ -113,16 +113,17 @@ static int ovl_real_fdget_meta(const struct file *file, struct fd *real, · 9 unmodified lines | |||
| 113 | return -EIO; | 113 | return -EIO; |
| 114 | 114 | ||
| 115 | /* Has it been copied up since we'd opened it? */ | 115 | /* Has it been copied up since we'd opened it? */ |
| 116 | if (unlikely(file_inode(real->file) != d_inode(realpath.dentry))) { | 116 | if (unlikely(file_inode(realfile) != d_inode(realpath.dentry))) { |
| 117 | real->flags = FDPUT_FPUT; | 117 | struct file *f = ovl_open_realfile(file, &realpath); |
| 118 | real->file = ovl_open_realfile(file, &realpath); | 118 | if (IS_ERR(f)) |
| 119 | 119 | return PTR_ERR(f); | |
| 120 | return PTR_ERR_OR_ZERO(real->file); | 120 | real->word = (unsigned long)ovl_open_realfile(file, &realpath) | FDPUT_FPUT; |
| 121 | return 0; | ||
| 121 | } | 122 | } |
| 122 | 123 | ||
| 123 | /* Did the flags change since open? */ | 124 | /* Did the flags change since open? */ |
| 124 | if (unlikely((file->f_flags ^ real->file->f_flags) & ~OVL_OPEN_FLAGS)) | 125 | if (unlikely((file->f_flags ^ realfile->f_flags) & ~OVL_OPEN_FLAGS)) |
| 125 | return ovl_change_flags(real->file, file->f_flags); | 126 | return ovl_change_flags(realfile, file->f_flags); |
| 126 | 127 | ||
| 127 | return 0; | 128 | return 0; |
| 128 | } | 129 | } |
| @@ -130,10 +131,11 @@ static int ovl_real_fdget_meta(const struct file *file, struct fd *real, · 1 unmodified line | |||
| 130 | static int ovl_real_fdget(const struct file *file, struct fd *real) | 131 | static int ovl_real_fdget(const struct file *file, struct fd *real) |
| 131 | { | 132 | { |
| 132 | if (d_is_dir(file_dentry(file))) { | 133 | if (d_is_dir(file_dentry(file))) { |
| 133 | real->flags = 0; | 134 | struct file *f = ovl_dir_real_file(file, false); |
| 134 | real->file = ovl_dir_real_file(file, false); | 135 | if (IS_ERR(f)) |
| 135 | 136 | return PTR_ERR(f); | |
| 136 | return PTR_ERR_OR_ZERO(real->file); | 137 | real->word = (unsigned long)f; |
| 138 | return 0; | ||
| 137 | } | 139 | } |
| 138 | 140 | ||
| 139 | return ovl_real_fdget_meta(file, real, false); | 141 | return ovl_real_fdget_meta(file, real, false); |
| @@ -209,13 +211,13 @@ static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) · 69 unmodified lines | |||
| 209 | * files, so we use the real file to perform seeks. | 211 | * files, so we use the real file to perform seeks. |
| 210 | */ | 212 | */ |
| 211 | ovl_inode_lock(inode); | 213 | ovl_inode_lock(inode); |
| 212 | real.file->f_pos = file->f_pos; | 214 | fd_file(real)->f_pos = file->f_pos; |
| 213 | 215 | ||
| 214 | old_cred = ovl_override_creds(inode->i_sb); | 216 | old_cred = ovl_override_creds(inode->i_sb); |
| 215 | ret = vfs_llseek(real.file, offset, whence); | 217 | ret = vfs_llseek(fd_file(real), offset, whence); |
| 216 | revert_creds(old_cred); | 218 | revert_creds(old_cred); |
| 217 | 219 | ||
| 218 | file->f_pos = real.file->f_pos; | 220 | file->f_pos = fd_file(real)->f_pos; |
| 219 | ovl_inode_unlock(inode); | 221 | ovl_inode_unlock(inode); |
| 220 | 222 | ||
| 221 | fdput(real); | 223 | fdput(real); |
| @@ -275,7 +277,7 @@ static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter) · 53 unmodified lines | |||
| 275 | if (ret) | 277 | if (ret) |
| 276 | return ret; | 278 | return ret; |
| 277 | 279 | ||
| 278 | ret = backing_file_read_iter(real.file, iter, iocb, iocb->ki_flags, | 280 | ret = backing_file_read_iter(fd_file(real), iter, iocb, iocb->ki_flags, |
| 279 | &ctx); | 281 | &ctx); |
| 280 | fdput(real); | 282 | fdput(real); |
| 281 | 283 | ||
| @@ -314,7 +316,7 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) · 32 unmodified lines | |||
| 314 | * this property in case it is set by the issuer. | 316 | * this property in case it is set by the issuer. |
| 315 | */ | 317 | */ |
| 316 | ifl &= ~IOCB_DIO_CALLER_COMP; | 318 | ifl &= ~IOCB_DIO_CALLER_COMP; |
| 317 | ret = backing_file_write_iter(real.file, iter, iocb, ifl, &ctx); | 319 | ret = backing_file_write_iter(fd_file(real), iter, iocb, ifl, &ctx); |
| 318 | fdput(real); | 320 | fdput(real); |
| 319 | 321 | ||
| 320 | out_unlock: | 322 | out_unlock: |
| @@ -339,7 +341,7 @@ static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, · 18 unmodified lines | |||
| 339 | if (ret) | 341 | if (ret) |
| 340 | return ret; | 342 | return ret; |
| 341 | 343 | ||
| 342 | ret = backing_file_splice_read(real.file, ppos, pipe, len, flags, &ctx); | 344 | ret = backing_file_splice_read(fd_file(real), ppos, pipe, len, flags, &ctx); |
| 343 | fdput(real); | 345 | fdput(real); |
| 344 | 346 | ||
| 345 | return ret; | 347 | return ret; |
| @@ -348,7 +350,7 @@ static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, · 2 unmodified lines | |||
| 348 | /* | 350 | /* |
| 349 | * Calling iter_file_splice_write() directly from overlay's f_op may deadlock | 351 | * Calling iter_file_splice_write() directly from overlay's f_op may deadlock |
| 350 | * due to lock order inversion between pipe->mutex in iter_file_splice_write() | 352 | * due to lock order inversion between pipe->mutex in iter_file_splice_write() |
| 351 | * and file_start_write(real.file) in ovl_write_iter(). | 353 | * and file_start_write(fd_file(real)) in ovl_write_iter(). |
| 352 | * | 354 | * |
| 353 | * So do everything ovl_write_iter() does and call iter_file_splice_write() on | 355 | * So do everything ovl_write_iter() does and call iter_file_splice_write() on |
| 354 | * the real file. | 356 | * the real file. |
| @@ -373,7 +375,7 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, · 18 unmodified lines | |||
| 373 | if (ret) | 375 | if (ret) |
| 374 | goto out_unlock; | 376 | goto out_unlock; |
| 375 | 377 | ||
| 376 | ret = backing_file_splice_write(pipe, real.file, ppos, len, flags, &ctx); | 378 | ret = backing_file_splice_write(pipe, fd_file(real), ppos, len, flags, &ctx); |
| 377 | fdput(real); | 379 | fdput(real); |
| 378 | 380 | ||
| 379 | out_unlock: | 381 | out_unlock: |
| @@ -397,9 +399,9 @@ static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) · 17 unmodified lines | |||
| 397 | return ret; | 399 | return ret; |
| 398 | 400 | ||
| 399 | /* Don't sync lower file for fear of receiving EROFS error */ | 401 | /* Don't sync lower file for fear of receiving EROFS error */ |
| 400 | if (file_inode(real.file) == ovl_inode_upper(file_inode(file))) { | 402 | if (file_inode(fd_file(real)) == ovl_inode_upper(file_inode(file))) { |
| 401 | old_cred = ovl_override_creds(file_inode(file)->i_sb); | 403 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 402 | ret = vfs_fsync_range(real.file, start, end, datasync); | 404 | ret = vfs_fsync_range(fd_file(real), start, end, datasync); |
| 403 | revert_creds(old_cred); | 405 | revert_creds(old_cred); |
| 404 | } | 406 | } |
| 405 | 407 | ||
| @@ -439,7 +441,7 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len · 33 unmodified lines | |||
| 439 | goto out_unlock; | 441 | goto out_unlock; |
| 440 | 442 | ||
| 441 | old_cred = ovl_override_creds(file_inode(file)->i_sb); | 443 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 442 | ret = vfs_fallocate(real.file, mode, offset, len); | 444 | ret = vfs_fallocate(fd_file(real), mode, offset, len); |
| 443 | revert_creds(old_cred); | 445 | revert_creds(old_cred); |
| 444 | 446 | ||
| 445 | /* Update size */ | 447 | /* Update size */ |
| @@ -464,7 +466,7 @@ static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) · 18 unmodified lines | |||
| 464 | return ret; | 466 | return ret; |
| 465 | 467 | ||
| 466 | old_cred = ovl_override_creds(file_inode(file)->i_sb); | 468 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 467 | ret = vfs_fadvise(real.file, offset, len, advice); | 469 | ret = vfs_fadvise(fd_file(real), offset, len, advice); |
| 468 | revert_creds(old_cred); | 470 | revert_creds(old_cred); |
| 469 | 471 | ||
| 470 | fdput(real); | 472 | fdput(real); |
| @@ -509,18 +511,18 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, · 38 unmodified lines | |||
| 509 | old_cred = ovl_override_creds(file_inode(file_out)->i_sb); | 511 | old_cred = ovl_override_creds(file_inode(file_out)->i_sb); |
| 510 | switch (op) { | 512 | switch (op) { |
| 511 | case OVL_COPY: | 513 | case OVL_COPY: |
| 512 | ret = vfs_copy_file_range(real_in.file, pos_in, | 514 | ret = vfs_copy_file_range(fd_file(real_in), pos_in, |
| 513 | real_out.file, pos_out, len, flags); | 515 | fd_file(real_out), pos_out, len, flags); |
| 514 | break; | 516 | break; |
| 515 | 517 | ||
| 516 | case OVL_CLONE: | 518 | case OVL_CLONE: |
| 517 | ret = vfs_clone_file_range(real_in.file, pos_in, | 519 | ret = vfs_clone_file_range(fd_file(real_in), pos_in, |
| 518 | real_out.file, pos_out, len, flags); | 520 | fd_file(real_out), pos_out, len, flags); |
| 519 | break; | 521 | break; |
| 520 | 522 | ||
| 521 | case OVL_DEDUPE: | 523 | case OVL_DEDUPE: |
| 522 | ret = vfs_dedupe_file_range_one(real_in.file, pos_in, | 524 | ret = vfs_dedupe_file_range_one(fd_file(real_in), pos_in, |
| 523 | real_out.file, pos_out, len, | 525 | fd_file(real_out), pos_out, len, |
| 524 | flags); | 526 | flags); |
| 525 | break; | 527 | break; |
| 526 | } | 528 | } |
| @@ -583,9 +585,9 @@ static int ovl_flush(struct file *file, fl_owner_t id) · 56 unmodified lines | |||
| 583 | if (err) | 585 | if (err) |
| 584 | return err; | 586 | return err; |
| 585 | 587 | ||
| 586 | if (real.file->f_op->flush) { | 588 | if (fd_file(real)->f_op->flush) { |
| 587 | old_cred = ovl_override_creds(file_inode(file)->i_sb); | 589 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 588 | err = real.file->f_op->flush(real.file, id); | 590 | err = fd_file(real)->f_op->flush(fd_file(real), id); |
| 589 | revert_creds(old_cred); | 591 | revert_creds(old_cred); |
| 590 | } | 592 | } |
| 591 | fdput(real); | 593 | fdput(real); |
| @@ -980,7 +980,7 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 979 unmodified lines | |||
| 980 | int ret; | 980 | int ret; |
| 981 | 981 | ||
| 982 | f = fdget_raw(fd); | 982 | f = fdget_raw(fd); |
| 983 | if (!f.file) | 983 | if (!fd_file(f)) |
| 984 | return -EBADF; | 984 | return -EBADF; |
| 985 | 985 | ||
| 986 | ret = -EINVAL; | 986 | ret = -EINVAL; |
| @@ -988,12 +988,12 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 1 unmodified line | |||
| 988 | goto out; | 988 | goto out; |
| 989 | 989 | ||
| 990 | if (quotactl_cmd_write(cmds)) { | 990 | if (quotactl_cmd_write(cmds)) { |
| 991 | ret = mnt_want_write(f.file->f_path.mnt); | 991 | ret = mnt_want_write(fd_file(f)->f_path.mnt); |
| 992 | if (ret) | 992 | if (ret) |
| 993 | goto out; | 993 | goto out; |
| 994 | } | 994 | } |
| 995 | 995 | ||
| 996 | sb = f.file->f_path.mnt->mnt_sb; | 996 | sb = fd_file(f)->f_path.mnt->mnt_sb; |
| 997 | if (quotactl_cmd_onoff(cmds)) | 997 | if (quotactl_cmd_onoff(cmds)) |
| 998 | down_write(&sb->s_umount); | 998 | down_write(&sb->s_umount); |
| 999 | else | 999 | else |
| @@ -1007,7 +1007,7 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 7 unmodified lines | |||
| 1007 | up_read(&sb->s_umount); | 1007 | up_read(&sb->s_umount); |
| 1008 | 1008 | ||
| 1009 | if (quotactl_cmd_write(cmds)) | 1009 | if (quotactl_cmd_write(cmds)) |
| 1010 | mnt_drop_write(f.file->f_path.mnt); | 1010 | mnt_drop_write(fd_file(f)->f_path.mnt); |
| 1011 | out: | 1011 | out: |
| 1012 | fdput(f); | 1012 | fdput(f); |
| 1013 | return ret; | 1013 | return ret; |
| @@ -387,12 +387,12 @@ static off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence) · 386 unmodified lines | |||
| 387 | { | 387 | { |
| 388 | off_t retval; | 388 | off_t retval; |
| 389 | struct fd f = fdget_pos(fd); | 389 | struct fd f = fdget_pos(fd); |
| 390 | if (!f.file) | 390 | if (!fd_file(f)) |
| 391 | return -EBADF; | 391 | return -EBADF; |
| 392 | 392 | ||
| 393 | retval = -EINVAL; | 393 | retval = -EINVAL; |
| 394 | if (whence <= SEEK_MAX) { | 394 | if (whence <= SEEK_MAX) { |
| 395 | loff_t res = vfs_llseek(f.file, offset, whence); | 395 | loff_t res = vfs_llseek(fd_file(f), offset, whence); |
| 396 | retval = res; | 396 | retval = res; |
| 397 | if (res != (loff_t)retval) | 397 | if (res != (loff_t)retval) |
| 398 | retval = -EOVERFLOW; /* LFS: should only happen on 32 bit platforms */ | 398 | retval = -EOVERFLOW; /* LFS: should only happen on 32 bit platforms */ |
| @@ -423,14 +423,14 @@ SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned long, offset_high, · 24 unmodified lines | |||
| 423 | struct fd f = fdget_pos(fd); | 423 | struct fd f = fdget_pos(fd); |
| 424 | loff_t offset; | 424 | loff_t offset; |
| 425 | 425 | ||
| 426 | if (!f.file) | 426 | if (!fd_file(f)) |
| 427 | return -EBADF; | 427 | return -EBADF; |
| 428 | 428 | ||
| 429 | retval = -EINVAL; | 429 | retval = -EINVAL; |
| 430 | if (whence > SEEK_MAX) | 430 | if (whence > SEEK_MAX) |
| 431 | goto out_putf; | 431 | goto out_putf; |
| 432 | 432 | ||
| 433 | offset = vfs_llseek(f.file, ((loff_t) offset_high << 32) | offset_low, | 433 | offset = vfs_llseek(fd_file(f), ((loff_t) offset_high << 32) | offset_low, |
| 434 | whence); | 434 | whence); |
| 435 | 435 | ||
| 436 | retval = (int)offset; | 436 | retval = (int)offset; |
| @@ -703,15 +703,15 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) · 266 unmodified lines | |||
| 703 | struct fd f = fdget_pos(fd); | 703 | struct fd f = fdget_pos(fd); |
| 704 | ssize_t ret = -EBADF; | 704 | ssize_t ret = -EBADF; |
| 705 | 705 | ||
| 706 | if (f.file) { | 706 | if (fd_file(f)) { |
| 707 | loff_t pos, *ppos = file_ppos(f.file); | 707 | loff_t pos, *ppos = file_ppos(fd_file(f)); |
| 708 | if (ppos) { | 708 | if (ppos) { |
| 709 | pos = *ppos; | 709 | pos = *ppos; |
| 710 | ppos = &pos; | 710 | ppos = &pos; |
| 711 | } | 711 | } |
| 712 | ret = vfs_read(f.file, buf, count, ppos); | 712 | ret = vfs_read(fd_file(f), buf, count, ppos); |
| 713 | if (ret >= 0 && ppos) | 713 | if (ret >= 0 && ppos) |
| 714 | f.file->f_pos = pos; | 714 | fd_file(f)->f_pos = pos; |
| 715 | fdput_pos(f); | 715 | fdput_pos(f); |
| 716 | } | 716 | } |
| 717 | return ret; | 717 | return ret; |
| @@ -727,15 +727,15 @@ ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count) · 9 unmodified lines | |||
| 727 | struct fd f = fdget_pos(fd); | 727 | struct fd f = fdget_pos(fd); |
| 728 | ssize_t ret = -EBADF; | 728 | ssize_t ret = -EBADF; |
| 729 | 729 | ||
| 730 | if (f.file) { | 730 | if (fd_file(f)) { |
| 731 | loff_t pos, *ppos = file_ppos(f.file); | 731 | loff_t pos, *ppos = file_ppos(fd_file(f)); |
| 732 | if (ppos) { | 732 | if (ppos) { |
| 733 | pos = *ppos; | 733 | pos = *ppos; |
| 734 | ppos = &pos; | 734 | ppos = &pos; |
| 735 | } | 735 | } |
| 736 | ret = vfs_write(f.file, buf, count, ppos); | 736 | ret = vfs_write(fd_file(f), buf, count, ppos); |
| 737 | if (ret >= 0 && ppos) | 737 | if (ret >= 0 && ppos) |
| 738 | f.file->f_pos = pos; | 738 | fd_file(f)->f_pos = pos; |
| 739 | fdput_pos(f); | 739 | fdput_pos(f); |
| 740 | } | 740 | } |
| 741 | 741 | ||
| @@ -758,10 +758,10 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count, · 16 unmodified lines | |||
| 758 | return -EINVAL; | 758 | return -EINVAL; |
| 759 | 759 | ||
| 760 | f = fdget(fd); | 760 | f = fdget(fd); |
| 761 | if (f.file) { | 761 | if (fd_file(f)) { |
| 762 | ret = -ESPIPE; | 762 | ret = -ESPIPE; |
| 763 | if (f.file->f_mode & FMODE_PREAD) | 763 | if (fd_file(f)->f_mode & FMODE_PREAD) |
| 764 | ret = vfs_read(f.file, buf, count, &pos); | 764 | ret = vfs_read(fd_file(f), buf, count, &pos); |
| 765 | fdput(f); | 765 | fdput(f); |
| 766 | } | 766 | } |
| 767 | 767 | ||
| @@ -792,10 +792,10 @@ ssize_t ksys_pwrite64(unsigned int fd, const char __user *buf, · 24 unmodified lines | |||
| 792 | return -EINVAL; | 792 | return -EINVAL; |
| 793 | 793 | ||
| 794 | f = fdget(fd); | 794 | f = fdget(fd); |
| 795 | if (f.file) { | 795 | if (fd_file(f)) { |
| 796 | ret = -ESPIPE; | 796 | ret = -ESPIPE; |
| 797 | if (f.file->f_mode & FMODE_PWRITE) | 797 | if (fd_file(f)->f_mode & FMODE_PWRITE) |
| 798 | ret = vfs_write(f.file, buf, count, &pos); | 798 | ret = vfs_write(fd_file(f), buf, count, &pos); |
| 799 | fdput(f); | 799 | fdput(f); |
| 800 | } | 800 | } |
| 801 | 801 | ||
| @@ -1078,15 +1078,15 @@ static ssize_t do_readv(unsigned long fd, const struct iovec __user *vec, · 276 unmodified lines | |||
| 1078 | struct fd f = fdget_pos(fd); | 1078 | struct fd f = fdget_pos(fd); |
| 1079 | ssize_t ret = -EBADF; | 1079 | ssize_t ret = -EBADF; |
| 1080 | 1080 | ||
| 1081 | if (f.file) { | 1081 | if (fd_file(f)) { |
| 1082 | loff_t pos, *ppos = file_ppos(f.file); | 1082 | loff_t pos, *ppos = file_ppos(fd_file(f)); |
| 1083 | if (ppos) { | 1083 | if (ppos) { |
| 1084 | pos = *ppos; | 1084 | pos = *ppos; |
| 1085 | ppos = &pos; | 1085 | ppos = &pos; |
| 1086 | } | 1086 | } |
| 1087 | ret = vfs_readv(f.file, vec, vlen, ppos, flags); | 1087 | ret = vfs_readv(fd_file(f), vec, vlen, ppos, flags); |
| 1088 | if (ret >= 0 && ppos) | 1088 | if (ret >= 0 && ppos) |
| 1089 | f.file->f_pos = pos; | 1089 | fd_file(f)->f_pos = pos; |
| 1090 | fdput_pos(f); | 1090 | fdput_pos(f); |
| 1091 | } | 1091 | } |
| 1092 | 1092 | ||
| @@ -1102,15 +1102,15 @@ static ssize_t do_writev(unsigned long fd, const struct iovec __user *vec, · 9 unmodified lines | |||
| 1102 | struct fd f = fdget_pos(fd); | 1102 | struct fd f = fdget_pos(fd); |
| 1103 | ssize_t ret = -EBADF; | 1103 | ssize_t ret = -EBADF; |
| 1104 | 1104 | ||
| 1105 | if (f.file) { | 1105 | if (fd_file(f)) { |
| 1106 | loff_t pos, *ppos = file_ppos(f.file); | 1106 | loff_t pos, *ppos = file_ppos(fd_file(f)); |
| 1107 | if (ppos) { | 1107 | if (ppos) { |
| 1108 | pos = *ppos; | 1108 | pos = *ppos; |
| 1109 | ppos = &pos; | 1109 | ppos = &pos; |
| 1110 | } | 1110 | } |
| 1111 | ret = vfs_writev(f.file, vec, vlen, ppos, flags); | 1111 | ret = vfs_writev(fd_file(f), vec, vlen, ppos, flags); |
| 1112 | if (ret >= 0 && ppos) | 1112 | if (ret >= 0 && ppos) |
| 1113 | f.file->f_pos = pos; | 1113 | fd_file(f)->f_pos = pos; |
| 1114 | fdput_pos(f); | 1114 | fdput_pos(f); |
| 1115 | } | 1115 | } |
| 1116 | 1116 | ||
| @@ -1136,10 +1136,10 @@ static ssize_t do_preadv(unsigned long fd, const struct iovec __user *vec, · 19 unmodified lines | |||
| 1136 | return -EINVAL; | 1136 | return -EINVAL; |
| 1137 | 1137 | ||
| 1138 | f = fdget(fd); | 1138 | f = fdget(fd); |
| 1139 | if (f.file) { | 1139 | if (fd_file(f)) { |
| 1140 | ret = -ESPIPE; | 1140 | ret = -ESPIPE; |
| 1141 | if (f.file->f_mode & FMODE_PREAD) | 1141 | if (fd_file(f)->f_mode & FMODE_PREAD) |
| 1142 | ret = vfs_readv(f.file, vec, vlen, &pos, flags); | 1142 | ret = vfs_readv(fd_file(f), vec, vlen, &pos, flags); |
| 1143 | fdput(f); | 1143 | fdput(f); |
| 1144 | } | 1144 | } |
| 1145 | 1145 | ||
| @@ -1159,10 +1159,10 @@ static ssize_t do_pwritev(unsigned long fd, const struct iovec __user *vec, · 13 unmodified lines | |||
| 1159 | return -EINVAL; | 1159 | return -EINVAL; |
| 1160 | 1160 | ||
| 1161 | f = fdget(fd); | 1161 | f = fdget(fd); |
| 1162 | if (f.file) { | 1162 | if (fd_file(f)) { |
| 1163 | ret = -ESPIPE; | 1163 | ret = -ESPIPE; |
| 1164 | if (f.file->f_mode & FMODE_PWRITE) | 1164 | if (fd_file(f)->f_mode & FMODE_PWRITE) |
| 1165 | ret = vfs_writev(f.file, vec, vlen, &pos, flags); | 1165 | ret = vfs_writev(fd_file(f), vec, vlen, &pos, flags); |
| 1166 | fdput(f); | 1166 | fdput(f); |
| 1167 | } | 1167 | } |
| 1168 | 1168 | ||
| @@ -1328,19 +1328,19 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 159 unmodified lines | |||
| 1328 | */ | 1328 | */ |
| 1329 | retval = -EBADF; | 1329 | retval = -EBADF; |
| 1330 | in = fdget(in_fd); | 1330 | in = fdget(in_fd); |
| 1331 | if (!in.file) | 1331 | if (!fd_file(in)) |
| 1332 | goto out; | 1332 | goto out; |
| 1333 | if (!(in.file->f_mode & FMODE_READ)) | 1333 | if (!(fd_file(in)->f_mode & FMODE_READ)) |
| 1334 | goto fput_in; | 1334 | goto fput_in; |
| 1335 | retval = -ESPIPE; | 1335 | retval = -ESPIPE; |
| 1336 | if (!ppos) { | 1336 | if (!ppos) { |
| 1337 | pos = in.file->f_pos; | 1337 | pos = fd_file(in)->f_pos; |
| 1338 | } else { | 1338 | } else { |
| 1339 | pos = *ppos; | 1339 | pos = *ppos; |
| 1340 | if (!(in.file->f_mode & FMODE_PREAD)) | 1340 | if (!(fd_file(in)->f_mode & FMODE_PREAD)) |
| 1341 | goto fput_in; | 1341 | goto fput_in; |
| 1342 | } | 1342 | } |
| 1343 | retval = rw_verify_area(READ, in.file, &pos, count); | 1343 | retval = rw_verify_area(READ, fd_file(in), &pos, count); |
| 1344 | if (retval < 0) | 1344 | if (retval < 0) |
| 1345 | goto fput_in; | 1345 | goto fput_in; |
| 1346 | if (count > MAX_RW_COUNT) | 1346 | if (count > MAX_RW_COUNT) |
| @@ -1351,13 +1351,13 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 4 unmodified lines | |||
| 1351 | */ | 1351 | */ |
| 1352 | retval = -EBADF; | 1352 | retval = -EBADF; |
| 1353 | out = fdget(out_fd); | 1353 | out = fdget(out_fd); |
| 1354 | if (!out.file) | 1354 | if (!fd_file(out)) |
| 1355 | goto fput_in; | 1355 | goto fput_in; |
| 1356 | if (!(out.file->f_mode & FMODE_WRITE)) | 1356 | if (!(fd_file(out)->f_mode & FMODE_WRITE)) |
| 1357 | goto fput_out; | 1357 | goto fput_out; |
| 1358 | in_inode = file_inode(in.file); | 1358 | in_inode = file_inode(fd_file(in)); |
| 1359 | out_inode = file_inode(out.file); | 1359 | out_inode = file_inode(fd_file(out)); |
| 1360 | out_pos = out.file->f_pos; | 1360 | out_pos = fd_file(out)->f_pos; |
| 1361 | 1361 | ||
| 1362 | if (!max) | 1362 | if (!max) |
| 1363 | max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes); | 1363 | max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes); |
| @@ -1377,33 +1377,33 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 13 unmodified lines | |||
| 1377 | * and the application is arguably buggy if it doesn't expect | 1377 | * and the application is arguably buggy if it doesn't expect |
| 1378 | * EAGAIN on a non-blocking file descriptor. | 1378 | * EAGAIN on a non-blocking file descriptor. |
| 1379 | */ | 1379 | */ |
| 1380 | if (in.file->f_flags & O_NONBLOCK) | 1380 | if (fd_file(in)->f_flags & O_NONBLOCK) |
| 1381 | fl = SPLICE_F_NONBLOCK; | 1381 | fl = SPLICE_F_NONBLOCK; |
| 1382 | #endif | 1382 | #endif |
| 1383 | opipe = get_pipe_info(out.file, true); | 1383 | opipe = get_pipe_info(fd_file(out), true); |
| 1384 | if (!opipe) { | 1384 | if (!opipe) { |
| 1385 | retval = rw_verify_area(WRITE, out.file, &out_pos, count); | 1385 | retval = rw_verify_area(WRITE, fd_file(out), &out_pos, count); |
| 1386 | if (retval < 0) | 1386 | if (retval < 0) |
| 1387 | goto fput_out; | 1387 | goto fput_out; |
| 1388 | retval = do_splice_direct(in.file, &pos, out.file, &out_pos, | 1388 | retval = do_splice_direct(fd_file(in), &pos, fd_file(out), &out_pos, |
| 1389 | count, fl); | 1389 | count, fl); |
| 1390 | } else { | 1390 | } else { |
| 1391 | if (out.file->f_flags & O_NONBLOCK) | 1391 | if (fd_file(out)->f_flags & O_NONBLOCK) |
| 1392 | fl |= SPLICE_F_NONBLOCK; | 1392 | fl |= SPLICE_F_NONBLOCK; |
| 1393 | 1393 | ||
| 1394 | retval = splice_file_to_pipe(in.file, opipe, &pos, count, fl); | 1394 | retval = splice_file_to_pipe(fd_file(in), opipe, &pos, count, fl); |
| 1395 | } | 1395 | } |
| 1396 | 1396 | ||
| 1397 | if (retval > 0) { | 1397 | if (retval > 0) { |
| 1398 | add_rchar(current, retval); | 1398 | add_rchar(current, retval); |
| 1399 | add_wchar(current, retval); | 1399 | add_wchar(current, retval); |
| 1400 | fsnotify_access(in.file); | 1400 | fsnotify_access(fd_file(in)); |
| 1401 | fsnotify_modify(out.file); | 1401 | fsnotify_modify(fd_file(out)); |
| 1402 | out.file->f_pos = out_pos; | 1402 | fd_file(out)->f_pos = out_pos; |
| 1403 | if (ppos) | 1403 | if (ppos) |
| 1404 | *ppos = pos; | 1404 | *ppos = pos; |
| 1405 | else | 1405 | else |
| 1406 | in.file->f_pos = pos; | 1406 | fd_file(in)->f_pos = pos; |
| 1407 | } | 1407 | } |
| 1408 | 1408 | ||
| 1409 | inc_syscr(current); | 1409 | inc_syscr(current); |
| @@ -1676,11 +1676,11 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 266 unmodified lines | |||
| 1676 | ssize_t ret = -EBADF; | 1676 | ssize_t ret = -EBADF; |
| 1677 | 1677 | ||
| 1678 | f_in = fdget(fd_in); | 1678 | f_in = fdget(fd_in); |
| 1679 | if (!f_in.file) | 1679 | if (!fd_file(f_in)) |
| 1680 | goto out2; | 1680 | goto out2; |
| 1681 | 1681 | ||
| 1682 | f_out = fdget(fd_out); | 1682 | f_out = fdget(fd_out); |
| 1683 | if (!f_out.file) | 1683 | if (!fd_file(f_out)) |
| 1684 | goto out1; | 1684 | goto out1; |
| 1685 | 1685 | ||
| 1686 | ret = -EFAULT; | 1686 | ret = -EFAULT; |
| @@ -1688,21 +1688,21 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 1 unmodified line | |||
| 1688 | if (copy_from_user(&pos_in, off_in, sizeof(loff_t))) | 1688 | if (copy_from_user(&pos_in, off_in, sizeof(loff_t))) |
| 1689 | goto out; | 1689 | goto out; |
| 1690 | } else { | 1690 | } else { |
| 1691 | pos_in = f_in.file->f_pos; | 1691 | pos_in = fd_file(f_in)->f_pos; |
| 1692 | } | 1692 | } |
| 1693 | 1693 | ||
| 1694 | if (off_out) { | 1694 | if (off_out) { |
| 1695 | if (copy_from_user(&pos_out, off_out, sizeof(loff_t))) | 1695 | if (copy_from_user(&pos_out, off_out, sizeof(loff_t))) |
| 1696 | goto out; | 1696 | goto out; |
| 1697 | } else { | 1697 | } else { |
| 1698 | pos_out = f_out.file->f_pos; | 1698 | pos_out = fd_file(f_out)->f_pos; |
| 1699 | } | 1699 | } |
| 1700 | 1700 | ||
| 1701 | ret = -EINVAL; | 1701 | ret = -EINVAL; |
| 1702 | if (flags != 0) | 1702 | if (flags != 0) |
| 1703 | goto out; | 1703 | goto out; |
| 1704 | 1704 | ||
| 1705 | ret = vfs_copy_file_range(f_in.file, pos_in, f_out.file, pos_out, len, | 1705 | ret = vfs_copy_file_range(fd_file(f_in), pos_in, fd_file(f_out), pos_out, len, |
| 1706 | flags); | 1706 | flags); |
| 1707 | if (ret > 0) { | 1707 | if (ret > 0) { |
| 1708 | pos_in += ret; | 1708 | pos_in += ret; |
| @@ -1712,14 +1712,14 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 3 unmodified lines | |||
| 1712 | if (copy_to_user(off_in, &pos_in, sizeof(loff_t))) | 1712 | if (copy_to_user(off_in, &pos_in, sizeof(loff_t))) |
| 1713 | ret = -EFAULT; | 1713 | ret = -EFAULT; |
| 1714 | } else { | 1714 | } else { |
| 1715 | f_in.file->f_pos = pos_in; | 1715 | fd_file(f_in)->f_pos = pos_in; |
| 1716 | } | 1716 | } |
| 1717 | 1717 | ||
| 1718 | if (off_out) { | 1718 | if (off_out) { |
| 1719 | if (copy_to_user(off_out, &pos_out, sizeof(loff_t))) | 1719 | if (copy_to_user(off_out, &pos_out, sizeof(loff_t))) |
| 1720 | ret = -EFAULT; | 1720 | ret = -EFAULT; |
| 1721 | } else { | 1721 | } else { |
| 1722 | f_out.file->f_pos = pos_out; | 1722 | fd_file(f_out)->f_pos = pos_out; |
| 1723 | } | 1723 | } |
| 1724 | } | 1724 | } |
| 1725 | 1725 | ||
| @@ -225,10 +225,10 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, · 224 unmodified lines | |||
| 225 | .dirent = dirent | 225 | .dirent = dirent |
| 226 | }; | 226 | }; |
| 227 | 227 | ||
| 228 | if (!f.file) | 228 | if (!fd_file(f)) |
| 229 | return -EBADF; | 229 | return -EBADF; |
| 230 | 230 | ||
| 231 | error = iterate_dir(f.file, &buf.ctx); | 231 | error = iterate_dir(fd_file(f), &buf.ctx); |
| 232 | if (buf.result) | 232 | if (buf.result) |
| 233 | error = buf.result; | 233 | error = buf.result; |
| 234 | 234 | ||
| @@ -318,10 +318,10 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, · 83 unmodified lines | |||
| 318 | int error; | 318 | int error; |
| 319 | 319 | ||
| 320 | f = fdget_pos(fd); | 320 | f = fdget_pos(fd); |
| 321 | if (!f.file) | 321 | if (!fd_file(f)) |
| 322 | return -EBADF; | 322 | return -EBADF; |
| 323 | 323 | ||
| 324 | error = iterate_dir(f.file, &buf.ctx); | 324 | error = iterate_dir(fd_file(f), &buf.ctx); |
| 325 | if (error >= 0) | 325 | if (error >= 0) |
| 326 | error = buf.error; | 326 | error = buf.error; |
| 327 | if (buf.prev_reclen) { | 327 | if (buf.prev_reclen) { |
| @@ -401,10 +401,10 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, · 73 unmodified lines | |||
| 401 | int error; | 401 | int error; |
| 402 | 402 | ||
| 403 | f = fdget_pos(fd); | 403 | f = fdget_pos(fd); |
| 404 | if (!f.file) | 404 | if (!fd_file(f)) |
| 405 | return -EBADF; | 405 | return -EBADF; |
| 406 | 406 | ||
| 407 | error = iterate_dir(f.file, &buf.ctx); | 407 | error = iterate_dir(fd_file(f), &buf.ctx); |
| 408 | if (error >= 0) | 408 | if (error >= 0) |
| 409 | error = buf.error; | 409 | error = buf.error; |
| 410 | if (buf.prev_reclen) { | 410 | if (buf.prev_reclen) { |
| @@ -483,10 +483,10 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd, · 72 unmodified lines | |||
| 483 | .dirent = dirent | 483 | .dirent = dirent |
| 484 | }; | 484 | }; |
| 485 | 485 | ||
| 486 | if (!f.file) | 486 | if (!fd_file(f)) |
| 487 | return -EBADF; | 487 | return -EBADF; |
| 488 | 488 | ||
| 489 | error = iterate_dir(f.file, &buf.ctx); | 489 | error = iterate_dir(fd_file(f), &buf.ctx); |
| 490 | if (buf.result) | 490 | if (buf.result) |
| 491 | error = buf.result; | 491 | error = buf.result; |
| 492 | 492 | ||
| @@ -569,10 +569,10 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd, · 76 unmodified lines | |||
| 569 | int error; | 569 | int error; |
| 570 | 570 | ||
| 571 | f = fdget_pos(fd); | 571 | f = fdget_pos(fd); |
| 572 | if (!f.file) | 572 | if (!fd_file(f)) |
| 573 | return -EBADF; | 573 | return -EBADF; |
| 574 | 574 | ||
| 575 | error = iterate_dir(f.file, &buf.ctx); | 575 | error = iterate_dir(fd_file(f), &buf.ctx); |
| 576 | if (error >= 0) | 576 | if (error >= 0) |
| 577 | error = buf.error; | 577 | error = buf.error; |
| 578 | if (buf.prev_reclen) { | 578 | if (buf.prev_reclen) { |
| @@ -537,7 +537,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) · 536 unmodified lines | |||
| 537 | 537 | ||
| 538 | for (i = 0, info = same->info; i < count; i++, info++) { | 538 | for (i = 0, info = same->info; i < count; i++, info++) { |
| 539 | struct fd dst_fd = fdget(info->dest_fd); | 539 | struct fd dst_fd = fdget(info->dest_fd); |
| 540 | struct file *dst_file = dst_fd.file; | 540 | struct file *dst_file = fd_file(dst_fd); |
| 541 | 541 | ||
| 542 | if (!dst_file) { | 542 | if (!dst_file) { |
| 543 | info->status = -EBADF; | 543 | info->status = -EBADF; |
| @@ -529,10 +529,10 @@ static noinline_for_stack int do_select(int n, fd_set_bits *fds, struct timespec · 528 unmodified lines | |||
| 529 | continue; | 529 | continue; |
| 530 | mask = EPOLLNVAL; | 530 | mask = EPOLLNVAL; |
| 531 | f = fdget(i); | 531 | f = fdget(i); |
| 532 | if (f.file) { | 532 | if (fd_file(f)) { |
| 533 | wait_key_set(wait, in, out, bit, | 533 | wait_key_set(wait, in, out, bit, |
| 534 | busy_flag); | 534 | busy_flag); |
| 535 | mask = vfs_poll(f.file, wait); | 535 | mask = vfs_poll(fd_file(f), wait); |
| 536 | 536 | ||
| 537 | fdput(f); | 537 | fdput(f); |
| 538 | } | 538 | } |
| @@ -863,13 +863,13 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, · 324 unmodified lines | |||
| 863 | goto out; | 863 | goto out; |
| 864 | mask = EPOLLNVAL; | 864 | mask = EPOLLNVAL; |
| 865 | f = fdget(fd); | 865 | f = fdget(fd); |
| 866 | if (!f.file) | 866 | if (!fd_file(f)) |
| 867 | goto out; | 867 | goto out; |
| 868 | 868 | ||
| 869 | /* userland u16 ->events contains POLL... bitmap */ | 869 | /* userland u16 ->events contains POLL... bitmap */ |
| 870 | filter = demangle_poll(pollfd->events) | EPOLLERR | EPOLLHUP; | 870 | filter = demangle_poll(pollfd->events) | EPOLLERR | EPOLLHUP; |
| 871 | pwait->_key = filter | busy_flag; | 871 | pwait->_key = filter | busy_flag; |
| 872 | mask = vfs_poll(f.file, pwait); | 872 | mask = vfs_poll(fd_file(f), pwait); |
| 873 | if (mask & busy_flag) | 873 | if (mask & busy_flag) |
| 874 | *can_busy_poll = true; | 874 | *can_busy_poll = true; |
| 875 | mask &= filter; /* Mask out unneeded events. */ | 875 | mask &= filter; /* Mask out unneeded events. */ |
| @@ -289,10 +289,10 @@ static int do_signalfd4(int ufd, sigset_t *mask, int flags) · 288 unmodified lines | |||
| 289 | fd_install(ufd, file); | 289 | fd_install(ufd, file); |
| 290 | } else { | 290 | } else { |
| 291 | struct fd f = fdget(ufd); | 291 | struct fd f = fdget(ufd); |
| 292 | if (!f.file) | 292 | if (!fd_file(f)) |
| 293 | return -EBADF; | 293 | return -EBADF; |
| 294 | ctx = f.file->private_data; | 294 | ctx = fd_file(f)->private_data; |
| 295 | if (f.file->f_op != &signalfd_fops) { | 295 | if (fd_file(f)->f_op != &signalfd_fops) { |
| 296 | fdput(f); | 296 | fdput(f); |
| 297 | return -EINVAL; | 297 | return -EINVAL; |
| 298 | } | 298 | } |
| @@ -90,23 +90,23 @@ static long cifs_ioctl_copychunk(unsigned int xid, struct file *dst_file, · 89 unmodified lines | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | src_file = fdget(srcfd); | 92 | src_file = fdget(srcfd); |
| 93 | if (!src_file.file) { | 93 | if (!fd_file(src_file)) { |
| 94 | rc = -EBADF; | 94 | rc = -EBADF; |
| 95 | goto out_drop_write; | 95 | goto out_drop_write; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | if (src_file.file->f_op->unlocked_ioctl != cifs_ioctl) { | 98 | if (fd_file(src_file)->f_op->unlocked_ioctl != cifs_ioctl) { |
| 99 | rc = -EBADF; | 99 | rc = -EBADF; |
| 100 | cifs_dbg(VFS, "src file seems to be from a different filesystem type\n"); | 100 | cifs_dbg(VFS, "src file seems to be from a different filesystem type\n"); |
| 101 | goto out_fput; | 101 | goto out_fput; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | src_inode = file_inode(src_file.file); | 104 | src_inode = file_inode(fd_file(src_file)); |
| 105 | rc = -EINVAL; | 105 | rc = -EINVAL; |
| 106 | if (S_ISDIR(src_inode->i_mode)) | 106 | if (S_ISDIR(src_inode->i_mode)) |
| 107 | goto out_fput; | 107 | goto out_fput; |
| 108 | 108 | ||
| 109 | rc = cifs_file_copychunk_range(xid, src_file.file, 0, dst_file, 0, | 109 | rc = cifs_file_copychunk_range(xid, fd_file(src_file), 0, dst_file, 0, |
| 110 | src_inode->i_size, 0); | 110 | src_inode->i_size, 0); |
| 111 | if (rc > 0) | 111 | if (rc > 0) |
| 112 | rc = 0; | 112 | rc = 0; |
| @@ -1566,11 +1566,11 @@ static ssize_t vmsplice_to_pipe(struct file *file, struct iov_iter *iter, · 1565 unmodified lines | |||
| 1566 | 1566 | ||
| 1567 | static int vmsplice_type(struct fd f, int *type) | 1567 | static int vmsplice_type(struct fd f, int *type) |
| 1568 | { | 1568 | { |
| 1569 | if (!f.file) | 1569 | if (!fd_file(f)) |
| 1570 | return -EBADF; | 1570 | return -EBADF; |
| 1571 | if (f.file->f_mode & FMODE_WRITE) { | 1571 | if (fd_file(f)->f_mode & FMODE_WRITE) { |
| 1572 | *type = ITER_SOURCE; | 1572 | *type = ITER_SOURCE; |
| 1573 | } else if (f.file->f_mode & FMODE_READ) { | 1573 | } else if (fd_file(f)->f_mode & FMODE_READ) { |
| 1574 | *type = ITER_DEST; | 1574 | *type = ITER_DEST; |
| 1575 | } else { | 1575 | } else { |
| 1576 | fdput(f); | 1576 | fdput(f); |
| @@ -1621,9 +1621,9 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov, · 44 unmodified lines | |||
| 1621 | if (!iov_iter_count(&iter)) | 1621 | if (!iov_iter_count(&iter)) |
| 1622 | error = 0; | 1622 | error = 0; |
| 1623 | else if (type == ITER_SOURCE) | 1623 | else if (type == ITER_SOURCE) |
| 1624 | error = vmsplice_to_pipe(f.file, &iter, flags); | 1624 | error = vmsplice_to_pipe(fd_file(f), &iter, flags); |
| 1625 | else | 1625 | else |
| 1626 | error = vmsplice_to_user(f.file, &iter, flags); | 1626 | error = vmsplice_to_user(fd_file(f), &iter, flags); |
| 1627 | 1627 | ||
| 1628 | kfree(iov); | 1628 | kfree(iov); |
| 1629 | out_fdput: | 1629 | out_fdput: |
| @@ -1646,10 +1646,10 @@ SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in, · 16 unmodified lines | |||
| 1646 | 1646 | ||
| 1647 | error = -EBADF; | 1647 | error = -EBADF; |
| 1648 | in = fdget(fd_in); | 1648 | in = fdget(fd_in); |
| 1649 | if (in.file) { | 1649 | if (fd_file(in)) { |
| 1650 | out = fdget(fd_out); | 1650 | out = fdget(fd_out); |
| 1651 | if (out.file) { | 1651 | if (fd_file(out)) { |
| 1652 | error = __do_splice(in.file, off_in, out.file, off_out, | 1652 | error = __do_splice(fd_file(in), off_in, fd_file(out), off_out, |
| 1653 | len, flags); | 1653 | len, flags); |
| 1654 | fdput(out); | 1654 | fdput(out); |
| 1655 | } | 1655 | } |
| @@ -2016,10 +2016,10 @@ SYSCALL_DEFINE4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags) · 360 unmodified lines | |||
| 2016 | 2016 | ||
| 2017 | error = -EBADF; | 2017 | error = -EBADF; |
| 2018 | in = fdget(fdin); | 2018 | in = fdget(fdin); |
| 2019 | if (in.file) { | 2019 | if (fd_file(in)) { |
| 2020 | out = fdget(fdout); | 2020 | out = fdget(fdout); |
| 2021 | if (out.file) { | 2021 | if (fd_file(out)) { |
| 2022 | error = do_tee(in.file, out.file, len, flags); | 2022 | error = do_tee(fd_file(in), fd_file(out), len, flags); |
| 2023 | fdput(out); | 2023 | fdput(out); |
| 2024 | } | 2024 | } |
| 2025 | fdput(in); | 2025 | fdput(in); |
| @@ -224,9 +224,9 @@ int vfs_fstat(int fd, struct kstat *stat) · 223 unmodified lines | |||
| 224 | int error; | 224 | int error; |
| 225 | 225 | ||
| 226 | f = fdget_raw(fd); | 226 | f = fdget_raw(fd); |
| 227 | if (!f.file) | 227 | if (!fd_file(f)) |
| 228 | return -EBADF; | 228 | return -EBADF; |
| 229 | error = vfs_getattr(&f.file->f_path, stat, STATX_BASIC_STATS, 0); | 229 | error = vfs_getattr(&fd_file(f)->f_path, stat, STATX_BASIC_STATS, 0); |
| 230 | fdput(f); | 230 | fdput(f); |
| 231 | return error; | 231 | return error; |
| 232 | } | 232 | } |
| @@ -277,9 +277,9 @@ static int vfs_statx_fd(int fd, int flags, struct kstat *stat, · 44 unmodified lines | |||
| 277 | u32 request_mask) | 277 | u32 request_mask) |
| 278 | { | 278 | { |
| 279 | CLASS(fd_raw, f)(fd); | 279 | CLASS(fd_raw, f)(fd); |
| 280 | if (!f.file) | 280 | if (!fd_file(f)) |
| 281 | return -EBADF; | 281 | return -EBADF; |
| 282 | return vfs_statx_path(&f.file->f_path, flags, stat, request_mask); | 282 | return vfs_statx_path(&fd_file(f)->f_path, flags, stat, request_mask); |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | /** | 285 | /** |
| @@ -116,8 +116,8 @@ int fd_statfs(int fd, struct kstatfs *st) · 115 unmodified lines | |||
| 116 | { | 116 | { |
| 117 | struct fd f = fdget_raw(fd); | 117 | struct fd f = fdget_raw(fd); |
| 118 | int error = -EBADF; | 118 | int error = -EBADF; |
| 119 | if (f.file) { | 119 | if (fd_file(f)) { |
| 120 | error = vfs_statfs(&f.file->f_path, st); | 120 | error = vfs_statfs(&fd_file(f)->f_path, st); |
| 121 | fdput(f); | 121 | fdput(f); |
| 122 | } | 122 | } |
| 123 | return error; | 123 | return error; |
| @@ -152,15 +152,15 @@ SYSCALL_DEFINE1(syncfs, int, fd) · 151 unmodified lines | |||
| 152 | struct super_block *sb; | 152 | struct super_block *sb; |
| 153 | int ret, ret2; | 153 | int ret, ret2; |
| 154 | 154 | ||
| 155 | if (!f.file) | 155 | if (!fd_file(f)) |
| 156 | return -EBADF; | 156 | return -EBADF; |
| 157 | sb = f.file->f_path.dentry->d_sb; | 157 | sb = fd_file(f)->f_path.dentry->d_sb; |
| 158 | 158 | ||
| 159 | down_read(&sb->s_umount); | 159 | down_read(&sb->s_umount); |
| 160 | ret = sync_filesystem(sb); | 160 | ret = sync_filesystem(sb); |
| 161 | up_read(&sb->s_umount); | 161 | up_read(&sb->s_umount); |
| 162 | 162 | ||
| 163 | ret2 = errseq_check_and_advance(&sb->s_wb_err, &f.file->f_sb_err); | 163 | ret2 = errseq_check_and_advance(&sb->s_wb_err, &fd_file(f)->f_sb_err); |
| 164 | 164 | ||
| 165 | fdput(f); | 165 | fdput(f); |
| 166 | return ret ? ret : ret2; | 166 | return ret ? ret : ret2; |
| @@ -208,8 +208,8 @@ static int do_fsync(unsigned int fd, int datasync) · 41 unmodified lines | |||
| 208 | struct fd f = fdget(fd); | 208 | struct fd f = fdget(fd); |
| 209 | int ret = -EBADF; | 209 | int ret = -EBADF; |
| 210 | 210 | ||
| 211 | if (f.file) { | 211 | if (fd_file(f)) { |
| 212 | ret = vfs_fsync(f.file, datasync); | 212 | ret = vfs_fsync(fd_file(f), datasync); |
| 213 | fdput(f); | 213 | fdput(f); |
| 214 | } | 214 | } |
| 215 | return ret; | 215 | return ret; |
| @@ -360,8 +360,8 @@ int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes, · 144 unmodified lines | |||
| 360 | 360 | ||
| 361 | ret = -EBADF; | 361 | ret = -EBADF; |
| 362 | f = fdget(fd); | 362 | f = fdget(fd); |
| 363 | if (f.file) | 363 | if (fd_file(f)) |
| 364 | ret = sync_file_range(f.file, offset, nbytes, flags); | 364 | ret = sync_file_range(fd_file(f), offset, nbytes, flags); |
| 365 | 365 | ||
| 366 | fdput(f); | 366 | fdput(f); |
| 367 | return ret; | 367 | return ret; |
| @@ -397,9 +397,9 @@ static const struct file_operations timerfd_fops = { · 396 unmodified lines | |||
| 397 | static int timerfd_fget(int fd, struct fd *p) | 397 | static int timerfd_fget(int fd, struct fd *p) |
| 398 | { | 398 | { |
| 399 | struct fd f = fdget(fd); | 399 | struct fd f = fdget(fd); |
| 400 | if (!f.file) | 400 | if (!fd_file(f)) |
| 401 | return -EBADF; | 401 | return -EBADF; |
| 402 | if (f.file->f_op != &timerfd_fops) { | 402 | if (fd_file(f)->f_op != &timerfd_fops) { |
| 403 | fdput(f); | 403 | fdput(f); |
| 404 | return -EINVAL; | 404 | return -EINVAL; |
| 405 | } | 405 | } |
| @@ -482,7 +482,7 @@ static int do_timerfd_settime(int ufd, int flags, · 76 unmodified lines | |||
| 482 | ret = timerfd_fget(ufd, &f); | 482 | ret = timerfd_fget(ufd, &f); |
| 483 | if (ret) | 483 | if (ret) |
| 484 | return ret; | 484 | return ret; |
| 485 | ctx = f.file->private_data; | 485 | ctx = fd_file(f)->private_data; |
| 486 | 486 | ||
| 487 | if (isalarm(ctx) && !capable(CAP_WAKE_ALARM)) { | 487 | if (isalarm(ctx) && !capable(CAP_WAKE_ALARM)) { |
| 488 | fdput(f); | 488 | fdput(f); |
| @@ -546,7 +546,7 @@ static int do_timerfd_gettime(int ufd, struct itimerspec64 *t) · 57 unmodified lines | |||
| 546 | int ret = timerfd_fget(ufd, &f); | 546 | int ret = timerfd_fget(ufd, &f); |
| 547 | if (ret) | 547 | if (ret) |
| 548 | return ret; | 548 | return ret; |
| 549 | ctx = f.file->private_data; | 549 | ctx = fd_file(f)->private_data; |
| 550 | 550 | ||
| 551 | spin_lock_irq(&ctx->wqh.lock); | 551 | spin_lock_irq(&ctx->wqh.lock); |
| 552 | if (ctx->expired && ctx->tintv) { | 552 | if (ctx->expired && ctx->tintv) { |
| @@ -115,9 +115,9 @@ static int do_utimes_fd(int fd, struct timespec64 *times, int flags) · 114 unmodified lines | |||
| 115 | return -EINVAL; | 115 | return -EINVAL; |
| 116 | 116 | ||
| 117 | f = fdget(fd); | 117 | f = fdget(fd); |
| 118 | if (!f.file) | 118 | if (!fd_file(f)) |
| 119 | return -EBADF; | 119 | return -EBADF; |
| 120 | error = vfs_utimes(&f.file->f_path, times); | 120 | error = vfs_utimes(&fd_file(f)->f_path, times); |
| 121 | fdput(f); | 121 | fdput(f); |
| 122 | return error; | 122 | return error; |
| 123 | } | 123 | } |
| @@ -697,19 +697,19 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, · 696 unmodified lines | |||
| 697 | int error; | 697 | int error; |
| 698 | 698 | ||
| 699 | CLASS(fd, f)(fd); | 699 | CLASS(fd, f)(fd); |
| 700 | if (!f.file) | 700 | if (!fd_file(f)) |
| 701 | return -EBADF; | 701 | return -EBADF; |
| 702 | 702 | ||
| 703 | audit_file(f.file); | 703 | audit_file(fd_file(f)); |
| 704 | error = setxattr_copy(name, &ctx); | 704 | error = setxattr_copy(name, &ctx); |
| 705 | if (error) | 705 | if (error) |
| 706 | return error; | 706 | return error; |
| 707 | 707 | ||
| 708 | error = mnt_want_write_file(f.file); | 708 | error = mnt_want_write_file(fd_file(f)); |
| 709 | if (!error) { | 709 | if (!error) { |
| 710 | error = do_setxattr(file_mnt_idmap(f.file), | 710 | error = do_setxattr(file_mnt_idmap(fd_file(f)), |
| 711 | f.file->f_path.dentry, &ctx); | 711 | fd_file(f)->f_path.dentry, &ctx); |
| 712 | mnt_drop_write_file(f.file); | 712 | mnt_drop_write_file(fd_file(f)); |
| 713 | } | 713 | } |
| 714 | kvfree(ctx.kvalue); | 714 | kvfree(ctx.kvalue); |
| 715 | return error; | 715 | return error; |
| @@ -812,10 +812,10 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, · 96 unmodified lines | |||
| 812 | struct fd f = fdget(fd); | 812 | struct fd f = fdget(fd); |
| 813 | ssize_t error = -EBADF; | 813 | ssize_t error = -EBADF; |
| 814 | 814 | ||
| 815 | if (!f.file) | 815 | if (!fd_file(f)) |
| 816 | return error; | 816 | return error; |
| 817 | audit_file(f.file); | 817 | audit_file(fd_file(f)); |
| 818 | error = getxattr(file_mnt_idmap(f.file), f.file->f_path.dentry, | 818 | error = getxattr(file_mnt_idmap(fd_file(f)), fd_file(f)->f_path.dentry, |
| 819 | name, value, size); | 819 | name, value, size); |
| 820 | fdput(f); | 820 | fdput(f); |
| 821 | return error; | 821 | return error; |
| @@ -888,10 +888,10 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) · 66 unmodified lines | |||
| 888 | struct fd f = fdget(fd); | 888 | struct fd f = fdget(fd); |
| 889 | ssize_t error = -EBADF; | 889 | ssize_t error = -EBADF; |
| 890 | 890 | ||
| 891 | if (!f.file) | 891 | if (!fd_file(f)) |
| 892 | return error; | 892 | return error; |
| 893 | audit_file(f.file); | 893 | audit_file(fd_file(f)); |
| 894 | error = listxattr(f.file->f_path.dentry, list, size); | 894 | error = listxattr(fd_file(f)->f_path.dentry, list, size); |
| 895 | fdput(f); | 895 | fdput(f); |
| 896 | return error; | 896 | return error; |
| 897 | } | 897 | } |
| @@ -954,9 +954,9 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) · 56 unmodified lines | |||
| 954 | char kname[XATTR_NAME_MAX + 1]; | 954 | char kname[XATTR_NAME_MAX + 1]; |
| 955 | int error = -EBADF; | 955 | int error = -EBADF; |
| 956 | 956 | ||
| 957 | if (!f.file) | 957 | if (!fd_file(f)) |
| 958 | return error; | 958 | return error; |
| 959 | audit_file(f.file); | 959 | audit_file(fd_file(f)); |
| 960 | 960 | ||
| 961 | error = strncpy_from_user(kname, name, sizeof(kname)); | 961 | error = strncpy_from_user(kname, name, sizeof(kname)); |
| 962 | if (error == 0 || error == sizeof(kname)) | 962 | if (error == 0 || error == sizeof(kname)) |
| @@ -964,11 +964,11 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) · 1 unmodified line | |||
| 964 | if (error < 0) | 964 | if (error < 0) |
| 965 | return error; | 965 | return error; |
| 966 | 966 | ||
| 967 | error = mnt_want_write_file(f.file); | 967 | error = mnt_want_write_file(fd_file(f)); |
| 968 | if (!error) { | 968 | if (!error) { |
| 969 | error = removexattr(file_mnt_idmap(f.file), | 969 | error = removexattr(file_mnt_idmap(fd_file(f)), |
| 970 | f.file->f_path.dentry, kname); | 970 | fd_file(f)->f_path.dentry, kname); |
| 971 | mnt_drop_write_file(f.file); | 971 | mnt_drop_write_file(fd_file(f)); |
| 972 | } | 972 | } |
| 973 | fdput(f); | 973 | fdput(f); |
| 974 | return error; | 974 | return error; |
| @@ -829,9 +829,9 @@ xfs_ioc_exchange_range( · 828 unmodified lines | |||
| 829 | fxr.flags = args.flags; | 829 | fxr.flags = args.flags; |
| 830 | 830 | ||
| 831 | file1 = fdget(args.file1_fd); | 831 | file1 = fdget(args.file1_fd); |
| 832 | if (!file1.file) | 832 | if (!fd_file(file1)) |
| 833 | return -EBADF; | 833 | return -EBADF; |
| 834 | fxr.file1 = file1.file; | 834 | fxr.file1 = fd_file(file1); |
| 835 | 835 | ||
| 836 | error = xfs_exchange_range(&fxr); | 836 | error = xfs_exchange_range(&fxr); |
| 837 | fdput(file1); | 837 | fdput(file1); |
| @@ -935,9 +935,9 @@ xfs_ioc_commit_range( · 97 unmodified lines | |||
| 935 | fxr.file2_ctime.tv_nsec = kern_f->file2_ctime_nsec; | 935 | fxr.file2_ctime.tv_nsec = kern_f->file2_ctime_nsec; |
| 936 | 936 | ||
| 937 | file1 = fdget(args.file1_fd); | 937 | file1 = fdget(args.file1_fd); |
| 938 | if (!file1.file) | 938 | if (fd_empty(file1)) |
| 939 | return -EBADF; | 939 | return -EBADF; |
| 940 | fxr.file1 = file1.file; | 940 | fxr.file1 = fd_file(file1); |
| 941 | 941 | ||
| 942 | error = xfs_exchange_range(&fxr); | 942 | error = xfs_exchange_range(&fxr); |
| 943 | fdput(file1); | 943 | fdput(file1); |
| @@ -85,16 +85,16 @@ xfs_find_handle( · 84 unmodified lines | |||
| 85 | int hsize; | 85 | int hsize; |
| 86 | xfs_handle_t handle; | 86 | xfs_handle_t handle; |
| 87 | struct inode *inode; | 87 | struct inode *inode; |
| 88 | struct fd f = {NULL}; | 88 | struct fd f = EMPTY_FD; |
| 89 | struct path path; | 89 | struct path path; |
| 90 | int error; | 90 | int error; |
| 91 | struct xfs_inode *ip; | 91 | struct xfs_inode *ip; |
| 92 | 92 | ||
| 93 | if (cmd == XFS_IOC_FD_TO_HANDLE) { | 93 | if (cmd == XFS_IOC_FD_TO_HANDLE) { |
| 94 | f = fdget(hreq->fd); | 94 | f = fdget(hreq->fd); |
| 95 | if (!f.file) | 95 | if (!fd_file(f)) |
| 96 | return -EBADF; | 96 | return -EBADF; |
| 97 | inode = file_inode(f.file); | 97 | inode = file_inode(fd_file(f)); |
| 98 | } else { | 98 | } else { |
| 99 | error = user_path_at(AT_FDCWD, hreq->path, 0, &path); | 99 | error = user_path_at(AT_FDCWD, hreq->path, 0, &path); |
| 100 | if (error) | 100 | if (error) |
| @@ -886,33 +886,33 @@ xfs_ioc_swapext( · 885 unmodified lines | |||
| 886 | 886 | ||
| 887 | /* Pull information for the target fd */ | 887 | /* Pull information for the target fd */ |
| 888 | f = fdget((int)sxp->sx_fdtarget); | 888 | f = fdget((int)sxp->sx_fdtarget); |
| 889 | if (!f.file) { | 889 | if (!fd_file(f)) { |
| 890 | error = -EINVAL; | 890 | error = -EINVAL; |
| 891 | goto out; | 891 | goto out; |
| 892 | } | 892 | } |
| 893 | 893 | ||
| 894 | if (!(f.file->f_mode & FMODE_WRITE) || | 894 | if (!(fd_file(f)->f_mode & FMODE_WRITE) || |
| 895 | !(f.file->f_mode & FMODE_READ) || | 895 | !(fd_file(f)->f_mode & FMODE_READ) || |
| 896 | (f.file->f_flags & O_APPEND)) { | 896 | (fd_file(f)->f_flags & O_APPEND)) { |
| 897 | error = -EBADF; | 897 | error = -EBADF; |
| 898 | goto out_put_file; | 898 | goto out_put_file; |
| 899 | } | 899 | } |
| 900 | 900 | ||
| 901 | tmp = fdget((int)sxp->sx_fdtmp); | 901 | tmp = fdget((int)sxp->sx_fdtmp); |
| 902 | if (!tmp.file) { | 902 | if (!fd_file(tmp)) { |
| 903 | error = -EINVAL; | 903 | error = -EINVAL; |
| 904 | goto out_put_file; | 904 | goto out_put_file; |
| 905 | } | 905 | } |
| 906 | 906 | ||
| 907 | if (!(tmp.file->f_mode & FMODE_WRITE) || | 907 | if (!(fd_file(tmp)->f_mode & FMODE_WRITE) || |
| 908 | !(tmp.file->f_mode & FMODE_READ) || | 908 | !(fd_file(tmp)->f_mode & FMODE_READ) || |
| 909 | (tmp.file->f_flags & O_APPEND)) { | 909 | (fd_file(tmp)->f_flags & O_APPEND)) { |
| 910 | error = -EBADF; | 910 | error = -EBADF; |
| 911 | goto out_put_tmp_file; | 911 | goto out_put_tmp_file; |
| 912 | } | 912 | } |
| 913 | 913 | ||
| 914 | if (IS_SWAPFILE(file_inode(f.file)) || | 914 | if (IS_SWAPFILE(file_inode(fd_file(f))) || |
| 915 | IS_SWAPFILE(file_inode(tmp.file))) { | 915 | IS_SWAPFILE(file_inode(fd_file(tmp)))) { |
| 916 | error = -EINVAL; | 916 | error = -EINVAL; |
| 917 | goto out_put_tmp_file; | 917 | goto out_put_tmp_file; |
| 918 | } | 918 | } |
| @@ -922,14 +922,14 @@ xfs_ioc_swapext( · 3 unmodified lines | |||
| 922 | * before we cast and access them as XFS structures as we have no | 922 | * before we cast and access them as XFS structures as we have no |
| 923 | * control over what the user passes us here. | 923 | * control over what the user passes us here. |
| 924 | */ | 924 | */ |
| 925 | if (f.file->f_op != &xfs_file_operations || | 925 | if (fd_file(f)->f_op != &xfs_file_operations || |
| 926 | tmp.file->f_op != &xfs_file_operations) { | 926 | fd_file(tmp)->f_op != &xfs_file_operations) { |
| 927 | error = -EINVAL; | 927 | error = -EINVAL; |
| 928 | goto out_put_tmp_file; | 928 | goto out_put_tmp_file; |
| 929 | } | 929 | } |
| 930 | 930 | ||
| 931 | ip = XFS_I(file_inode(f.file)); | 931 | ip = XFS_I(file_inode(fd_file(f))); |
| 932 | tip = XFS_I(file_inode(tmp.file)); | 932 | tip = XFS_I(file_inode(fd_file(tmp))); |
| 933 | 933 | ||
| 934 | if (ip->i_mount != tip->i_mount) { | 934 | if (ip->i_mount != tip->i_mount) { |
| 935 | error = -EINVAL; | 935 | error = -EINVAL; |
| @@ -98,7 +98,7 @@ const volatile void * __must_check_fn(const volatile void *val) · 97 unmodified lines | |||
| 98 | * DEFINE_CLASS(fdget, struct fd, fdput(_T), fdget(fd), int fd) | 98 | * DEFINE_CLASS(fdget, struct fd, fdput(_T), fdget(fd), int fd) |
| 99 | * | 99 | * |
| 100 | * CLASS(fdget, f)(fd); | 100 | * CLASS(fdget, f)(fd); |
| 101 | * if (!f.file) | 101 | * if (!fd_file(f)) |
| 102 | * return -EBADF; | 102 | * return -EBADF; |
| 103 | * | 103 | * |
| 104 | * // use 'f' without concern | 104 | * // use 'f' without concern |
| @@ -36,51 +36,52 @@ static inline void fput_light(struct file *file, int fput_needed) · 35 unmodified lines | |||
| 36 | fput(file); | 36 | fput(file); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | /* either a reference to struct file + flags | ||
| 40 | * (cloned vs. borrowed, pos locked), with | ||
| 41 | * flags stored in lower bits of value, | ||
| 42 | * or empty (represented by 0). | ||
| 43 | */ | ||
| 39 | struct fd { | 44 | struct fd { |
| 40 | struct file *file; | 45 | unsigned long word; |
| 41 | unsigned int flags; | ||
| 42 | }; | 46 | }; |
| 43 | #define FDPUT_FPUT 1 | 47 | #define FDPUT_FPUT 1 |
| 44 | #define FDPUT_POS_UNLOCK 2 | 48 | #define FDPUT_POS_UNLOCK 2 |
| 45 | 49 | ||
| 46 | static inline void fdput(struct fd fd) | 50 | #define fd_file(f) ((struct file *)((f).word & ~(FDPUT_FPUT|FDPUT_POS_UNLOCK))) |
| 51 | static inline bool fd_empty(struct fd f) | ||
| 47 | { | 52 | { |
| 48 | if (fd.flags & FDPUT_FPUT) | 53 | return unlikely(!f.word); |
| 49 | fput(fd.file); | ||
| 50 | } | 54 | } |
| 51 | 55 | ||
| 52 | extern struct file *fget(unsigned int fd); | 56 | #define EMPTY_FD (struct fd){0} |
| 53 | extern struct file *fget_raw(unsigned int fd); | 57 | static inline struct fd BORROWED_FD(struct file *f) |
| 54 | extern struct file *fget_task(struct task_struct *task, unsigned int fd); | ||
| 55 | extern unsigned long __fdget(unsigned int fd); | ||
| 56 | extern unsigned long __fdget_raw(unsigned int fd); | ||
| 57 | extern unsigned long __fdget_pos(unsigned int fd); | ||
| 58 | extern void __f_unlock_pos(struct file *); | ||
| 59 | |||
| 60 | static inline struct fd __to_fd(unsigned long v) | ||
| 61 | { | 58 | { |
| 62 | return (struct fd){(struct file *)(v & ~3),v & 3}; | 59 | return (struct fd){(unsigned long)f}; |
| 63 | } | 60 | } |
| 64 | 61 | static inline struct fd CLONED_FD(struct file *f) | |
| 65 | static inline struct fd fdget(unsigned int fd) | ||
| 66 | { | 62 | { |
| 67 | return __to_fd(__fdget(fd)); | 63 | return (struct fd){(unsigned long)f | FDPUT_FPUT}; |
| 68 | } | 64 | } |
| 69 | 65 | ||
| 70 | static inline struct fd fdget_raw(unsigned int fd) | 66 | static inline void fdput(struct fd fd) |
| 71 | { | 67 | { |
| 72 | return __to_fd(__fdget_raw(fd)); | 68 | if (fd.word & FDPUT_FPUT) |
| 69 | fput(fd_file(fd)); | ||
| 73 | } | 70 | } |
| 74 | 71 | ||
| 75 | static inline struct fd fdget_pos(int fd) | 72 | extern struct file *fget(unsigned int fd); |
| 76 | { | 73 | extern struct file *fget_raw(unsigned int fd); |
| 77 | return __to_fd(__fdget_pos(fd)); | 74 | extern struct file *fget_task(struct task_struct *task, unsigned int fd); |
| 78 | } | 75 | extern void __f_unlock_pos(struct file *); |
| 76 | |||
| 77 | struct fd fdget(unsigned int fd); | ||
| 78 | struct fd fdget_raw(unsigned int fd); | ||
| 79 | struct fd fdget_pos(unsigned int fd); | ||
| 79 | 80 | ||
| 80 | static inline void fdput_pos(struct fd f) | 81 | static inline void fdput_pos(struct fd f) |
| 81 | { | 82 | { |
| 82 | if (f.flags & FDPUT_POS_UNLOCK) | 83 | if (f.word & FDPUT_POS_UNLOCK) |
| 83 | __f_unlock_pos(f.file); | 84 | __f_unlock_pos(fd_file(f)); |
| 84 | fdput(f); | 85 | fdput(f); |
| 85 | } | 86 | } |
| 86 | 87 | ||
| @@ -109,14 +109,14 @@ static struct io_sq_data *io_attach_sq_data(struct io_uring_params *p) · 108 unmodified lines | |||
| 109 | struct fd f; | 109 | struct fd f; |
| 110 | 110 | ||
| 111 | f = fdget(p->wq_fd); | 111 | f = fdget(p->wq_fd); |
| 112 | if (!f.file) | 112 | if (!fd_file(f)) |
| 113 | return ERR_PTR(-ENXIO); | 113 | return ERR_PTR(-ENXIO); |
| 114 | if (!io_is_uring_fops(f.file)) { | 114 | if (!io_is_uring_fops(fd_file(f))) { |
| 115 | fdput(f); | 115 | fdput(f); |
| 116 | return ERR_PTR(-EINVAL); | 116 | return ERR_PTR(-EINVAL); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | ctx_attach = f.file->private_data; | 119 | ctx_attach = fd_file(f)->private_data; |
| 120 | sqd = ctx_attach->sq_data; | 120 | sqd = ctx_attach->sq_data; |
| 121 | if (!sqd) { | 121 | if (!sqd) { |
| 122 | fdput(f); | 122 | fdput(f); |
| @@ -419,9 +419,9 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx, · 296 unmodified lines | |||
| 419 | struct fd f; | 419 | struct fd f; |
| 420 | 420 | ||
| 421 | f = fdget(p->wq_fd); | 421 | f = fdget(p->wq_fd); |
| 422 | if (!f.file) | 422 | if (!fd_file(f)) |
| 423 | return -ENXIO; | 423 | return -ENXIO; |
| 424 | if (!io_is_uring_fops(f.file)) { | 424 | if (!io_is_uring_fops(fd_file(f))) { |
| 425 | fdput(f); | 425 | fdput(f); |
| 426 | return -EINVAL; | 426 | return -EINVAL; |
| 427 | } | 427 | } |
| @@ -1085,20 +1085,20 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr, · 1084 unmodified lines | |||
| 1085 | audit_mq_sendrecv(mqdes, msg_len, msg_prio, ts); | 1085 | audit_mq_sendrecv(mqdes, msg_len, msg_prio, ts); |
| 1086 | 1086 | ||
| 1087 | f = fdget(mqdes); | 1087 | f = fdget(mqdes); |
| 1088 | if (unlikely(!f.file)) { | 1088 | if (unlikely(!fd_file(f))) { |
| 1089 | ret = -EBADF; | 1089 | ret = -EBADF; |
| 1090 | goto out; | 1090 | goto out; |
| 1091 | } | 1091 | } |
| 1092 | 1092 | ||
| 1093 | inode = file_inode(f.file); | 1093 | inode = file_inode(fd_file(f)); |
| 1094 | if (unlikely(f.file->f_op != &mqueue_file_operations)) { | 1094 | if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) { |
| 1095 | ret = -EBADF; | 1095 | ret = -EBADF; |
| 1096 | goto out_fput; | 1096 | goto out_fput; |
| 1097 | } | 1097 | } |
| 1098 | info = MQUEUE_I(inode); | 1098 | info = MQUEUE_I(inode); |
| 1099 | audit_file(f.file); | 1099 | audit_file(fd_file(f)); |
| 1100 | 1100 | ||
| 1101 | if (unlikely(!(f.file->f_mode & FMODE_WRITE))) { | 1101 | if (unlikely(!(fd_file(f)->f_mode & FMODE_WRITE))) { |
| 1102 | ret = -EBADF; | 1102 | ret = -EBADF; |
| 1103 | goto out_fput; | 1103 | goto out_fput; |
| 1104 | } | 1104 | } |
| @@ -1138,7 +1138,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr, · 33 unmodified lines | |||
| 1138 | } | 1138 | } |
| 1139 | 1139 | ||
| 1140 | if (info->attr.mq_curmsgs == info->attr.mq_maxmsg) { | 1140 | if (info->attr.mq_curmsgs == info->attr.mq_maxmsg) { |
| 1141 | if (f.file->f_flags & O_NONBLOCK) { | 1141 | if (fd_file(f)->f_flags & O_NONBLOCK) { |
| 1142 | ret = -EAGAIN; | 1142 | ret = -EAGAIN; |
| 1143 | } else { | 1143 | } else { |
| 1144 | wait.task = current; | 1144 | wait.task = current; |
| @@ -1199,20 +1199,20 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr, · 54 unmodified lines | |||
| 1199 | audit_mq_sendrecv(mqdes, msg_len, 0, ts); | 1199 | audit_mq_sendrecv(mqdes, msg_len, 0, ts); |
| 1200 | 1200 | ||
| 1201 | f = fdget(mqdes); | 1201 | f = fdget(mqdes); |
| 1202 | if (unlikely(!f.file)) { | 1202 | if (unlikely(!fd_file(f))) { |
| 1203 | ret = -EBADF; | 1203 | ret = -EBADF; |
| 1204 | goto out; | 1204 | goto out; |
| 1205 | } | 1205 | } |
| 1206 | 1206 | ||
| 1207 | inode = file_inode(f.file); | 1207 | inode = file_inode(fd_file(f)); |
| 1208 | if (unlikely(f.file->f_op != &mqueue_file_operations)) { | 1208 | if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) { |
| 1209 | ret = -EBADF; | 1209 | ret = -EBADF; |
| 1210 | goto out_fput; | 1210 | goto out_fput; |
| 1211 | } | 1211 | } |
| 1212 | info = MQUEUE_I(inode); | 1212 | info = MQUEUE_I(inode); |
| 1213 | audit_file(f.file); | 1213 | audit_file(fd_file(f)); |
| 1214 | 1214 | ||
| 1215 | if (unlikely(!(f.file->f_mode & FMODE_READ))) { | 1215 | if (unlikely(!(fd_file(f)->f_mode & FMODE_READ))) { |
| 1216 | ret = -EBADF; | 1216 | ret = -EBADF; |
| 1217 | goto out_fput; | 1217 | goto out_fput; |
| 1218 | } | 1218 | } |
| @@ -1242,7 +1242,7 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr, · 23 unmodified lines | |||
| 1242 | } | 1242 | } |
| 1243 | 1243 | ||
| 1244 | if (info->attr.mq_curmsgs == 0) { | 1244 | if (info->attr.mq_curmsgs == 0) { |
| 1245 | if (f.file->f_flags & O_NONBLOCK) { | 1245 | if (fd_file(f)->f_flags & O_NONBLOCK) { |
| 1246 | spin_unlock(&info->lock); | 1246 | spin_unlock(&info->lock); |
| 1247 | ret = -EAGAIN; | 1247 | ret = -EAGAIN; |
| 1248 | } else { | 1248 | } else { |
| @@ -1356,11 +1356,11 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification) · 107 unmodified lines | |||
| 1356 | /* and attach it to the socket */ | 1356 | /* and attach it to the socket */ |
| 1357 | retry: | 1357 | retry: |
| 1358 | f = fdget(notification->sigev_signo); | 1358 | f = fdget(notification->sigev_signo); |
| 1359 | if (!f.file) { | 1359 | if (!fd_file(f)) { |
| 1360 | ret = -EBADF; | 1360 | ret = -EBADF; |
| 1361 | goto out; | 1361 | goto out; |
| 1362 | } | 1362 | } |
| 1363 | sock = netlink_getsockbyfilp(f.file); | 1363 | sock = netlink_getsockbyfilp(fd_file(f)); |
| 1364 | fdput(f); | 1364 | fdput(f); |
| 1365 | if (IS_ERR(sock)) { | 1365 | if (IS_ERR(sock)) { |
| 1366 | ret = PTR_ERR(sock); | 1366 | ret = PTR_ERR(sock); |
| @@ -1379,13 +1379,13 @@ retry: · 12 unmodified lines | |||
| 1379 | } | 1379 | } |
| 1380 | 1380 | ||
| 1381 | f = fdget(mqdes); | 1381 | f = fdget(mqdes); |
| 1382 | if (!f.file) { | 1382 | if (!fd_file(f)) { |
| 1383 | ret = -EBADF; | 1383 | ret = -EBADF; |
| 1384 | goto out; | 1384 | goto out; |
| 1385 | } | 1385 | } |
| 1386 | 1386 | ||
| 1387 | inode = file_inode(f.file); | 1387 | inode = file_inode(fd_file(f)); |
| 1388 | if (unlikely(f.file->f_op != &mqueue_file_operations)) { | 1388 | if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) { |
| 1389 | ret = -EBADF; | 1389 | ret = -EBADF; |
| 1390 | goto out_fput; | 1390 | goto out_fput; |
| 1391 | } | 1391 | } |
| @@ -1460,31 +1460,31 @@ static int do_mq_getsetattr(int mqdes, struct mq_attr *new, struct mq_attr *old) · 68 unmodified lines | |||
| 1460 | return -EINVAL; | 1460 | return -EINVAL; |
| 1461 | 1461 | ||
| 1462 | f = fdget(mqdes); | 1462 | f = fdget(mqdes); |
| 1463 | if (!f.file) | 1463 | if (!fd_file(f)) |
| 1464 | return -EBADF; | 1464 | return -EBADF; |
| 1465 | 1465 | ||
| 1466 | if (unlikely(f.file->f_op != &mqueue_file_operations)) { | 1466 | if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) { |
| 1467 | fdput(f); | 1467 | fdput(f); |
| 1468 | return -EBADF; | 1468 | return -EBADF; |
| 1469 | } | 1469 | } |
| 1470 | 1470 | ||
| 1471 | inode = file_inode(f.file); | 1471 | inode = file_inode(fd_file(f)); |
| 1472 | info = MQUEUE_I(inode); | 1472 | info = MQUEUE_I(inode); |
| 1473 | 1473 | ||
| 1474 | spin_lock(&info->lock); | 1474 | spin_lock(&info->lock); |
| 1475 | 1475 | ||
| 1476 | if (old) { | 1476 | if (old) { |
| 1477 | *old = info->attr; | 1477 | *old = info->attr; |
| 1478 | old->mq_flags = f.file->f_flags & O_NONBLOCK; | 1478 | old->mq_flags = fd_file(f)->f_flags & O_NONBLOCK; |
| 1479 | } | 1479 | } |
| 1480 | if (new) { | 1480 | if (new) { |
| 1481 | audit_mq_getsetattr(mqdes, new); | 1481 | audit_mq_getsetattr(mqdes, new); |
| 1482 | spin_lock(&f.file->f_lock); | 1482 | spin_lock(&fd_file(f)->f_lock); |
| 1483 | if (new->mq_flags & O_NONBLOCK) | 1483 | if (new->mq_flags & O_NONBLOCK) |
| 1484 | f.file->f_flags |= O_NONBLOCK; | 1484 | fd_file(f)->f_flags |= O_NONBLOCK; |
| 1485 | else | 1485 | else |
| 1486 | f.file->f_flags &= ~O_NONBLOCK; | 1486 | fd_file(f)->f_flags &= ~O_NONBLOCK; |
| 1487 | spin_unlock(&f.file->f_lock); | 1487 | spin_unlock(&fd_file(f)->f_lock); |
| 1488 | 1488 | ||
| 1489 | inode_set_atime_to_ts(inode, inode_set_ctime_current(inode)); | 1489 | inode_set_atime_to_ts(inode, inode_set_ctime_current(inode)); |
| 1490 | } | 1490 | } |
| @@ -80,10 +80,10 @@ static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key) · 79 unmodified lines | |||
| 80 | struct bpf_local_storage_data *sdata; | 80 | struct bpf_local_storage_data *sdata; |
| 81 | struct fd f = fdget_raw(*(int *)key); | 81 | struct fd f = fdget_raw(*(int *)key); |
| 82 | 82 | ||
| 83 | if (!f.file) | 83 | if (!fd_file(f)) |
| 84 | return ERR_PTR(-EBADF); | 84 | return ERR_PTR(-EBADF); |
| 85 | 85 | ||
| 86 | sdata = inode_storage_lookup(file_inode(f.file), map, true); | 86 | sdata = inode_storage_lookup(file_inode(fd_file(f)), map, true); |
| 87 | fdput(f); | 87 | fdput(f); |
| 88 | return sdata ? sdata->data : NULL; | 88 | return sdata ? sdata->data : NULL; |
| 89 | } | 89 | } |
| @@ -94,14 +94,14 @@ static long bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key, · 4 unmodified lines | |||
| 94 | struct bpf_local_storage_data *sdata; | 94 | struct bpf_local_storage_data *sdata; |
| 95 | struct fd f = fdget_raw(*(int *)key); | 95 | struct fd f = fdget_raw(*(int *)key); |
| 96 | 96 | ||
| 97 | if (!f.file) | 97 | if (!fd_file(f)) |
| 98 | return -EBADF; | 98 | return -EBADF; |
| 99 | if (!inode_storage_ptr(file_inode(f.file))) { | 99 | if (!inode_storage_ptr(file_inode(fd_file(f)))) { |
| 100 | fdput(f); | 100 | fdput(f); |
| 101 | return -EBADF; | 101 | return -EBADF; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | sdata = bpf_local_storage_update(file_inode(f.file), | 104 | sdata = bpf_local_storage_update(file_inode(fd_file(f)), |
| 105 | (struct bpf_local_storage_map *)map, | 105 | (struct bpf_local_storage_map *)map, |
| 106 | value, map_flags, GFP_ATOMIC); | 106 | value, map_flags, GFP_ATOMIC); |
| 107 | fdput(f); | 107 | fdput(f); |
| @@ -126,10 +126,10 @@ static long bpf_fd_inode_storage_delete_elem(struct bpf_map *map, void *key) · 18 unmodified lines | |||
| 126 | struct fd f = fdget_raw(*(int *)key); | 126 | struct fd f = fdget_raw(*(int *)key); |
| 127 | int err; | 127 | int err; |
| 128 | 128 | ||
| 129 | if (!f.file) | 129 | if (!fd_file(f)) |
| 130 | return -EBADF; | 130 | return -EBADF; |
| 131 | 131 | ||
| 132 | err = inode_storage_delete(file_inode(f.file), map); | 132 | err = inode_storage_delete(file_inode(fd_file(f)), map); |
| 133 | fdput(f); | 133 | fdput(f); |
| 134 | return err; | 134 | return err; |
| 135 | } | 135 | } |
| @@ -7715,15 +7715,15 @@ struct btf *btf_get_by_fd(int fd) · 7714 unmodified lines | |||
| 7715 | 7715 | ||
| 7716 | f = fdget(fd); | 7716 | f = fdget(fd); |
| 7717 | 7717 | ||
| 7718 | if (!f.file) | 7718 | if (!fd_file(f)) |
| 7719 | return ERR_PTR(-EBADF); | 7719 | return ERR_PTR(-EBADF); |
| 7720 | 7720 | ||
| 7721 | if (f.file->f_op != &btf_fops) { | 7721 | if (fd_file(f)->f_op != &btf_fops) { |
| 7722 | fdput(f); | 7722 | fdput(f); |
| 7723 | return ERR_PTR(-EINVAL); | 7723 | return ERR_PTR(-EINVAL); |
| 7724 | } | 7724 | } |
| 7725 | 7725 | ||
| 7726 | btf = f.file->private_data; | 7726 | btf = fd_file(f)->private_data; |
| 7727 | refcount_inc(&btf->refcnt); | 7727 | refcount_inc(&btf->refcnt); |
| 7728 | fdput(f); | 7728 | fdput(f); |
| 7729 | 7729 | ||
| @@ -837,7 +837,7 @@ static int bpf_map_release(struct inode *inode, struct file *filp) · 836 unmodified lines | |||
| 837 | 837 | ||
| 838 | static fmode_t map_get_sys_perms(struct bpf_map *map, struct fd f) | 838 | static fmode_t map_get_sys_perms(struct bpf_map *map, struct fd f) |
| 839 | { | 839 | { |
| 840 | fmode_t mode = f.file->f_mode; | 840 | fmode_t mode = fd_file(f)->f_mode; |
| 841 | 841 | ||
| 842 | /* Our file permissions may have been overridden by global | 842 | /* Our file permissions may have been overridden by global |
| 843 | * map permissions facing syscall side. | 843 | * map permissions facing syscall side. |
| @@ -1430,14 +1430,14 @@ put_token: · 586 unmodified lines | |||
| 1430 | */ | 1430 | */ |
| 1431 | struct bpf_map *__bpf_map_get(struct fd f) | 1431 | struct bpf_map *__bpf_map_get(struct fd f) |
| 1432 | { | 1432 | { |
| 1433 | if (!f.file) | 1433 | if (!fd_file(f)) |
| 1434 | return ERR_PTR(-EBADF); | 1434 | return ERR_PTR(-EBADF); |
| 1435 | if (f.file->f_op != &bpf_map_fops) { | 1435 | if (fd_file(f)->f_op != &bpf_map_fops) { |
| 1436 | fdput(f); | 1436 | fdput(f); |
| 1437 | return ERR_PTR(-EINVAL); | 1437 | return ERR_PTR(-EINVAL); |
| 1438 | } | 1438 | } |
| 1439 | 1439 | ||
| 1440 | return f.file->private_data; | 1440 | return fd_file(f)->private_data; |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | void bpf_map_inc(struct bpf_map *map) | 1443 | void bpf_map_inc(struct bpf_map *map) |
| @@ -1658,7 +1658,7 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) · 214 unmodified lines | |||
| 1658 | goto free_key; | 1658 | goto free_key; |
| 1659 | } | 1659 | } |
| 1660 | 1660 | ||
| 1661 | err = bpf_map_update_value(map, f.file, key, value, attr->flags); | 1661 | err = bpf_map_update_value(map, fd_file(f), key, value, attr->flags); |
| 1662 | if (!err) | 1662 | if (!err) |
| 1663 | maybe_wait_bpf_programs(map); | 1663 | maybe_wait_bpf_programs(map); |
| 1664 | 1664 | ||
| @@ -2416,14 +2416,14 @@ int bpf_prog_new_fd(struct bpf_prog *prog) · 751 unmodified lines | |||
| 2416 | 2416 | ||
| 2417 | static struct bpf_prog *____bpf_prog_get(struct fd f) | 2417 | static struct bpf_prog *____bpf_prog_get(struct fd f) |
| 2418 | { | 2418 | { |
| 2419 | if (!f.file) | 2419 | if (!fd_file(f)) |
| 2420 | return ERR_PTR(-EBADF); | 2420 | return ERR_PTR(-EBADF); |
| 2421 | if (f.file->f_op != &bpf_prog_fops) { | 2421 | if (fd_file(f)->f_op != &bpf_prog_fops) { |
| 2422 | fdput(f); | 2422 | fdput(f); |
| 2423 | return ERR_PTR(-EINVAL); | 2423 | return ERR_PTR(-EINVAL); |
| 2424 | } | 2424 | } |
| 2425 | 2425 | ||
| 2426 | return f.file->private_data; | 2426 | return fd_file(f)->private_data; |
| 2427 | } | 2427 | } |
| 2428 | 2428 | ||
| 2429 | void bpf_prog_add(struct bpf_prog *prog, int i) | 2429 | void bpf_prog_add(struct bpf_prog *prog, int i) |
| @@ -3266,14 +3266,14 @@ struct bpf_link *bpf_link_get_from_fd(u32 ufd) · 836 unmodified lines | |||
| 3266 | struct fd f = fdget(ufd); | 3266 | struct fd f = fdget(ufd); |
| 3267 | struct bpf_link *link; | 3267 | struct bpf_link *link; |
| 3268 | 3268 | ||
| 3269 | if (!f.file) | 3269 | if (!fd_file(f)) |
| 3270 | return ERR_PTR(-EBADF); | 3270 | return ERR_PTR(-EBADF); |
| 3271 | if (f.file->f_op != &bpf_link_fops && f.file->f_op != &bpf_link_fops_poll) { | 3271 | if (fd_file(f)->f_op != &bpf_link_fops && fd_file(f)->f_op != &bpf_link_fops_poll) { |
| 3272 | fdput(f); | 3272 | fdput(f); |
| 3273 | return ERR_PTR(-EINVAL); | 3273 | return ERR_PTR(-EINVAL); |
| 3274 | } | 3274 | } |
| 3275 | 3275 | ||
| 3276 | link = f.file->private_data; | 3276 | link = fd_file(f)->private_data; |
| 3277 | bpf_link_inc(link); | 3277 | bpf_link_inc(link); |
| 3278 | fdput(f); | 3278 | fdput(f); |
| 3279 | 3279 | ||
| @@ -4989,19 +4989,19 @@ static int bpf_obj_get_info_by_fd(const union bpf_attr *attr, · 1709 unmodified lines | |||
| 4989 | return -EINVAL; | 4989 | return -EINVAL; |
| 4990 | 4990 | ||
| 4991 | f = fdget(ufd); | 4991 | f = fdget(ufd); |
| 4992 | if (!f.file) | 4992 | if (!fd_file(f)) |
| 4993 | return -EBADFD; | 4993 | return -EBADFD; |
| 4994 | 4994 | ||
| 4995 | if (f.file->f_op == &bpf_prog_fops) | 4995 | if (fd_file(f)->f_op == &bpf_prog_fops) |
| 4996 | err = bpf_prog_get_info_by_fd(f.file, f.file->private_data, attr, | 4996 | err = bpf_prog_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr, |
| 4997 | uattr); | 4997 | uattr); |
| 4998 | else if (f.file->f_op == &bpf_map_fops) | 4998 | else if (fd_file(f)->f_op == &bpf_map_fops) |
| 4999 | err = bpf_map_get_info_by_fd(f.file, f.file->private_data, attr, | 4999 | err = bpf_map_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr, |
| 5000 | uattr); | 5000 | uattr); |
| 5001 | else if (f.file->f_op == &btf_fops) | 5001 | else if (fd_file(f)->f_op == &btf_fops) |
| 5002 | err = bpf_btf_get_info_by_fd(f.file, f.file->private_data, attr, uattr); | 5002 | err = bpf_btf_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr, uattr); |
| 5003 | else if (f.file->f_op == &bpf_link_fops || f.file->f_op == &bpf_link_fops_poll) | 5003 | else if (fd_file(f)->f_op == &bpf_link_fops || fd_file(f)->f_op == &bpf_link_fops_poll) |
| 5004 | err = bpf_link_get_info_by_fd(f.file, f.file->private_data, | 5004 | err = bpf_link_get_info_by_fd(fd_file(f), fd_file(f)->private_data, |
| 5005 | attr, uattr); | 5005 | attr, uattr); |
| 5006 | else | 5006 | else |
| 5007 | err = -EINVAL; | 5007 | err = -EINVAL; |
| @@ -5222,7 +5222,7 @@ static int bpf_map_do_batch(const union bpf_attr *attr, · 214 unmodified lines | |||
| 5222 | else if (cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH) | 5222 | else if (cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH) |
| 5223 | BPF_DO_BATCH(map->ops->map_lookup_and_delete_batch, map, attr, uattr); | 5223 | BPF_DO_BATCH(map->ops->map_lookup_and_delete_batch, map, attr, uattr); |
| 5224 | else if (cmd == BPF_MAP_UPDATE_BATCH) | 5224 | else if (cmd == BPF_MAP_UPDATE_BATCH) |
| 5225 | BPF_DO_BATCH(map->ops->map_update_batch, map, f.file, attr, uattr); | 5225 | BPF_DO_BATCH(map->ops->map_update_batch, map, fd_file(f), attr, uattr); |
| 5226 | else | 5226 | else |
| 5227 | BPF_DO_BATCH(map->ops->map_delete_batch, map, attr, uattr); | 5227 | BPF_DO_BATCH(map->ops->map_delete_batch, map, attr, uattr); |
| 5228 | err_put: | 5228 | err_put: |
| @@ -122,10 +122,10 @@ int bpf_token_create(union bpf_attr *attr) · 121 unmodified lines | |||
| 122 | int err, fd; | 122 | int err, fd; |
| 123 | 123 | ||
| 124 | f = fdget(attr->token_create.bpffs_fd); | 124 | f = fdget(attr->token_create.bpffs_fd); |
| 125 | if (!f.file) | 125 | if (!fd_file(f)) |
| 126 | return -EBADF; | 126 | return -EBADF; |
| 127 | 127 | ||
| 128 | path = f.file->f_path; | 128 | path = fd_file(f)->f_path; |
| 129 | path_get(&path); | 129 | path_get(&path); |
| 130 | fdput(f); | 130 | fdput(f); |
| 131 | 131 | ||
| @@ -235,14 +235,14 @@ struct bpf_token *bpf_token_get_from_fd(u32 ufd) · 103 unmodified lines | |||
| 235 | struct fd f = fdget(ufd); | 235 | struct fd f = fdget(ufd); |
| 236 | struct bpf_token *token; | 236 | struct bpf_token *token; |
| 237 | 237 | ||
| 238 | if (!f.file) | 238 | if (!fd_file(f)) |
| 239 | return ERR_PTR(-EBADF); | 239 | return ERR_PTR(-EBADF); |
| 240 | if (f.file->f_op != &bpf_token_fops) { | 240 | if (fd_file(f)->f_op != &bpf_token_fops) { |
| 241 | fdput(f); | 241 | fdput(f); |
| 242 | return ERR_PTR(-EINVAL); | 242 | return ERR_PTR(-EINVAL); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | token = f.file->private_data; | 245 | token = fd_file(f)->private_data; |
| 246 | bpf_token_inc(token); | 246 | bpf_token_inc(token); |
| 247 | fdput(f); | 247 | fdput(f); |
| 248 | 248 | ||
| @@ -6968,10 +6968,10 @@ struct cgroup *cgroup_v1v2_get_from_fd(int fd) · 6967 unmodified lines | |||
| 6968 | { | 6968 | { |
| 6969 | struct cgroup *cgrp; | 6969 | struct cgroup *cgrp; |
| 6970 | struct fd f = fdget_raw(fd); | 6970 | struct fd f = fdget_raw(fd); |
| 6971 | if (!f.file) | 6971 | if (!fd_file(f)) |
| 6972 | return ERR_PTR(-EBADF); | 6972 | return ERR_PTR(-EBADF); |
| 6973 | 6973 | ||
| 6974 | cgrp = cgroup_v1v2_get_from_file(f.file); | 6974 | cgrp = cgroup_v1v2_get_from_file(fd_file(f)); |
| 6975 | fdput(f); | 6975 | fdput(f); |
| 6976 | return cgrp; | 6976 | return cgrp; |
| 6977 | } | 6977 | } |
| @@ -969,10 +969,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event, · 968 unmodified lines | |||
| 969 | struct fd f = fdget(fd); | 969 | struct fd f = fdget(fd); |
| 970 | int ret = 0; | 970 | int ret = 0; |
| 971 | 971 | ||
| 972 | if (!f.file) | 972 | if (!fd_file(f)) |
| 973 | return -EBADF; | 973 | return -EBADF; |
| 974 | 974 | ||
| 975 | css = css_tryget_online_from_dir(f.file->f_path.dentry, | 975 | css = css_tryget_online_from_dir(fd_file(f)->f_path.dentry, |
| 976 | &perf_event_cgrp_subsys); | 976 | &perf_event_cgrp_subsys); |
| 977 | if (IS_ERR(css)) { | 977 | if (IS_ERR(css)) { |
| 978 | ret = PTR_ERR(css); | 978 | ret = PTR_ERR(css); |
| @@ -6001,10 +6001,10 @@ static const struct file_operations perf_fops; · 5022 unmodified lines | |||
| 6001 | static inline int perf_fget_light(int fd, struct fd *p) | 6001 | static inline int perf_fget_light(int fd, struct fd *p) |
| 6002 | { | 6002 | { |
| 6003 | struct fd f = fdget(fd); | 6003 | struct fd f = fdget(fd); |
| 6004 | if (!f.file) | 6004 | if (!fd_file(f)) |
| 6005 | return -EBADF; | 6005 | return -EBADF; |
| 6006 | 6006 | ||
| 6007 | if (f.file->f_op != &perf_fops) { | 6007 | if (fd_file(f)->f_op != &perf_fops) { |
| 6008 | fdput(f); | 6008 | fdput(f); |
| 6009 | return -EBADF; | 6009 | return -EBADF; |
| 6010 | } | 6010 | } |
| @@ -6064,7 +6064,7 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon · 53 unmodified lines | |||
| 6064 | ret = perf_fget_light(arg, &output); | 6064 | ret = perf_fget_light(arg, &output); |
| 6065 | if (ret) | 6065 | if (ret) |
| 6066 | return ret; | 6066 | return ret; |
| 6067 | output_event = output.file->private_data; | 6067 | output_event = fd_file(output)->private_data; |
| 6068 | ret = perf_event_set_output(event, output_event); | 6068 | ret = perf_event_set_output(event, output_event); |
| 6069 | fdput(output); | 6069 | fdput(output); |
| 6070 | } else { | 6070 | } else { |
| @@ -12665,7 +12665,7 @@ SYSCALL_DEFINE5(perf_event_open, · 6594 unmodified lines | |||
| 12665 | struct perf_event_attr attr; | 12665 | struct perf_event_attr attr; |
| 12666 | struct perf_event_context *ctx; | 12666 | struct perf_event_context *ctx; |
| 12667 | struct file *event_file = NULL; | 12667 | struct file *event_file = NULL; |
| 12668 | struct fd group = {NULL, 0}; | 12668 | struct fd group = EMPTY_FD; |
| 12669 | struct task_struct *task = NULL; | 12669 | struct task_struct *task = NULL; |
| 12670 | struct pmu *pmu; | 12670 | struct pmu *pmu; |
| 12671 | int event_fd; | 12671 | int event_fd; |
| @@ -12740,7 +12740,7 @@ SYSCALL_DEFINE5(perf_event_open, · 68 unmodified lines | |||
| 12740 | err = perf_fget_light(group_fd, &group); | 12740 | err = perf_fget_light(group_fd, &group); |
| 12741 | if (err) | 12741 | if (err) |
| 12742 | goto err_fd; | 12742 | goto err_fd; |
| 12743 | group_leader = group.file->private_data; | 12743 | group_leader = fd_file(group)->private_data; |
| 12744 | if (flags & PERF_FLAG_FD_OUTPUT) | 12744 | if (flags & PERF_FLAG_FD_OUTPUT) |
| 12745 | output_event = group_leader; | 12745 | output_event = group_leader; |
| 12746 | if (flags & PERF_FLAG_FD_NO_GROUP) | 12746 | if (flags & PERF_FLAG_FD_NO_GROUP) |
| @@ -3234,7 +3234,7 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) · 3233 unmodified lines | |||
| 3234 | return -EINVAL; | 3234 | return -EINVAL; |
| 3235 | 3235 | ||
| 3236 | f = fdget(fd); | 3236 | f = fdget(fd); |
| 3237 | err = idempotent_init_module(f.file, uargs, flags); | 3237 | err = idempotent_init_module(fd_file(f), uargs, flags); |
| 3238 | fdput(f); | 3238 | fdput(f); |
| 3239 | return err; | 3239 | return err; |
| 3240 | } | 3240 | } |
| @@ -550,15 +550,15 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) · 549 unmodified lines | |||
| 550 | struct nsset nsset = {}; | 550 | struct nsset nsset = {}; |
| 551 | int err = 0; | 551 | int err = 0; |
| 552 | 552 | ||
| 553 | if (!f.file) | 553 | if (!fd_file(f)) |
| 554 | return -EBADF; | 554 | return -EBADF; |
| 555 | 555 | ||
| 556 | if (proc_ns_file(f.file)) { | 556 | if (proc_ns_file(fd_file(f))) { |
| 557 | ns = get_proc_ns(file_inode(f.file)); | 557 | ns = get_proc_ns(file_inode(fd_file(f))); |
| 558 | if (flags && (ns->ops->type != flags)) | 558 | if (flags && (ns->ops->type != flags)) |
| 559 | err = -EINVAL; | 559 | err = -EINVAL; |
| 560 | flags = ns->ops->type; | 560 | flags = ns->ops->type; |
| 561 | } else if (!IS_ERR(pidfd_pid(f.file))) { | 561 | } else if (!IS_ERR(pidfd_pid(fd_file(f)))) { |
| 562 | err = check_setns_flags(flags); | 562 | err = check_setns_flags(flags); |
| 563 | } else { | 563 | } else { |
| 564 | err = -EINVAL; | 564 | err = -EINVAL; |
| @@ -570,10 +570,10 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) · 5 unmodified lines | |||
| 570 | if (err) | 570 | if (err) |
| 571 | goto out; | 571 | goto out; |
| 572 | 572 | ||
| 573 | if (proc_ns_file(f.file)) | 573 | if (proc_ns_file(fd_file(f))) |
| 574 | err = validate_ns(&nsset, ns); | 574 | err = validate_ns(&nsset, ns); |
| 575 | else | 575 | else |
| 576 | err = validate_nsset(&nsset, pidfd_pid(f.file)); | 576 | err = validate_nsset(&nsset, pidfd_pid(fd_file(f))); |
| 577 | if (!err) { | 577 | if (!err) { |
| 578 | commit_nsset(&nsset); | 578 | commit_nsset(&nsset); |
| 579 | perf_event_namespaces(current); | 579 | perf_event_namespaces(current); |
| @@ -540,13 +540,13 @@ struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) · 539 unmodified lines | |||
| 540 | struct pid *pid; | 540 | struct pid *pid; |
| 541 | 541 | ||
| 542 | f = fdget(fd); | 542 | f = fdget(fd); |
| 543 | if (!f.file) | 543 | if (!fd_file(f)) |
| 544 | return ERR_PTR(-EBADF); | 544 | return ERR_PTR(-EBADF); |
| 545 | 545 | ||
| 546 | pid = pidfd_pid(f.file); | 546 | pid = pidfd_pid(fd_file(f)); |
| 547 | if (!IS_ERR(pid)) { | 547 | if (!IS_ERR(pid)) { |
| 548 | get_pid(pid); | 548 | get_pid(pid); |
| 549 | *flags = f.file->f_flags; | 549 | *flags = fd_file(f)->f_flags; |
| 550 | } | 550 | } |
| 551 | 551 | ||
| 552 | fdput(f); | 552 | fdput(f); |
| @@ -755,10 +755,10 @@ SYSCALL_DEFINE3(pidfd_getfd, int, pidfd, int, fd, · 202 unmodified lines | |||
| 755 | return -EINVAL; | 755 | return -EINVAL; |
| 756 | 756 | ||
| 757 | f = fdget(pidfd); | 757 | f = fdget(pidfd); |
| 758 | if (!f.file) | 758 | if (!fd_file(f)) |
| 759 | return -EBADF; | 759 | return -EBADF; |
| 760 | 760 | ||
| 761 | pid = pidfd_pid(f.file); | 761 | pid = pidfd_pid(fd_file(f)); |
| 762 | if (IS_ERR(pid)) | 762 | if (IS_ERR(pid)) |
| 763 | ret = PTR_ERR(pid); | 763 | ret = PTR_ERR(pid); |
| 764 | else | 764 | else |
| @@ -3941,11 +3941,11 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 3940 unmodified lines | |||
| 3941 | return -EINVAL; | 3941 | return -EINVAL; |
| 3942 | 3942 | ||
| 3943 | f = fdget(pidfd); | 3943 | f = fdget(pidfd); |
| 3944 | if (!f.file) | 3944 | if (!fd_file(f)) |
| 3945 | return -EBADF; | 3945 | return -EBADF; |
| 3946 | 3946 | ||
| 3947 | /* Is this a pidfd? */ | 3947 | /* Is this a pidfd? */ |
| 3948 | pid = pidfd_to_pid(f.file); | 3948 | pid = pidfd_to_pid(fd_file(f)); |
| 3949 | if (IS_ERR(pid)) { | 3949 | if (IS_ERR(pid)) { |
| 3950 | ret = PTR_ERR(pid); | 3950 | ret = PTR_ERR(pid); |
| 3951 | goto err; | 3951 | goto err; |
| @@ -3958,7 +3958,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 6 unmodified lines | |||
| 3958 | switch (flags) { | 3958 | switch (flags) { |
| 3959 | case 0: | 3959 | case 0: |
| 3960 | /* Infer scope from the type of pidfd. */ | 3960 | /* Infer scope from the type of pidfd. */ |
| 3961 | if (f.file->f_flags & PIDFD_THREAD) | 3961 | if (fd_file(f)->f_flags & PIDFD_THREAD) |
| 3962 | type = PIDTYPE_PID; | 3962 | type = PIDTYPE_PID; |
| 3963 | else | 3963 | else |
| 3964 | type = PIDTYPE_TGID; | 3964 | type = PIDTYPE_TGID; |
| @@ -1916,10 +1916,10 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd) · 1915 unmodified lines | |||
| 1916 | int err; | 1916 | int err; |
| 1917 | 1917 | ||
| 1918 | exe = fdget(fd); | 1918 | exe = fdget(fd); |
| 1919 | if (!exe.file) | 1919 | if (!fd_file(exe)) |
| 1920 | return -EBADF; | 1920 | return -EBADF; |
| 1921 | 1921 | ||
| 1922 | inode = file_inode(exe.file); | 1922 | inode = file_inode(fd_file(exe)); |
| 1923 | 1923 | ||
| 1924 | /* | 1924 | /* |
| 1925 | * Because the original mm->exe_file points to executable file, make | 1925 | * Because the original mm->exe_file points to executable file, make |
| @@ -1927,14 +1927,14 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd) · 1 unmodified line | |||
| 1927 | * overall picture. | 1927 | * overall picture. |
| 1928 | */ | 1928 | */ |
| 1929 | err = -EACCES; | 1929 | err = -EACCES; |
| 1930 | if (!S_ISREG(inode->i_mode) || path_noexec(&exe.file->f_path)) | 1930 | if (!S_ISREG(inode->i_mode) || path_noexec(&fd_file(exe)->f_path)) |
| 1931 | goto exit; | 1931 | goto exit; |
| 1932 | 1932 | ||
| 1933 | err = file_permission(exe.file, MAY_EXEC); | 1933 | err = file_permission(fd_file(exe), MAY_EXEC); |
| 1934 | if (err) | 1934 | if (err) |
| 1935 | goto exit; | 1935 | goto exit; |
| 1936 | 1936 | ||
| 1937 | err = replace_mm_exe_file(mm, exe.file); | 1937 | err = replace_mm_exe_file(mm, fd_file(exe)); |
| 1938 | exit: | 1938 | exit: |
| 1939 | fdput(exe); | 1939 | fdput(exe); |
| 1940 | return err; | 1940 | return err; |
| @@ -419,7 +419,7 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info) · 418 unmodified lines | |||
| 419 | 419 | ||
| 420 | fd = nla_get_u32(info->attrs[CGROUPSTATS_CMD_ATTR_FD]); | 420 | fd = nla_get_u32(info->attrs[CGROUPSTATS_CMD_ATTR_FD]); |
| 421 | f = fdget(fd); | 421 | f = fdget(fd); |
| 422 | if (!f.file) | 422 | if (!fd_file(f)) |
| 423 | return 0; | 423 | return 0; |
| 424 | 424 | ||
| 425 | size = nla_total_size(sizeof(struct cgroupstats)); | 425 | size = nla_total_size(sizeof(struct cgroupstats)); |
| @@ -440,7 +440,7 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info) · 14 unmodified lines | |||
| 440 | stats = nla_data(na); | 440 | stats = nla_data(na); |
| 441 | memset(stats, 0, sizeof(*stats)); | 441 | memset(stats, 0, sizeof(*stats)); |
| 442 | 442 | ||
| 443 | rc = cgroupstats_build(stats, f.file->f_path.dentry); | 443 | rc = cgroupstats_build(stats, fd_file(f)->f_path.dentry); |
| 444 | if (rc < 0) { | 444 | if (rc < 0) { |
| 445 | nlmsg_free(rep_skb); | 445 | nlmsg_free(rep_skb); |
| 446 | goto err; | 446 | goto err; |
| @@ -666,8 +666,8 @@ struct watch_queue *get_watch_queue(int fd) · 665 unmodified lines | |||
| 666 | struct fd f; | 666 | struct fd f; |
| 667 | 667 | ||
| 668 | f = fdget(fd); | 668 | f = fdget(fd); |
| 669 | if (f.file) { | 669 | if (fd_file(f)) { |
| 670 | pipe = get_pipe_info(f.file, false); | 670 | pipe = get_pipe_info(fd_file(f), false); |
| 671 | if (pipe && pipe->watch_queue) { | 671 | if (pipe && pipe->watch_queue) { |
| 672 | wqueue = pipe->watch_queue; | 672 | wqueue = pipe->watch_queue; |
| 673 | kref_get(&wqueue->usage); | 673 | kref_get(&wqueue->usage); |
| @@ -193,10 +193,10 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) · 192 unmodified lines | |||
| 193 | struct fd f = fdget(fd); | 193 | struct fd f = fdget(fd); |
| 194 | int ret; | 194 | int ret; |
| 195 | 195 | ||
| 196 | if (!f.file) | 196 | if (!fd_file(f)) |
| 197 | return -EBADF; | 197 | return -EBADF; |
| 198 | 198 | ||
| 199 | ret = vfs_fadvise(f.file, offset, len, advice); | 199 | ret = vfs_fadvise(fd_file(f), offset, len, advice); |
| 200 | 200 | ||
| 201 | fdput(f); | 201 | fdput(f); |
| 202 | return ret; | 202 | return ret; |
| @@ -4423,7 +4423,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 4422 unmodified lines | |||
| 4423 | struct cachestat cs; | 4423 | struct cachestat cs; |
| 4424 | pgoff_t first_index, last_index; | 4424 | pgoff_t first_index, last_index; |
| 4425 | 4425 | ||
| 4426 | if (!f.file) | 4426 | if (!fd_file(f)) |
| 4427 | return -EBADF; | 4427 | return -EBADF; |
| 4428 | 4428 | ||
| 4429 | if (copy_from_user(&csr, cstat_range, | 4429 | if (copy_from_user(&csr, cstat_range, |
| @@ -4433,7 +4433,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 3 unmodified lines | |||
| 4433 | } | 4433 | } |
| 4434 | 4434 | ||
| 4435 | /* hugetlbfs is not supported */ | 4435 | /* hugetlbfs is not supported */ |
| 4436 | if (is_file_hugepages(f.file)) { | 4436 | if (is_file_hugepages(fd_file(f))) { |
| 4437 | fdput(f); | 4437 | fdput(f); |
| 4438 | return -EOPNOTSUPP; | 4438 | return -EOPNOTSUPP; |
| 4439 | } | 4439 | } |
| @@ -4447,7 +4447,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 7 unmodified lines | |||
| 4447 | last_index = | 4447 | last_index = |
| 4448 | csr.len == 0 ? ULONG_MAX : (csr.off + csr.len - 1) >> PAGE_SHIFT; | 4448 | csr.len == 0 ? ULONG_MAX : (csr.off + csr.len - 1) >> PAGE_SHIFT; |
| 4449 | memset(&cs, 0, sizeof(struct cachestat)); | 4449 | memset(&cs, 0, sizeof(struct cachestat)); |
| 4450 | mapping = f.file->f_mapping; | 4450 | mapping = fd_file(f)->f_mapping; |
| 4451 | filemap_cachestat(mapping, first_index, last_index, &cs); | 4451 | filemap_cachestat(mapping, first_index, last_index, &cs); |
| 4452 | fdput(f); | 4452 | fdput(f); |
| 4453 | 4453 | ||
| @@ -1947,26 +1947,26 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 1946 unmodified lines | |||
| 1947 | INIT_WORK(&event->remove, memcg_event_remove); | 1947 | INIT_WORK(&event->remove, memcg_event_remove); |
| 1948 | 1948 | ||
| 1949 | efile = fdget(efd); | 1949 | efile = fdget(efd); |
| 1950 | if (!efile.file) { | 1950 | if (!fd_file(efile)) { |
| 1951 | ret = -EBADF; | 1951 | ret = -EBADF; |
| 1952 | goto out_kfree; | 1952 | goto out_kfree; |
| 1953 | } | 1953 | } |
| 1954 | 1954 | ||
| 1955 | event->eventfd = eventfd_ctx_fileget(efile.file); | 1955 | event->eventfd = eventfd_ctx_fileget(fd_file(efile)); |
| 1956 | if (IS_ERR(event->eventfd)) { | 1956 | if (IS_ERR(event->eventfd)) { |
| 1957 | ret = PTR_ERR(event->eventfd); | 1957 | ret = PTR_ERR(event->eventfd); |
| 1958 | goto out_put_efile; | 1958 | goto out_put_efile; |
| 1959 | } | 1959 | } |
| 1960 | 1960 | ||
| 1961 | cfile = fdget(cfd); | 1961 | cfile = fdget(cfd); |
| 1962 | if (!cfile.file) { | 1962 | if (!fd_file(cfile)) { |
| 1963 | ret = -EBADF; | 1963 | ret = -EBADF; |
| 1964 | goto out_put_eventfd; | 1964 | goto out_put_eventfd; |
| 1965 | } | 1965 | } |
| 1966 | 1966 | ||
| 1967 | /* the process need read permission on control file */ | 1967 | /* the process need read permission on control file */ |
| 1968 | /* AV: shouldn't we check that it's been opened for read instead? */ | 1968 | /* AV: shouldn't we check that it's been opened for read instead? */ |
| 1969 | ret = file_permission(cfile.file, MAY_READ); | 1969 | ret = file_permission(fd_file(cfile), MAY_READ); |
| 1970 | if (ret < 0) | 1970 | if (ret < 0) |
| 1971 | goto out_put_cfile; | 1971 | goto out_put_cfile; |
| 1972 | 1972 | ||
| @@ -1974,7 +1974,7 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 1 unmodified line | |||
| 1974 | * The control file must be a regular cgroup1 file. As a regular cgroup | 1974 | * The control file must be a regular cgroup1 file. As a regular cgroup |
| 1975 | * file can't be renamed, it's safe to access its name afterwards. | 1975 | * file can't be renamed, it's safe to access its name afterwards. |
| 1976 | */ | 1976 | */ |
| 1977 | cdentry = cfile.file->f_path.dentry; | 1977 | cdentry = fd_file(cfile)->f_path.dentry; |
| 1978 | if (cdentry->d_sb->s_type != &cgroup_fs_type || !d_is_reg(cdentry)) { | 1978 | if (cdentry->d_sb->s_type != &cgroup_fs_type || !d_is_reg(cdentry)) { |
| 1979 | ret = -EINVAL; | 1979 | ret = -EINVAL; |
| 1980 | goto out_put_cfile; | 1980 | goto out_put_cfile; |
| @@ -2032,7 +2032,7 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 51 unmodified lines | |||
| 2032 | if (ret) | 2032 | if (ret) |
| 2033 | goto out_put_css; | 2033 | goto out_put_css; |
| 2034 | 2034 | ||
| 2035 | vfs_poll(efile.file, &event->pt); | 2035 | vfs_poll(fd_file(efile), &event->pt); |
| 2036 | 2036 | ||
| 2037 | spin_lock_irq(&memcg->event_list_lock); | 2037 | spin_lock_irq(&memcg->event_list_lock); |
| 2038 | list_add(&event->list, &memcg->event_list); | 2038 | list_add(&event->list, &memcg->event_list); |
| @@ -678,7 +678,7 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) · 677 unmodified lines | |||
| 678 | 678 | ||
| 679 | ret = -EBADF; | 679 | ret = -EBADF; |
| 680 | f = fdget(fd); | 680 | f = fdget(fd); |
| 681 | if (!f.file || !(f.file->f_mode & FMODE_READ)) | 681 | if (!fd_file(f) || !(fd_file(f)->f_mode & FMODE_READ)) |
| 682 | goto out; | 682 | goto out; |
| 683 | 683 | ||
| 684 | /* | 684 | /* |
| @@ -687,12 +687,12 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) · 2 unmodified lines | |||
| 687 | * on this file, then we must return -EINVAL. | 687 | * on this file, then we must return -EINVAL. |
| 688 | */ | 688 | */ |
| 689 | ret = -EINVAL; | 689 | ret = -EINVAL; |
| 690 | if (!f.file->f_mapping || !f.file->f_mapping->a_ops || | 690 | if (!fd_file(f)->f_mapping || !fd_file(f)->f_mapping->a_ops || |
| 691 | (!S_ISREG(file_inode(f.file)->i_mode) && | 691 | (!S_ISREG(file_inode(fd_file(f))->i_mode) && |
| 692 | !S_ISBLK(file_inode(f.file)->i_mode))) | 692 | !S_ISBLK(file_inode(fd_file(f))->i_mode))) |
| 693 | goto out; | 693 | goto out; |
| 694 | 694 | ||
| 695 | ret = vfs_fadvise(f.file, offset, count, POSIX_FADV_WILLNEED); | 695 | ret = vfs_fadvise(fd_file(f), offset, count, POSIX_FADV_WILLNEED); |
| 696 | out: | 696 | out: |
| 697 | fdput(f); | 697 | fdput(f); |
| 698 | return ret; | 698 | return ret; |
| @@ -697,11 +697,11 @@ struct net *get_net_ns_by_fd(int fd) · 696 unmodified lines | |||
| 697 | struct fd f = fdget(fd); | 697 | struct fd f = fdget(fd); |
| 698 | struct net *net = ERR_PTR(-EINVAL); | 698 | struct net *net = ERR_PTR(-EINVAL); |
| 699 | 699 | ||
| 700 | if (!f.file) | 700 | if (!fd_file(f)) |
| 701 | return ERR_PTR(-EBADF); | 701 | return ERR_PTR(-EBADF); |
| 702 | 702 | ||
| 703 | if (proc_ns_file(f.file)) { | 703 | if (proc_ns_file(fd_file(f))) { |
| 704 | struct ns_common *ns = get_proc_ns(file_inode(f.file)); | 704 | struct ns_common *ns = get_proc_ns(file_inode(fd_file(f))); |
| 705 | if (ns->ops == &netns_operations) | 705 | if (ns->ops == &netns_operations) |
| 706 | net = get_net(container_of(ns, struct net, ns)); | 706 | net = get_net(container_of(ns, struct net, ns)); |
| 707 | } | 707 | } |
| @@ -556,10 +556,10 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) · 555 unmodified lines | |||
| 556 | struct socket *sock; | 556 | struct socket *sock; |
| 557 | 557 | ||
| 558 | *err = -EBADF; | 558 | *err = -EBADF; |
| 559 | if (f.file) { | 559 | if (fd_file(f)) { |
| 560 | sock = sock_from_file(f.file); | 560 | sock = sock_from_file(fd_file(f)); |
| 561 | if (likely(sock)) { | 561 | if (likely(sock)) { |
| 562 | *fput_needed = f.flags & FDPUT_FPUT; | 562 | *fput_needed = f.word & FDPUT_FPUT; |
| 563 | return sock; | 563 | return sock; |
| 564 | } | 564 | } |
| 565 | *err = -ENOTSOCK; | 565 | *err = -ENOTSOCK; |
| @@ -2014,8 +2014,8 @@ int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr, · 1448 unmodified lines | |||
| 2014 | struct fd f; | 2014 | struct fd f; |
| 2015 | 2015 | ||
| 2016 | f = fdget(fd); | 2016 | f = fdget(fd); |
| 2017 | if (f.file) { | 2017 | if (fd_file(f)) { |
| 2018 | ret = __sys_accept4_file(f.file, upeer_sockaddr, | 2018 | ret = __sys_accept4_file(fd_file(f), upeer_sockaddr, |
| 2019 | upeer_addrlen, flags); | 2019 | upeer_addrlen, flags); |
| 2020 | fdput(f); | 2020 | fdput(f); |
| 2021 | } | 2021 | } |
| @@ -2076,12 +2076,12 @@ int __sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen) · 54 unmodified lines | |||
| 2076 | struct fd f; | 2076 | struct fd f; |
| 2077 | 2077 | ||
| 2078 | f = fdget(fd); | 2078 | f = fdget(fd); |
| 2079 | if (f.file) { | 2079 | if (fd_file(f)) { |
| 2080 | struct sockaddr_storage address; | 2080 | struct sockaddr_storage address; |
| 2081 | 2081 | ||
| 2082 | ret = move_addr_to_kernel(uservaddr, addrlen, &address); | 2082 | ret = move_addr_to_kernel(uservaddr, addrlen, &address); |
| 2083 | if (!ret) | 2083 | if (!ret) |
| 2084 | ret = __sys_connect_file(f.file, &address, addrlen, 0); | 2084 | ret = __sys_connect_file(fd_file(f), &address, addrlen, 0); |
| 2085 | fdput(f); | 2085 | fdput(f); |
| 2086 | } | 2086 | } |
| 2087 | 2087 | ||
| @@ -1068,10 +1068,10 @@ void ima_kexec_cmdline(int kernel_fd, const void *buf, int size) · 1067 unmodified lines | |||
| 1068 | return; | 1068 | return; |
| 1069 | 1069 | ||
| 1070 | f = fdget(kernel_fd); | 1070 | f = fdget(kernel_fd); |
| 1071 | if (!f.file) | 1071 | if (!fd_file(f)) |
| 1072 | return; | 1072 | return; |
| 1073 | 1073 | ||
| 1074 | process_buffer_measurement(file_mnt_idmap(f.file), file_inode(f.file), | 1074 | process_buffer_measurement(file_mnt_idmap(fd_file(f)), file_inode(fd_file(f)), |
| 1075 | buf, size, "kexec-cmdline", KEXEC_CMDLINE, 0, | 1075 | buf, size, "kexec-cmdline", KEXEC_CMDLINE, 0, |
| 1076 | NULL, false, NULL, 0); | 1076 | NULL, false, NULL, 0); |
| 1077 | fdput(f); | 1077 | fdput(f); |
| @@ -238,19 +238,19 @@ static struct landlock_ruleset *get_ruleset_from_fd(const int fd, · 237 unmodified lines | |||
| 238 | struct landlock_ruleset *ruleset; | 238 | struct landlock_ruleset *ruleset; |
| 239 | 239 | ||
| 240 | ruleset_f = fdget(fd); | 240 | ruleset_f = fdget(fd); |
| 241 | if (!ruleset_f.file) | 241 | if (!fd_file(ruleset_f)) |
| 242 | return ERR_PTR(-EBADF); | 242 | return ERR_PTR(-EBADF); |
| 243 | 243 | ||
| 244 | /* Checks FD type and access right. */ | 244 | /* Checks FD type and access right. */ |
| 245 | if (ruleset_f.file->f_op != &ruleset_fops) { | 245 | if (fd_file(ruleset_f)->f_op != &ruleset_fops) { |
| 246 | ruleset = ERR_PTR(-EBADFD); | 246 | ruleset = ERR_PTR(-EBADFD); |
| 247 | goto out_fdput; | 247 | goto out_fdput; |
| 248 | } | 248 | } |
| 249 | if (!(ruleset_f.file->f_mode & mode)) { | 249 | if (!(fd_file(ruleset_f)->f_mode & mode)) { |
| 250 | ruleset = ERR_PTR(-EPERM); | 250 | ruleset = ERR_PTR(-EPERM); |
| 251 | goto out_fdput; | 251 | goto out_fdput; |
| 252 | } | 252 | } |
| 253 | ruleset = ruleset_f.file->private_data; | 253 | ruleset = fd_file(ruleset_f)->private_data; |
| 254 | if (WARN_ON_ONCE(ruleset->num_layers != 1)) { | 254 | if (WARN_ON_ONCE(ruleset->num_layers != 1)) { |
| 255 | ruleset = ERR_PTR(-EINVAL); | 255 | ruleset = ERR_PTR(-EINVAL); |
| 256 | goto out_fdput; | 256 | goto out_fdput; |
| @@ -277,22 +277,22 @@ static int get_path_from_fd(const s32 fd, struct path *const path) · 20 unmodified lines | |||
| 277 | 277 | ||
| 278 | /* Handles O_PATH. */ | 278 | /* Handles O_PATH. */ |
| 279 | f = fdget_raw(fd); | 279 | f = fdget_raw(fd); |
| 280 | if (!f.file) | 280 | if (!fd_file(f)) |
| 281 | return -EBADF; | 281 | return -EBADF; |
| 282 | /* | 282 | /* |
| 283 | * Forbids ruleset FDs, internal filesystems (e.g. nsfs), including | 283 | * Forbids ruleset FDs, internal filesystems (e.g. nsfs), including |
| 284 | * pseudo filesystems that will never be mountable (e.g. sockfs, | 284 | * pseudo filesystems that will never be mountable (e.g. sockfs, |
| 285 | * pipefs). | 285 | * pipefs). |
| 286 | */ | 286 | */ |
| 287 | if ((f.file->f_op == &ruleset_fops) || | 287 | if ((fd_file(f)->f_op == &ruleset_fops) || |
| 288 | (f.file->f_path.mnt->mnt_flags & MNT_INTERNAL) || | 288 | (fd_file(f)->f_path.mnt->mnt_flags & MNT_INTERNAL) || |
| 289 | (f.file->f_path.dentry->d_sb->s_flags & SB_NOUSER) || | 289 | (fd_file(f)->f_path.dentry->d_sb->s_flags & SB_NOUSER) || |
| 290 | d_is_negative(f.file->f_path.dentry) || | 290 | d_is_negative(fd_file(f)->f_path.dentry) || |
| 291 | IS_PRIVATE(d_backing_inode(f.file->f_path.dentry))) { | 291 | IS_PRIVATE(d_backing_inode(fd_file(f)->f_path.dentry))) { |
| 292 | err = -EBADFD; | 292 | err = -EBADFD; |
| 293 | goto out_fdput; | 293 | goto out_fdput; |
| 294 | } | 294 | } |
| 295 | *path = f.file->f_path; | 295 | *path = fd_file(f)->f_path; |
| 296 | path_get(path); | 296 | path_get(path); |
| 297 | 297 | ||
| 298 | out_fdput: | 298 | out_fdput: |
| @@ -296,7 +296,7 @@ static int read_trusted_verity_root_digests(unsigned int fd) · 295 unmodified lines | |||
| 296 | return -EPERM; | 296 | return -EPERM; |
| 297 | 297 | ||
| 298 | f = fdget(fd); | 298 | f = fdget(fd); |
| 299 | if (!f.file) | 299 | if (!fd_file(f)) |
| 300 | return -EINVAL; | 300 | return -EINVAL; |
| 301 | 301 | ||
| 302 | data = kzalloc(SZ_4K, GFP_KERNEL); | 302 | data = kzalloc(SZ_4K, GFP_KERNEL); |
| @@ -305,7 +305,7 @@ static int read_trusted_verity_root_digests(unsigned int fd) · 2 unmodified lines | |||
| 305 | goto err; | 305 | goto err; |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | rc = kernel_read_file(f.file, 0, (void **)&data, SZ_4K - 1, NULL, READING_POLICY); | 308 | rc = kernel_read_file(fd_file(f), 0, (void **)&data, SZ_4K - 1, NULL, READING_POLICY); |
| 309 | if (rc < 0) | 309 | if (rc < 0) |
| 310 | goto err; | 310 | goto err; |
| 311 | 311 | ||
| @@ -2250,12 +2250,12 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) · 2249 unmodified lines | |||
| 2250 | bool nonatomic = substream->pcm->nonatomic; | 2250 | bool nonatomic = substream->pcm->nonatomic; |
| 2251 | CLASS(fd, f)(fd); | 2251 | CLASS(fd, f)(fd); |
| 2252 | 2252 | ||
| 2253 | if (!f.file) | 2253 | if (!fd_file(f)) |
| 2254 | return -EBADFD; | 2254 | return -EBADFD; |
| 2255 | if (!is_pcm_file(f.file)) | 2255 | if (!is_pcm_file(fd_file(f))) |
| 2256 | return -EBADFD; | 2256 | return -EBADFD; |
| 2257 | 2257 | ||
| 2258 | pcm_file = f.file->private_data; | 2258 | pcm_file = fd_file(f)->private_data; |
| 2259 | substream1 = pcm_file->substream; | 2259 | substream1 = pcm_file->substream; |
| 2260 | 2260 | ||
| 2261 | if (substream == substream1) | 2261 | if (substream == substream1) |
| @@ -328,12 +328,12 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) · 327 unmodified lines | |||
| 328 | seqcount_spinlock_init(&irqfd->irq_entry_sc, &kvm->irqfds.lock); | 328 | seqcount_spinlock_init(&irqfd->irq_entry_sc, &kvm->irqfds.lock); |
| 329 | 329 | ||
| 330 | f = fdget(args->fd); | 330 | f = fdget(args->fd); |
| 331 | if (!f.file) { | 331 | if (!fd_file(f)) { |
| 332 | ret = -EBADF; | 332 | ret = -EBADF; |
| 333 | goto out; | 333 | goto out; |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | eventfd = eventfd_ctx_fileget(f.file); | 336 | eventfd = eventfd_ctx_fileget(fd_file(f)); |
| 337 | if (IS_ERR(eventfd)) { | 337 | if (IS_ERR(eventfd)) { |
| 338 | ret = PTR_ERR(eventfd); | 338 | ret = PTR_ERR(eventfd); |
| 339 | goto fail; | 339 | goto fail; |
| @@ -420,7 +420,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) · 80 unmodified lines | |||
| 420 | * Check if there was an event already pending on the eventfd | 420 | * Check if there was an event already pending on the eventfd |
| 421 | * before we registered, and trigger it as if we didn't miss it. | 421 | * before we registered, and trigger it as if we didn't miss it. |
| 422 | */ | 422 | */ |
| 423 | events = vfs_poll(f.file, &irqfd->pt); | 423 | events = vfs_poll(fd_file(f), &irqfd->pt); |
| 424 | 424 | ||
| 425 | if (events & EPOLLIN) | 425 | if (events & EPOLLIN) |
| 426 | schedule_work(&irqfd->inject); | 426 | schedule_work(&irqfd->inject); |
| @@ -194,7 +194,7 @@ static int kvm_vfio_file_del(struct kvm_device *dev, unsigned int fd) · 193 unmodified lines | |||
| 194 | int ret; | 194 | int ret; |
| 195 | 195 | ||
| 196 | f = fdget(fd); | 196 | f = fdget(fd); |
| 197 | if (!f.file) | 197 | if (!fd_file(f)) |
| 198 | return -EBADF; | 198 | return -EBADF; |
| 199 | 199 | ||
| 200 | ret = -ENOENT; | 200 | ret = -ENOENT; |
| @@ -202,7 +202,7 @@ static int kvm_vfio_file_del(struct kvm_device *dev, unsigned int fd) · 1 unmodified line | |||
| 202 | mutex_lock(&kv->lock); | 202 | mutex_lock(&kv->lock); |
| 203 | 203 | ||
| 204 | list_for_each_entry(kvf, &kv->file_list, node) { | 204 | list_for_each_entry(kvf, &kv->file_list, node) { |
| 205 | if (kvf->file != f.file) | 205 | if (kvf->file != fd_file(f)) |
| 206 | continue; | 206 | continue; |
| 207 | 207 | ||
| 208 | list_del(&kvf->node); | 208 | list_del(&kvf->node); |
| @@ -240,7 +240,7 @@ static int kvm_vfio_file_set_spapr_tce(struct kvm_device *dev, · 31 unmodified lines | |||
| 240 | return -EFAULT; | 240 | return -EFAULT; |
| 241 | 241 | ||
| 242 | f = fdget(param.groupfd); | 242 | f = fdget(param.groupfd); |
| 243 | if (!f.file) | 243 | if (!fd_file(f)) |
| 244 | return -EBADF; | 244 | return -EBADF; |
| 245 | 245 | ||
| 246 | ret = -ENOENT; | 246 | ret = -ENOENT; |
| @@ -248,7 +248,7 @@ static int kvm_vfio_file_set_spapr_tce(struct kvm_device *dev, · 1 unmodified line | |||
| 248 | mutex_lock(&kv->lock); | 248 | mutex_lock(&kv->lock); |
| 249 | 249 | ||
| 250 | list_for_each_entry(kvf, &kv->file_list, node) { | 250 | list_for_each_entry(kvf, &kv->file_list, node) { |
| 251 | if (kvf->file != f.file) | 251 | if (kvf->file != fd_file(f)) |
| 252 | continue; | 252 | continue; |
| 253 | 253 | ||
| 254 | if (!kvf->iommu_group) { | 254 | if (!kvf->iommu_group) { |