For any changes of struct fd representation we need to turn existing accesses to fields into calls of wrappers. Accesses to struct fd::flags are very few (3 in linux/file.h, 1 in net/socket.c, 3 in fs/overlayfs/file.c and 3 more in explicit initializers). Those can be dealt with in the commit converting to new layout; accesses to struct fd::file are too many for that. This commit converts (almost) all of f.file to fd_file(f). It's not entirely mechanical ('file' is used as a member name more than just in struct fd) and it does not even attempt to distinguish the uses in pointer context from those in boolean context; the latter will be eventually turned into a separate helper (fd_empty()). NOTE: mass conversion to fd_empty(), tempting as it might be, is a bad idea; better do that piecewise in commit that convert from fdget...() to CLASS(...). [conflicts in fs/fhandle.c, kernel/bpf/syscall.c, mm/memcontrol.c caught by git; fs/stat.c one got caught by git grep] [fs/xattr.c conflict]
Unified · Split
| @@ -160,10 +160,10 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd, · 159 unmodified lines | ||
| 160 | 160 | .count = count |
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | − if (!arg.file) | |
| 163 | + if (!fd_file(arg)) | |
| 164 | 164 | return -EBADF; |
| 165 | 165 | |
| 166 | − error = iterate_dir(arg.file, &buf.ctx); | |
| 166 | + error = iterate_dir(fd_file(arg), &buf.ctx); | |
| 167 | 167 | if (error >= 0) |
| 168 | 168 | error = buf.error; |
| 169 | 169 | if (count != buf.count) |
| @@ -239,19 +239,19 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, · 238 unmodified lines | ||
| 239 | 239 | struct flock64 flock; |
| 240 | 240 | long err = -EBADF; |
| 241 | 241 | |
| 242 | − if (!f.file) | |
| 242 | + if (!fd_file(f)) | |
| 243 | 243 | goto out; |
| 244 | 244 | |
| 245 | 245 | switch (cmd) { |
| 246 | 246 | case F_GETLK64: |
| 247 | 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 | 249 | if (err) |
| 250 | 250 | break; |
| 251 | 251 | err = get_oabi_flock(&flock, argp); |
| 252 | 252 | if (err) |
| 253 | 253 | break; |
| 254 | − err = fcntl_getlk64(f.file, cmd, &flock); | |
| 254 | + err = fcntl_getlk64(fd_file(f), cmd, &flock); | |
| 255 | 255 | if (!err) |
| 256 | 256 | err = put_oabi_flock(&flock, argp); |
| 257 | 257 | break; |
| @@ -259,13 +259,13 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, · 1 unmodified line | ||
| 259 | 259 | case F_SETLKW64: |
| 260 | 260 | case F_OFD_SETLK: |
| 261 | 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 | 263 | if (err) |
| 264 | 264 | break; |
| 265 | 265 | err = get_oabi_flock(&flock, argp); |
| 266 | 266 | if (err) |
| 267 | 267 | break; |
| 268 | − err = fcntl_setlk64(fd, f.file, cmd, &flock); | |
| 268 | + err = fcntl_setlk64(fd, fd_file(f), cmd, &flock); | |
| 269 | 269 | break; |
| 270 | 270 | default: |
| 271 | 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 | 118 | struct fd f; |
| 119 | 119 | |
| 120 | 120 | f = fdget(tablefd); |
| 121 | − if (!f.file) | |
| 121 | + if (!fd_file(f)) | |
| 122 | 122 | return -EBADF; |
| 123 | 123 | |
| 124 | 124 | rcu_read_lock(); |
| 125 | 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 | 127 | found = true; |
| 128 | 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 | 1939 | r = -EBADF; |
| 1940 | 1940 | f = fdget(cap->args[0]); |
| 1941 | − if (!f.file) | |
| 1941 | + if (!fd_file(f)) | |
| 1942 | 1942 | break; |
| 1943 | 1943 | |
| 1944 | 1944 | r = -EPERM; |
| 1945 | − dev = kvm_device_from_filp(f.file); | |
| 1945 | + dev = kvm_device_from_filp(fd_file(f)); | |
| 1946 | 1946 | if (dev) |
| 1947 | 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 | 1958 | r = -EBADF; |
| 1959 | 1959 | f = fdget(cap->args[0]); |
| 1960 | − if (!f.file) | |
| 1960 | + if (!fd_file(f)) | |
| 1961 | 1961 | break; |
| 1962 | 1962 | |
| 1963 | 1963 | r = -EPERM; |
| 1964 | − dev = kvm_device_from_filp(f.file); | |
| 1964 | + dev = kvm_device_from_filp(fd_file(f)); | |
| 1965 | 1965 | if (dev) { |
| 1966 | 1966 | if (xics_on_xive()) |
| 1967 | 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 | 1981 | r = -EBADF; |
| 1982 | 1982 | f = fdget(cap->args[0]); |
| 1983 | − if (!f.file) | |
| 1983 | + if (!fd_file(f)) | |
| 1984 | 1984 | break; |
| 1985 | 1985 | |
| 1986 | 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 | 1992 | r = -EPERM; |
| 1993 | − dev = kvm_device_from_filp(f.file); | |
| 1993 | + dev = kvm_device_from_filp(fd_file(f)); | |
| 1994 | 1994 | if (dev) |
| 1995 | 1995 | r = kvmppc_xive_native_connect_vcpu(dev, vcpu, |
| 1996 | 1996 | cap->args[1]); |
| @@ -66,8 +66,8 @@ SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags, · 65 unmodified lines | ||
| 66 | 66 | if (flags & SPU_CREATE_AFFINITY_SPU) { |
| 67 | 67 | struct fd neighbor = fdget(neighbor_fd); |
| 68 | 68 | ret = -EBADF; |
| 69 | − if (neighbor.file) { | |
| 70 | − ret = calls->create_thread(name, flags, mode, neighbor.file); | |
| 69 | + if (fd_file(neighbor)) { | |
| 70 | + ret = calls->create_thread(name, flags, mode, fd_file(neighbor)); | |
| 71 | 71 | fdput(neighbor); |
| 72 | 72 | } |
| 73 | 73 | } else |
| @@ -89,8 +89,8 @@ SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, ustatus) · 15 unmodified lines | ||
| 89 | 89 | |
| 90 | 90 | ret = -EBADF; |
| 91 | 91 | arg = fdget(fd); |
| 92 | − if (arg.file) { | |
| 93 | − ret = calls->spu_run(arg.file, unpc, ustatus); | |
| 92 | + if (fd_file(arg)) { | |
| 93 | + ret = calls->spu_run(fd_file(arg), unpc, ustatus); | |
| 94 | 94 | fdput(arg); |
| 95 | 95 | } |
| 96 | 96 | |
| @@ -895,10 +895,10 @@ int sgx_set_attribute(unsigned long *allowed_attributes, · 894 unmodified lines | ||
| 895 | 895 | { |
| 896 | 896 | struct fd f = fdget(attribute_fd); |
| 897 | 897 | |
| 898 | − if (!f.file) | |
| 898 | + if (!fd_file(f)) | |
| 899 | 899 | return -EINVAL; |
| 900 | 900 | |
| 901 | − if (f.file->f_op != &sgx_provision_fops) { | |
| 901 | + if (fd_file(f)->f_op != &sgx_provision_fops) { | |
| 902 | 902 | fdput(f); |
| 903 | 903 | return -EINVAL; |
| 904 | 904 | } |
| @@ -534,10 +534,10 @@ static int __sev_issue_cmd(int fd, int id, void *data, int *error) · 533 unmodified lines | ||
| 534 | 534 | int ret; |
| 535 | 535 | |
| 536 | 536 | f = fdget(fd); |
| 537 | − if (!f.file) | |
| 537 | + if (!fd_file(f)) | |
| 538 | 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 | 542 | fdput(f); |
| 543 | 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 | 2078 | bool charged = false; |
| 2079 | 2079 | int ret; |
| 2080 | 2080 | |
| 2081 | − if (!f.file) | |
| 2081 | + if (!fd_file(f)) | |
| 2082 | 2082 | return -EBADF; |
| 2083 | 2083 | |
| 2084 | − if (!file_is_kvm(f.file)) { | |
| 2084 | + if (!file_is_kvm(fd_file(f))) { | |
| 2085 | 2085 | ret = -EBADF; |
| 2086 | 2086 | goto out_fput; |
| 2087 | 2087 | } |
| 2088 | 2088 | |
| 2089 | − source_kvm = f.file->private_data; | |
| 2089 | + source_kvm = fd_file(f)->private_data; | |
| 2090 | 2090 | ret = sev_lock_two_vms(kvm, source_kvm); |
| 2091 | 2091 | if (ret) |
| 2092 | 2092 | goto out_fput; |
| @@ -2801,15 +2801,15 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd) · 708 unmodified lines | ||
| 2801 | 2801 | struct kvm_sev_info *source_sev, *mirror_sev; |
| 2802 | 2802 | int ret; |
| 2803 | 2803 | |
| 2804 | − if (!f.file) | |
| 2804 | + if (!fd_file(f)) | |
| 2805 | 2805 | return -EBADF; |
| 2806 | 2806 | |
| 2807 | − if (!file_is_kvm(f.file)) { | |
| 2807 | + if (!file_is_kvm(fd_file(f))) { | |
| 2808 | 2808 | ret = -EBADF; |
| 2809 | 2809 | goto e_source_fput; |
| 2810 | 2810 | } |
| 2811 | 2811 | |
| 2812 | − source_kvm = f.file->private_data; | |
| 2812 | + source_kvm = fd_file(f)->private_data; | |
| 2813 | 2813 | ret = sev_lock_two_vms(kvm, source_kvm); |
| 2814 | 2814 | if (ret) |
| 2815 | 2815 | goto e_source_fput; |
| @@ -43,10 +43,10 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, · 42 unmodified lines | ||
| 43 | 43 | uint32_t id; |
| 44 | 44 | int r; |
| 45 | 45 | |
| 46 | − if (!f.file) | |
| 46 | + if (!fd_file(f)) | |
| 47 | 47 | return -EINVAL; |
| 48 | 48 | |
| 49 | − r = amdgpu_file_to_fpriv(f.file, &fpriv); | |
| 49 | + r = amdgpu_file_to_fpriv(fd_file(f), &fpriv); | |
| 50 | 50 | if (r) { |
| 51 | 51 | fdput(f); |
| 52 | 52 | return r; |
| @@ -72,10 +72,10 @@ static int amdgpu_sched_context_priority_override(struct amdgpu_device *adev, · 19 unmodified lines | ||
| 72 | 72 | struct amdgpu_ctx *ctx; |
| 73 | 73 | int r; |
| 74 | 74 | |
| 75 | − if (!f.file) | |
| 75 | + if (!fd_file(f)) | |
| 76 | 76 | return -EINVAL; |
| 77 | 77 | |
| 78 | − r = amdgpu_file_to_fpriv(f.file, &fpriv); | |
| 78 | + r = amdgpu_file_to_fpriv(fd_file(f), &fpriv); | |
| 79 | 79 | if (r) { |
| 80 | 80 | fdput(f); |
| 81 | 81 | return r; |
| @@ -715,16 +715,16 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private, · 714 unmodified lines | ||
| 715 | 715 | struct fd f = fdget(fd); |
| 716 | 716 | int ret; |
| 717 | 717 | |
| 718 | − if (!f.file) | |
| 718 | + if (!fd_file(f)) | |
| 719 | 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 | 722 | fdput(f); |
| 723 | 723 | return -EINVAL; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | /* take a reference to put in the idr */ |
| 727 | − syncobj = f.file->private_data; | |
| 727 | + syncobj = fd_file(f)->private_data; | |
| 728 | 728 | drm_syncobj_get(syncobj); |
| 729 | 729 | |
| 730 | 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 | 1625 | /* Get current fd to protect against it being closed */ |
| 1626 | 1626 | f = fdget(cmd.fd); |
| 1627 | − if (!f.file) | |
| 1627 | + if (!fd_file(f)) | |
| 1628 | 1628 | return -ENOENT; |
| 1629 | − if (f.file->f_op != &ucma_fops) { | |
| 1629 | + if (fd_file(f)->f_op != &ucma_fops) { | |
| 1630 | 1630 | ret = -EINVAL; |
| 1631 | 1631 | goto file_put; |
| 1632 | 1632 | } |
| 1633 | − cur_file = f.file->private_data; | |
| 1633 | + cur_file = fd_file(f)->private_data; | |
| 1634 | 1634 | |
| 1635 | 1635 | /* Validate current fd and prevent destruction of id. */ |
| 1636 | 1636 | ctx = ucma_get_ctx(cur_file, cmd.id); |
| @@ -584,12 +584,12 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) · 583 unmodified lines | ||
| 584 | 584 | if (cmd.fd != -1) { |
| 585 | 585 | /* search for file descriptor */ |
| 586 | 586 | f = fdget(cmd.fd); |
| 587 | − if (!f.file) { | |
| 587 | + if (!fd_file(f)) { | |
| 588 | 588 | ret = -EBADF; |
| 589 | 589 | goto err_tree_mutex_unlock; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | − inode = file_inode(f.file); | |
| 592 | + inode = file_inode(fd_file(f)); | |
| 593 | 593 | xrcd = find_xrcd(ibudev, inode); |
| 594 | 594 | if (!xrcd && !(cmd.oflags & O_CREAT)) { |
| 595 | 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 | 632 | atomic_inc(&xrcd->usecnt); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | − if (f.file) | |
| 635 | + if (fd_file(f)) | |
| 636 | 636 | fdput(f); |
| 637 | 637 | |
| 638 | 638 | mutex_unlock(&ibudev->xrcd_tree_mutex); |
| @@ -648,7 +648,7 @@ err: · 9 unmodified lines | ||
| 648 | 648 | uobj_alloc_abort(&obj->uobject, attrs); |
| 649 | 649 | |
| 650 | 650 | err_tree_mutex_unlock: |
| 651 | − if (f.file) | |
| 651 | + if (fd_file(f)) | |
| 652 | 652 | fdput(f); |
| 653 | 653 | |
| 654 | 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 | 254 | return ERR_PTR(-EBADR); |
| 255 | 255 | |
| 256 | 256 | f = fdget(request_fd); |
| 257 | − if (!f.file) | |
| 257 | + if (!fd_file(f)) | |
| 258 | 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 | 261 | goto err_fput; |
| 262 | − req = f.file->private_data; | |
| 262 | + req = fd_file(f)->private_data; | |
| 263 | 263 | if (req->mdev != mdev) |
| 264 | 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 | 820 | struct lirc_fh *fh; |
| 821 | 821 | struct rc_dev *dev; |
| 822 | 822 | |
| 823 | − if (!f.file) | |
| 823 | + if (!fd_file(f)) | |
| 824 | 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 | 827 | fdput(f); |
| 828 | 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 | 832 | fdput(f); |
| 833 | 833 | return ERR_PTR(-EPERM); |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | − fh = f.file->private_data; | |
| 836 | + fh = fd_file(f)->private_data; | |
| 837 | 837 | dev = fh->rc; |
| 838 | 838 | |
| 839 | 839 | get_device(&dev->dev); |
| @@ -112,7 +112,7 @@ static int vfio_group_ioctl_set_container(struct vfio_group *group, · 111 unmodified lines | ||
| 112 | 112 | return -EFAULT; |
| 113 | 113 | |
| 114 | 114 | f = fdget(fd); |
| 115 | − if (!f.file) | |
| 115 | + if (!fd_file(f)) | |
| 116 | 116 | return -EBADF; |
| 117 | 117 | |
| 118 | 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 | 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 | 129 | if (container) { |
| 130 | 130 | ret = vfio_container_attach_group(container, group); |
| 131 | 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 | 135 | if (!IS_ERR(iommufd)) { |
| 136 | 136 | if (IS_ENABLED(CONFIG_VFIO_NOIOMMU) && |
| 137 | 137 | group->type == VFIO_NO_IOMMU) |
| @@ -134,12 +134,12 @@ int vfio_virqfd_enable(void *opaque, · 133 unmodified lines | ||
| 134 | 134 | INIT_WORK(&virqfd->flush_inject, virqfd_flush_inject); |
| 135 | 135 | |
| 136 | 136 | irqfd = fdget(fd); |
| 137 | − if (!irqfd.file) { | |
| 137 | + if (!fd_file(irqfd)) { | |
| 138 | 138 | ret = -EBADF; |
| 139 | 139 | goto err_fd; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | − ctx = eventfd_ctx_fileget(irqfd.file); | |
| 142 | + ctx = eventfd_ctx_fileget(fd_file(irqfd)); | |
| 143 | 143 | if (IS_ERR(ctx)) { |
| 144 | 144 | ret = PTR_ERR(ctx); |
| 145 | 145 | goto err_ctx; |
| @@ -171,7 +171,7 @@ int vfio_virqfd_enable(void *opaque, · 25 unmodified lines | ||
| 171 | 171 | init_waitqueue_func_entry(&virqfd->wait, virqfd_wakeup); |
| 172 | 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 | 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 | 125 | INIT_WORK(&irqfd->shutdown, hsm_irqfd_shutdown_work); |
| 126 | 126 | |
| 127 | 127 | f = fdget(args->fd); |
| 128 | − if (!f.file) { | |
| 128 | + if (!fd_file(f)) { | |
| 129 | 129 | ret = -EBADF; |
| 130 | 130 | goto out; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | − eventfd = eventfd_ctx_fileget(f.file); | |
| 133 | + eventfd = eventfd_ctx_fileget(fd_file(f)); | |
| 134 | 134 | if (IS_ERR(eventfd)) { |
| 135 | 135 | ret = PTR_ERR(eventfd); |
| 136 | 136 | goto fail; |
| @@ -157,7 +157,7 @@ static int acrn_irqfd_assign(struct acrn_vm *vm, struct acrn_irqfd *args) · 20 unmodified lines | ||
| 157 | 157 | mutex_unlock(&vm->irqfds_lock); |
| 158 | 158 | |
| 159 | 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 | 162 | if (events & EPOLLIN) |
| 163 | 163 | acrn_irqfd_inject(irqfd); |
| @@ -959,12 +959,12 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 958 unmodified lines | ||
| 959 | 959 | INIT_WORK(&kirqfd->shutdown, irqfd_shutdown); |
| 960 | 960 | |
| 961 | 961 | f = fdget(irqfd->fd); |
| 962 | − if (!f.file) { | |
| 962 | + if (!fd_file(f)) { | |
| 963 | 963 | ret = -EBADF; |
| 964 | 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 | 968 | if (IS_ERR(kirqfd->eventfd)) { |
| 969 | 969 | ret = PTR_ERR(kirqfd->eventfd); |
| 970 | 970 | goto error_fd_put; |
| @@ -995,7 +995,7 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 24 unmodified lines | ||
| 995 | 995 | * Check if there was an event already pending on the eventfd before we |
| 996 | 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 | 999 | if (events & EPOLLIN) |
| 1000 | 1000 | irqfd_inject(kirqfd); |
| 1001 | 1001 | |
| @@ -1345,12 +1345,12 @@ static int privcmd_ioeventfd_assign(struct privcmd_ioeventfd *ioeventfd) · 343 unmodified lines | ||
| 1345 | 1345 | return -ENOMEM; |
| 1346 | 1346 | |
| 1347 | 1347 | f = fdget(ioeventfd->event_fd); |
| 1348 | − if (!f.file) { | |
| 1348 | + if (!fd_file(f)) { | |
| 1349 | 1349 | ret = -EBADF; |
| 1350 | 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 | 1354 | fdput(f); |
| 1355 | 1355 | |
| 1356 | 1356 | if (IS_ERR(kioeventfd->eventfd)) { |
| @@ -1312,12 +1312,12 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file, · 1311 unmodified lines | ||
| 1312 | 1312 | } else { |
| 1313 | 1313 | struct fd src = fdget(fd); |
| 1314 | 1314 | struct inode *src_inode; |
| 1315 | − if (!src.file) { | |
| 1315 | + if (!fd_file(src)) { | |
| 1316 | 1316 | ret = -EINVAL; |
| 1317 | 1317 | goto out_drop_write; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | − src_inode = file_inode(src.file); | |
| 1320 | + src_inode = file_inode(fd_file(src)); | |
| 1321 | 1321 | if (src_inode->i_sb != file_inode(file)->i_sb) { |
| 1322 | 1322 | btrfs_info(BTRFS_I(file_inode(file))->root->fs_info, |
| 1323 | 1323 | "Snapshot src from another FS"); |
| @@ -127,9 +127,9 @@ static int coda_parse_fd(struct fs_context *fc, int fd) · 126 unmodified lines | ||
| 127 | 127 | int idx; |
| 128 | 128 | |
| 129 | 129 | f = fdget(fd); |
| 130 | − if (!f.file) | |
| 130 | + if (!fd_file(f)) | |
| 131 | 131 | return -EBADF; |
| 132 | − inode = file_inode(f.file); | |
| 132 | + inode = file_inode(fd_file(f)); | |
| 133 | 133 | if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) { |
| 134 | 134 | fdput(f); |
| 135 | 135 | return invalf(fc, "code: Not coda psdev"); |
| @@ -349,9 +349,9 @@ struct eventfd_ctx *eventfd_ctx_fdget(int fd) · 348 unmodified lines | ||
| 349 | 349 | { |
| 350 | 350 | struct eventfd_ctx *ctx; |
| 351 | 351 | struct fd f = fdget(fd); |
| 352 | − if (!f.file) | |
| 352 | + if (!fd_file(f)) | |
| 353 | 353 | return ERR_PTR(-EBADF); |
| 354 | − ctx = eventfd_ctx_fileget(f.file); | |
| 354 | + ctx = eventfd_ctx_fileget(fd_file(f)); | |
| 355 | 355 | fdput(f); |
| 356 | 356 | return ctx; |
| 357 | 357 | } |
| @@ -2266,17 +2266,17 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 2265 unmodified lines | ||
| 2266 | 2266 | |
| 2267 | 2267 | error = -EBADF; |
| 2268 | 2268 | f = fdget(epfd); |
| 2269 | − if (!f.file) | |
| 2269 | + if (!fd_file(f)) | |
| 2270 | 2270 | goto error_return; |
| 2271 | 2271 | |
| 2272 | 2272 | /* Get the "struct file *" for the target file */ |
| 2273 | 2273 | tf = fdget(fd); |
| 2274 | − if (!tf.file) | |
| 2274 | + if (!fd_file(tf)) | |
| 2275 | 2275 | goto error_fput; |
| 2276 | 2276 | |
| 2277 | 2277 | /* The target file descriptor must support poll */ |
| 2278 | 2278 | error = -EPERM; |
| 2279 | − if (!file_can_poll(tf.file)) | |
| 2279 | + if (!file_can_poll(fd_file(tf))) | |
| 2280 | 2280 | goto error_tgt_fput; |
| 2281 | 2281 | |
| 2282 | 2282 | /* Check if EPOLLWAKEUP is allowed */ |
| @@ -2289,7 +2289,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 6 unmodified lines | ||
| 2289 | 2289 | * adding an epoll file descriptor inside itself. |
| 2290 | 2290 | */ |
| 2291 | 2291 | error = -EINVAL; |
| 2292 | − if (f.file == tf.file || !is_file_epoll(f.file)) | |
| 2292 | + if (fd_file(f) == fd_file(tf) || !is_file_epoll(fd_file(f))) | |
| 2293 | 2293 | goto error_tgt_fput; |
| 2294 | 2294 | |
| 2295 | 2295 | /* |
| @@ -2300,7 +2300,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 4 unmodified lines | ||
| 2300 | 2300 | if (ep_op_has_event(op) && (epds->events & EPOLLEXCLUSIVE)) { |
| 2301 | 2301 | if (op == EPOLL_CTL_MOD) |
| 2302 | 2302 | goto error_tgt_fput; |
| 2303 | − if (op == EPOLL_CTL_ADD && (is_file_epoll(tf.file) || | |
| 2303 | + if (op == EPOLL_CTL_ADD && (is_file_epoll(fd_file(tf)) || | |
| 2304 | 2304 | (epds->events & ~EPOLLEXCLUSIVE_OK_BITS))) |
| 2305 | 2305 | goto error_tgt_fput; |
| 2306 | 2306 | } |
| @@ -2309,7 +2309,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 2 unmodified lines | ||
| 2309 | 2309 | * At this point it is safe to assume that the "private_data" contains |
| 2310 | 2310 | * our own data structure. |
| 2311 | 2311 | */ |
| 2312 | − ep = f.file->private_data; | |
| 2312 | + ep = fd_file(f)->private_data; | |
| 2313 | 2313 | |
| 2314 | 2314 | /* |
| 2315 | 2315 | * When we insert an epoll file descriptor inside another epoll file |
| @@ -2330,16 +2330,16 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 14 unmodified lines | ||
| 2330 | 2330 | if (error) |
| 2331 | 2331 | goto error_tgt_fput; |
| 2332 | 2332 | if (op == EPOLL_CTL_ADD) { |
| 2333 | − if (READ_ONCE(f.file->f_ep) || ep->gen == loop_check_gen || | |
| 2334 | − is_file_epoll(tf.file)) { | |
| 2333 | + if (READ_ONCE(fd_file(f)->f_ep) || ep->gen == loop_check_gen || | |
| 2334 | + is_file_epoll(fd_file(tf))) { | |
| 2335 | 2335 | mutex_unlock(&ep->mtx); |
| 2336 | 2336 | error = epoll_mutex_lock(&epnested_mutex, 0, nonblock); |
| 2337 | 2337 | if (error) |
| 2338 | 2338 | goto error_tgt_fput; |
| 2339 | 2339 | loop_check_gen++; |
| 2340 | 2340 | full_check = 1; |
| 2341 | − if (is_file_epoll(tf.file)) { | |
| 2342 | − tep = tf.file->private_data; | |
| 2341 | + if (is_file_epoll(fd_file(tf))) { | |
| 2342 | + tep = fd_file(tf)->private_data; | |
| 2343 | 2343 | error = -ELOOP; |
| 2344 | 2344 | if (ep_loop_check(ep, tep) != 0) |
| 2345 | 2345 | goto error_tgt_fput; |
| @@ -2355,14 +2355,14 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 9 unmodified lines | ||
| 2355 | 2355 | * above, we can be sure to be able to use the item looked up by |
| 2356 | 2356 | * ep_find() till we release the mutex. |
| 2357 | 2357 | */ |
| 2358 | − epi = ep_find(ep, tf.file, fd); | |
| 2358 | + epi = ep_find(ep, fd_file(tf), fd); | |
| 2359 | 2359 | |
| 2360 | 2360 | error = -EINVAL; |
| 2361 | 2361 | switch (op) { |
| 2362 | 2362 | case EPOLL_CTL_ADD: |
| 2363 | 2363 | if (!epi) { |
| 2364 | 2364 | epds->events |= EPOLLERR | EPOLLHUP; |
| 2365 | − error = ep_insert(ep, epds, tf.file, fd, full_check); | |
| 2365 | + error = ep_insert(ep, epds, fd_file(tf), fd, full_check); | |
| 2366 | 2366 | } else |
| 2367 | 2367 | error = -EEXIST; |
| 2368 | 2368 | break; |
| @@ -2443,7 +2443,7 @@ static int do_epoll_wait(int epfd, struct epoll_event __user *events, · 74 unmodified lines | ||
| 2443 | 2443 | |
| 2444 | 2444 | /* Get the "struct file *" for the eventpoll file */ |
| 2445 | 2445 | f = fdget(epfd); |
| 2446 | − if (!f.file) | |
| 2446 | + if (!fd_file(f)) | |
| 2447 | 2447 | return -EBADF; |
| 2448 | 2448 | |
| 2449 | 2449 | /* |
| @@ -2451,14 +2451,14 @@ static int do_epoll_wait(int epfd, struct epoll_event __user *events, · 1 unmodified line | ||
| 2451 | 2451 | * the user passed to us _is_ an eventpoll file. |
| 2452 | 2452 | */ |
| 2453 | 2453 | error = -EINVAL; |
| 2454 | − if (!is_file_epoll(f.file)) | |
| 2454 | + if (!is_file_epoll(fd_file(f))) | |
| 2455 | 2455 | goto error_fput; |
| 2456 | 2456 | |
| 2457 | 2457 | /* |
| 2458 | 2458 | * At this point it is safe to assume that the "private_data" contains |
| 2459 | 2459 | * our own data structure. |
| 2460 | 2460 | */ |
| 2461 | − ep = f.file->private_data; | |
| 2461 | + ep = fd_file(f)->private_data; | |
| 2462 | 2462 | |
| 2463 | 2463 | /* Time to fish for events ... */ |
| 2464 | 2464 | error = ep_poll(ep, events, maxevents, to); |
| @@ -1343,10 +1343,10 @@ group_extend_out: · 1342 unmodified lines | ||
| 1343 | 1343 | me.moved_len = 0; |
| 1344 | 1344 | |
| 1345 | 1345 | donor = fdget(me.donor_fd); |
| 1346 | − if (!donor.file) | |
| 1346 | + if (!fd_file(donor)) | |
| 1347 | 1347 | return -EBADF; |
| 1348 | 1348 | |
| 1349 | − if (!(donor.file->f_mode & FMODE_WRITE)) { | |
| 1349 | + if (!(fd_file(donor)->f_mode & FMODE_WRITE)) { | |
| 1350 | 1350 | err = -EBADF; |
| 1351 | 1351 | goto mext_out; |
| 1352 | 1352 | } |
| @@ -1367,7 +1367,7 @@ group_extend_out: · 14 unmodified lines | ||
| 1367 | 1367 | if (err) |
| 1368 | 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 | 1371 | me.donor_start, me.len, &me.moved_len); |
| 1372 | 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 | 3014 | return -EBADF; |
| 3015 | 3015 | |
| 3016 | 3016 | dst = fdget(range->dst_fd); |
| 3017 | − if (!dst.file) | |
| 3017 | + if (!fd_file(dst)) | |
| 3018 | 3018 | return -EBADF; |
| 3019 | 3019 | |
| 3020 | − if (!(dst.file->f_mode & FMODE_WRITE)) { | |
| 3020 | + if (!(fd_file(dst)->f_mode & FMODE_WRITE)) { | |
| 3021 | 3021 | err = -EBADF; |
| 3022 | 3022 | goto err_out; |
| 3023 | 3023 | } |
| @@ -3026,7 +3026,7 @@ static int __f2fs_ioc_move_range(struct file *filp, · 2 unmodified lines | ||
| 3026 | 3026 | if (err) |
| 3027 | 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 | 3030 | range->pos_out, range->len); |
| 3031 | 3031 | |
| 3032 | 3032 | mnt_drop_write_file(filp); |
| @@ -340,7 +340,7 @@ static long f_dupfd_query(int fd, struct file *filp) · 339 unmodified lines | ||
| 340 | 340 | * overkill, but given our lockless file pointer lookup, the |
| 341 | 341 | * alternatives are complicated. |
| 342 | 342 | */ |
| 343 | − return f.file == filp; | |
| 343 | + return fd_file(f) == filp; | |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, |
| @@ -479,17 +479,17 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) · 132 unmodified lines | ||
| 479 | 479 | struct fd f = fdget_raw(fd); |
| 480 | 480 | long err = -EBADF; |
| 481 | 481 | |
| 482 | − if (!f.file) | |
| 482 | + if (!fd_file(f)) | |
| 483 | 483 | goto out; |
| 484 | 484 | |
| 485 | − if (unlikely(f.file->f_mode & FMODE_PATH)) { | |
| 485 | + if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) { | |
| 486 | 486 | if (!check_fcntl_cmd(cmd)) |
| 487 | 487 | goto out1; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | − err = security_file_fcntl(f.file, cmd, arg); | |
| 490 | + err = security_file_fcntl(fd_file(f), cmd, arg); | |
| 491 | 491 | if (!err) |
| 492 | − err = do_fcntl(fd, cmd, arg, f.file); | |
| 492 | + err = do_fcntl(fd, cmd, arg, fd_file(f)); | |
| 493 | 493 | |
| 494 | 494 | out1: |
| 495 | 495 | fdput(f); |
| @@ -506,15 +506,15 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 10 unmodified lines | ||
| 506 | 506 | struct flock64 flock; |
| 507 | 507 | long err = -EBADF; |
| 508 | 508 | |
| 509 | − if (!f.file) | |
| 509 | + if (!fd_file(f)) | |
| 510 | 510 | goto out; |
| 511 | 511 | |
| 512 | − if (unlikely(f.file->f_mode & FMODE_PATH)) { | |
| 512 | + if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) { | |
| 513 | 513 | if (!check_fcntl_cmd(cmd)) |
| 514 | 514 | goto out1; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | − err = security_file_fcntl(f.file, cmd, arg); | |
| 517 | + err = security_file_fcntl(fd_file(f), cmd, arg); | |
| 518 | 518 | if (err) |
| 519 | 519 | goto out1; |
| 520 | 520 | |
| @@ -524,7 +524,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 3 unmodified lines | ||
| 524 | 524 | err = -EFAULT; |
| 525 | 525 | if (copy_from_user(&flock, argp, sizeof(flock))) |
| 526 | 526 | break; |
| 527 | − err = fcntl_getlk64(f.file, cmd, &flock); | |
| 527 | + err = fcntl_getlk64(fd_file(f), cmd, &flock); | |
| 528 | 528 | if (!err && copy_to_user(argp, &flock, sizeof(flock))) |
| 529 | 529 | err = -EFAULT; |
| 530 | 530 | break; |
| @@ -535,10 +535,10 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 4 unmodified lines | ||
| 535 | 535 | err = -EFAULT; |
| 536 | 536 | if (copy_from_user(&flock, argp, sizeof(flock))) |
| 537 | 537 | break; |
| 538 | − err = fcntl_setlk64(fd, f.file, cmd, &flock); | |
| 538 | + err = fcntl_setlk64(fd, fd_file(f), cmd, &flock); | |
| 539 | 539 | break; |
| 540 | 540 | default: |
| 541 | − err = do_fcntl(fd, cmd, arg, f.file); | |
| 541 | + err = do_fcntl(fd, cmd, arg, fd_file(f)); | |
| 542 | 542 | break; |
| 543 | 543 | } |
| 544 | 544 | out1: |
| @@ -643,15 +643,15 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 98 unmodified lines | ||
| 643 | 643 | struct flock flock; |
| 644 | 644 | long err = -EBADF; |
| 645 | 645 | |
| 646 | − if (!f.file) | |
| 646 | + if (!fd_file(f)) | |
| 647 | 647 | return err; |
| 648 | 648 | |
| 649 | − if (unlikely(f.file->f_mode & FMODE_PATH)) { | |
| 649 | + if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) { | |
| 650 | 650 | if (!check_fcntl_cmd(cmd)) |
| 651 | 651 | goto out_put; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | − err = security_file_fcntl(f.file, cmd, arg); | |
| 654 | + err = security_file_fcntl(fd_file(f), cmd, arg); | |
| 655 | 655 | if (err) |
| 656 | 656 | goto out_put; |
| 657 | 657 | |
| @@ -660,7 +660,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines | ||
| 660 | 660 | err = get_compat_flock(&flock, compat_ptr(arg)); |
| 661 | 661 | if (err) |
| 662 | 662 | break; |
| 663 | − err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); | |
| 663 | + err = fcntl_getlk(fd_file(f), convert_fcntl_cmd(cmd), &flock); | |
| 664 | 664 | if (err) |
| 665 | 665 | break; |
| 666 | 666 | err = fixup_compat_flock(&flock); |
| @@ -672,7 +672,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 5 unmodified lines | ||
| 672 | 672 | err = get_compat_flock64(&flock, compat_ptr(arg)); |
| 673 | 673 | if (err) |
| 674 | 674 | break; |
| 675 | − err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); | |
| 675 | + err = fcntl_getlk(fd_file(f), convert_fcntl_cmd(cmd), &flock); | |
| 676 | 676 | if (!err) |
| 677 | 677 | err = put_compat_flock64(&flock, compat_ptr(arg)); |
| 678 | 678 | break; |
| @@ -681,7 +681,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines | ||
| 681 | 681 | err = get_compat_flock(&flock, compat_ptr(arg)); |
| 682 | 682 | if (err) |
| 683 | 683 | break; |
| 684 | − err = fcntl_setlk(fd, f.file, convert_fcntl_cmd(cmd), &flock); | |
| 684 | + err = fcntl_setlk(fd, fd_file(f), convert_fcntl_cmd(cmd), &flock); | |
| 685 | 685 | break; |
| 686 | 686 | case F_SETLK64: |
| 687 | 687 | case F_SETLKW64: |
| @@ -690,10 +690,10 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines | ||
| 690 | 690 | err = get_compat_flock64(&flock, compat_ptr(arg)); |
| 691 | 691 | if (err) |
| 692 | 692 | break; |
| 693 | − err = fcntl_setlk(fd, f.file, convert_fcntl_cmd(cmd), &flock); | |
| 693 | + err = fcntl_setlk(fd, fd_file(f), convert_fcntl_cmd(cmd), &flock); | |
| 694 | 694 | break; |
| 695 | 695 | default: |
| 696 | − err = do_fcntl(fd, cmd, arg, f.file); | |
| 696 | + err = do_fcntl(fd, cmd, arg, fd_file(f)); | |
| 697 | 697 | break; |
| 698 | 698 | } |
| 699 | 699 | out_put: |
| @@ -125,9 +125,9 @@ static int get_path_from_fd(int fd, struct path *root) · 124 unmodified lines | ||
| 125 | 125 | spin_unlock(&fs->lock); |
| 126 | 126 | } else { |
| 127 | 127 | struct fd f = fdget(fd); |
| 128 | − if (!f.file) | |
| 128 | + if (!fd_file(f)) | |
| 129 | 129 | return -EBADF; |
| 130 | − *root = f.file->f_path; | |
| 130 | + *root = fd_file(f)->f_path; | |
| 131 | 131 | path_get(root); |
| 132 | 132 | fdput(f); |
| 133 | 133 | } |
| @@ -394,13 +394,13 @@ SYSCALL_DEFINE5(fsconfig, · 393 unmodified lines | ||
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | f = fdget(fd); |
| 397 | − if (!f.file) | |
| 397 | + if (!fd_file(f)) | |
| 398 | 398 | return -EBADF; |
| 399 | 399 | ret = -EINVAL; |
| 400 | − if (f.file->f_op != &fscontext_fops) | |
| 400 | + if (fd_file(f)->f_op != &fscontext_fops) | |
| 401 | 401 | goto out_f; |
| 402 | 402 | |
| 403 | − fc = f.file->private_data; | |
| 403 | + fc = fd_file(f)->private_data; | |
| 404 | 404 | if (fc->ops == &legacy_fs_context_ops) { |
| 405 | 405 | switch (cmd) { |
| 406 | 406 | case FSCONFIG_SET_BINARY: |
| @@ -2321,15 +2321,15 @@ static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp) · 2320 unmodified lines | ||
| 2321 | 2321 | return -EFAULT; |
| 2322 | 2322 | |
| 2323 | 2323 | f = fdget(oldfd); |
| 2324 | − if (!f.file) | |
| 2324 | + if (!fd_file(f)) | |
| 2325 | 2325 | return -EINVAL; |
| 2326 | 2326 | |
| 2327 | 2327 | /* |
| 2328 | 2328 | * Check against file->f_op because CUSE |
| 2329 | 2329 | * uses the same ioctl handler. |
| 2330 | 2330 | */ |
| 2331 | − if (f.file->f_op == file->f_op) | |
| 2332 | − fud = fuse_get_dev(f.file); | |
| 2331 | + if (fd_file(f)->f_op == file->f_op) | |
| 2332 | + fud = fuse_get_dev(fd_file(f)); | |
| 2333 | 2333 | |
| 2334 | 2334 | res = -EINVAL; |
| 2335 | 2335 | if (fud) { |
| @@ -235,9 +235,9 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, · 234 unmodified lines | ||
| 235 | 235 | loff_t cloned; |
| 236 | 236 | int ret; |
| 237 | 237 | |
| 238 | − if (!src_file.file) | |
| 238 | + if (!fd_file(src_file)) | |
| 239 | 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 | 241 | olen, 0); |
| 242 | 242 | if (cloned < 0) |
| 243 | 243 | ret = cloned; |
| @@ -895,16 +895,16 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) · 651 unmodified lines | ||
| 895 | 895 | struct fd f = fdget(fd); |
| 896 | 896 | int error; |
| 897 | 897 | |
| 898 | − if (!f.file) | |
| 898 | + if (!fd_file(f)) | |
| 899 | 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 | 902 | if (error) |
| 903 | 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 | 906 | if (error == -ENOIOCTLCMD) |
| 907 | − error = vfs_ioctl(f.file, cmd, arg); | |
| 907 | + error = vfs_ioctl(fd_file(f), cmd, arg); | |
| 908 | 908 | |
| 909 | 909 | out: |
| 910 | 910 | fdput(f); |
| @@ -953,32 +953,32 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, · 42 unmodified lines | ||
| 953 | 953 | struct fd f = fdget(fd); |
| 954 | 954 | int error; |
| 955 | 955 | |
| 956 | − if (!f.file) | |
| 956 | + if (!fd_file(f)) | |
| 957 | 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 | 960 | if (error) |
| 961 | 961 | goto out; |
| 962 | 962 | |
| 963 | 963 | switch (cmd) { |
| 964 | 964 | /* FICLONE takes an int argument, so don't use compat_ptr() */ |
| 965 | 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 | 967 | break; |
| 968 | 968 | |
| 969 | 969 | #if defined(CONFIG_X86_64) |
| 970 | 970 | /* these get messy on amd64 due to alignment differences */ |
| 971 | 971 | case FS_IOC_RESVSP_32: |
| 972 | 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 | 974 | break; |
| 975 | 975 | case FS_IOC_UNRESVSP_32: |
| 976 | 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 | 978 | compat_ptr(arg)); |
| 979 | 979 | break; |
| 980 | 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 | 982 | compat_ptr(arg)); |
| 983 | 983 | break; |
| 984 | 984 | #endif |
| @@ -998,13 +998,13 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, · 13 unmodified lines | ||
| 998 | 998 | * argument. |
| 999 | 999 | */ |
| 1000 | 1000 | default: |
| 1001 | − error = do_vfs_ioctl(f.file, fd, cmd, | |
| 1001 | + error = do_vfs_ioctl(fd_file(f), fd, cmd, | |
| 1002 | 1002 | (unsigned long)compat_ptr(arg)); |
| 1003 | 1003 | if (error != -ENOIOCTLCMD) |
| 1004 | 1004 | break; |
| 1005 | 1005 | |
| 1006 | − if (f.file->f_op->compat_ioctl) | |
| 1007 | − error = f.file->f_op->compat_ioctl(f.file, cmd, arg); | |
| 1006 | + if (fd_file(f)->f_op->compat_ioctl) | |
| 1007 | + error = fd_file(f)->f_op->compat_ioctl(fd_file(f), cmd, arg); | |
| 1008 | 1008 | if (error == -ENOIOCTLCMD) |
| 1009 | 1009 | error = -ENOTTY; |
| 1010 | 1010 | break; |
| @@ -178,10 +178,10 @@ ssize_t kernel_read_file_from_fd(int fd, loff_t offset, void **buf, · 177 unmodified lines | ||
| 178 | 178 | struct fd f = fdget(fd); |
| 179 | 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 | 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 | 185 | out: |
| 186 | 186 | fdput(f); |
| 187 | 187 | return ret; |
| @@ -2153,15 +2153,15 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) · 2152 unmodified lines | ||
| 2153 | 2153 | |
| 2154 | 2154 | error = -EBADF; |
| 2155 | 2155 | f = fdget(fd); |
| 2156 | − if (!f.file) | |
| 2156 | + if (!fd_file(f)) | |
| 2157 | 2157 | return error; |
| 2158 | 2158 | |
| 2159 | − if (type != F_UNLCK && !(f.file->f_mode & (FMODE_READ | FMODE_WRITE))) | |
| 2159 | + if (type != F_UNLCK && !(fd_file(f)->f_mode & (FMODE_READ | FMODE_WRITE))) | |
| 2160 | 2160 | goto out_putf; |
| 2161 | 2161 | |
| 2162 | − flock_make_lock(f.file, &fl, type); | |
| 2162 | + flock_make_lock(fd_file(f), &fl, type); | |
| 2163 | 2163 | |
| 2164 | − error = security_file_lock(f.file, fl.c.flc_type); | |
| 2164 | + error = security_file_lock(fd_file(f), fl.c.flc_type); | |
| 2165 | 2165 | if (error) |
| 2166 | 2166 | goto out_putf; |
| 2167 | 2167 | |
| @@ -2169,12 +2169,12 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) · 1 unmodified line | ||
| 2169 | 2169 | if (can_sleep) |
| 2170 | 2170 | fl.c.flc_flags |= FL_SLEEP; |
| 2171 | 2171 | |
| 2172 | − if (f.file->f_op->flock) | |
| 2173 | − error = f.file->f_op->flock(f.file, | |
| 2172 | + if (fd_file(f)->f_op->flock) | |
| 2173 | + error = fd_file(f)->f_op->flock(fd_file(f), | |
| 2174 | 2174 | (can_sleep) ? F_SETLKW : F_SETLK, |
| 2175 | 2175 | &fl); |
| 2176 | 2176 | else |
| 2177 | − error = locks_lock_file_wait(f.file, &fl); | |
| 2177 | + error = locks_lock_file_wait(fd_file(f), &fl); | |
| 2178 | 2178 | |
| 2179 | 2179 | locks_release_private(&fl); |
| 2180 | 2180 | out_putf: |
| @@ -2492,25 +2492,25 @@ static const char *path_init(struct nameidata *nd, unsigned flags) · 2491 unmodified lines | ||
| 2492 | 2492 | struct fd f = fdget_raw(nd->dfd); |
| 2493 | 2493 | struct dentry *dentry; |
| 2494 | 2494 | |
| 2495 | − if (!f.file) | |
| 2495 | + if (!fd_file(f)) | |
| 2496 | 2496 | return ERR_PTR(-EBADF); |
| 2497 | 2497 | |
| 2498 | 2498 | if (flags & LOOKUP_LINKAT_EMPTY) { |
| 2499 | − if (f.file->f_cred != current_cred() && | |
| 2500 | − !ns_capable(f.file->f_cred->user_ns, CAP_DAC_READ_SEARCH)) { | |
| 2499 | + if (fd_file(f)->f_cred != current_cred() && | |
| 2500 | + !ns_capable(fd_file(f)->f_cred->user_ns, CAP_DAC_READ_SEARCH)) { | |
| 2501 | 2501 | fdput(f); |
| 2502 | 2502 | return ERR_PTR(-ENOENT); |
| 2503 | 2503 | } |
| 2504 | 2504 | } |
| 2505 | 2505 | |
| 2506 | − dentry = f.file->f_path.dentry; | |
| 2506 | + dentry = fd_file(f)->f_path.dentry; | |
| 2507 | 2507 | |
| 2508 | 2508 | if (*s && unlikely(!d_can_lookup(dentry))) { |
| 2509 | 2509 | fdput(f); |
| 2510 | 2510 | return ERR_PTR(-ENOTDIR); |
| 2511 | 2511 | } |
| 2512 | 2512 | |
| 2513 | − nd->path = f.file->f_path; | |
| 2513 | + nd->path = fd_file(f)->f_path; | |
| 2514 | 2514 | if (flags & LOOKUP_RCU) { |
| 2515 | 2515 | nd->inode = nd->path.dentry->d_inode; |
| 2516 | 2516 | nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); |
| @@ -4099,14 +4099,14 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, · 4098 unmodified lines | ||
| 4099 | 4099 | } |
| 4100 | 4100 | |
| 4101 | 4101 | f = fdget(fs_fd); |
| 4102 | − if (!f.file) | |
| 4102 | + if (!fd_file(f)) | |
| 4103 | 4103 | return -EBADF; |
| 4104 | 4104 | |
| 4105 | 4105 | ret = -EINVAL; |
| 4106 | − if (f.file->f_op != &fscontext_fops) | |
| 4106 | + if (fd_file(f)->f_op != &fscontext_fops) | |
| 4107 | 4107 | goto err_fsfd; |
| 4108 | 4108 | |
| 4109 | − fc = f.file->private_data; | |
| 4109 | + fc = fd_file(f)->private_data; | |
| 4110 | 4110 | |
| 4111 | 4111 | ret = mutex_lock_interruptible(&fc->uapi_mutex); |
| 4112 | 4112 | if (ret < 0) |
| @@ -4649,15 +4649,15 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize, · 536 unmodified lines | ||
| 4649 | 4649 | return -EINVAL; |
| 4650 | 4650 | |
| 4651 | 4651 | f = fdget(attr->userns_fd); |
| 4652 | − if (!f.file) | |
| 4652 | + if (!fd_file(f)) | |
| 4653 | 4653 | return -EBADF; |
| 4654 | 4654 | |
| 4655 | − if (!proc_ns_file(f.file)) { | |
| 4655 | + if (!proc_ns_file(fd_file(f))) { | |
| 4656 | 4656 | err = -EINVAL; |
| 4657 | 4657 | goto out_fput; |
| 4658 | 4658 | } |
| 4659 | 4659 | |
| 4660 | − ns = get_proc_ns(file_inode(f.file)); | |
| 4660 | + ns = get_proc_ns(file_inode(fd_file(f))); | |
| 4661 | 4661 | if (ns->ops->type != CLONE_NEWUSER) { |
| 4662 | 4662 | err = -EINVAL; |
| 4663 | 4663 | goto out_fput; |
| @@ -1006,17 +1006,17 @@ static int fanotify_find_path(int dfd, const char __user *filename, · 1005 unmodified lines | ||
| 1006 | 1006 | struct fd f = fdget(dfd); |
| 1007 | 1007 | |
| 1008 | 1008 | ret = -EBADF; |
| 1009 | − if (!f.file) | |
| 1009 | + if (!fd_file(f)) | |
| 1010 | 1010 | goto out; |
| 1011 | 1011 | |
| 1012 | 1012 | ret = -ENOTDIR; |
| 1013 | 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 | 1015 | fdput(f); |
| 1016 | 1016 | goto out; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | − *path = f.file->f_path; | |
| 1019 | + *path = fd_file(f)->f_path; | |
| 1020 | 1020 | path_get(path); |
| 1021 | 1021 | fdput(f); |
| 1022 | 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 | 1755 | f = fdget(fanotify_fd); |
| 1756 | − if (unlikely(!f.file)) | |
| 1756 | + if (unlikely(!fd_file(f))) | |
| 1757 | 1757 | return -EBADF; |
| 1758 | 1758 | |
| 1759 | 1759 | /* verify that this is indeed an fanotify instance */ |
| 1760 | 1760 | ret = -EINVAL; |
| 1761 | − if (unlikely(f.file->f_op != &fanotify_fops)) | |
| 1761 | + if (unlikely(fd_file(f)->f_op != &fanotify_fops)) | |
| 1762 | 1762 | goto fput_and_out; |
| 1763 | − group = f.file->private_data; | |
| 1763 | + group = fd_file(f)->private_data; | |
| 1764 | 1764 | |
| 1765 | 1765 | /* |
| 1766 | 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 | 753 | return -EINVAL; |
| 754 | 754 | |
| 755 | 755 | f = fdget(fd); |
| 756 | − if (unlikely(!f.file)) | |
| 756 | + if (unlikely(!fd_file(f))) | |
| 757 | 757 | return -EBADF; |
| 758 | 758 | |
| 759 | 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 | 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 | 767 | ret = -EINVAL; |
| 768 | 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 | 781 | /* inode held in place by reference to path; group by fget on fd */ |
| 782 | 782 | inode = path.dentry->d_inode; |
| 783 | − group = f.file->private_data; | |
| 783 | + group = fd_file(f)->private_data; | |
| 784 | 784 | |
| 785 | 785 | /* create/update an inode mark */ |
| 786 | 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 | 798 | int ret = -EINVAL; |
| 799 | 799 | |
| 800 | 800 | f = fdget(fd); |
| 801 | − if (unlikely(!f.file)) | |
| 801 | + if (unlikely(!fd_file(f))) | |
| 802 | 802 | return -EBADF; |
| 803 | 803 | |
| 804 | 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 | 806 | goto out; |
| 807 | 807 | |
| 808 | − group = f.file->private_data; | |
| 808 | + group = fd_file(f)->private_data; | |
| 809 | 809 | |
| 810 | 810 | i_mark = inotify_idr_find(group, wd); |
| 811 | 811 | if (unlikely(!i_mark)) |
| @@ -1785,17 +1785,17 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, · 1784 unmodified lines | ||
| 1785 | 1785 | goto out; |
| 1786 | 1786 | |
| 1787 | 1787 | f = fdget(fd); |
| 1788 | − if (f.file == NULL) | |
| 1788 | + if (fd_file(f) == NULL) | |
| 1789 | 1789 | goto out; |
| 1790 | 1790 | |
| 1791 | 1791 | if (reg->hr_blocks == 0 || reg->hr_start_block == 0 || |
| 1792 | 1792 | reg->hr_block_bytes == 0) |
| 1793 | 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 | 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 | 1799 | BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, NULL); |
| 1800 | 1800 | if (IS_ERR(reg->hr_bdev_file)) { |
| 1801 | 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 | 193 | if (length < 0) |
| 194 | 194 | return -EINVAL; |
| 195 | 195 | f = fdget(fd); |
| 196 | − if (!f.file) | |
| 196 | + if (!fd_file(f)) | |
| 197 | 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 | 201 | fdput(f); |
| 202 | 202 | return error; |
| @@ -353,8 +353,8 @@ int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len) · 150 unmodified lines | ||
| 353 | 353 | struct fd f = fdget(fd); |
| 354 | 354 | int error = -EBADF; |
| 355 | 355 | |
| 356 | − if (f.file) { | |
| 357 | − error = vfs_fallocate(f.file, mode, offset, len); | |
| 356 | + if (fd_file(f)) { | |
| 357 | + error = vfs_fallocate(fd_file(f), mode, offset, len); | |
| 358 | 358 | fdput(f); |
| 359 | 359 | } |
| 360 | 360 | return error; |
| @@ -585,16 +585,16 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd) · 224 unmodified lines | ||
| 585 | 585 | int error; |
| 586 | 586 | |
| 587 | 587 | error = -EBADF; |
| 588 | − if (!f.file) | |
| 588 | + if (!fd_file(f)) | |
| 589 | 589 | goto out; |
| 590 | 590 | |
| 591 | 591 | error = -ENOTDIR; |
| 592 | − if (!d_can_lookup(f.file->f_path.dentry)) | |
| 592 | + if (!d_can_lookup(fd_file(f)->f_path.dentry)) | |
| 593 | 593 | goto out_putf; |
| 594 | 594 | |
| 595 | − error = file_permission(f.file, MAY_EXEC | MAY_CHDIR); | |
| 595 | + error = file_permission(fd_file(f), MAY_EXEC | MAY_CHDIR); | |
| 596 | 596 | if (!error) |
| 597 | − set_fs_pwd(current->fs, &f.file->f_path); | |
| 597 | + set_fs_pwd(current->fs, &fd_file(f)->f_path); | |
| 598 | 598 | out_putf: |
| 599 | 599 | fdput(f); |
| 600 | 600 | out: |
| @@ -675,8 +675,8 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) · 74 unmodified lines | ||
| 675 | 675 | struct fd f = fdget(fd); |
| 676 | 676 | int err = -EBADF; |
| 677 | 677 | |
| 678 | − if (f.file) { | |
| 679 | − err = vfs_fchmod(f.file, mode); | |
| 678 | + if (fd_file(f)) { | |
| 679 | + err = vfs_fchmod(fd_file(f), mode); | |
| 680 | 680 | fdput(f); |
| 681 | 681 | } |
| 682 | 682 | return err; |
| @@ -869,8 +869,8 @@ int ksys_fchown(unsigned int fd, uid_t user, gid_t group) · 186 unmodified lines | ||
| 869 | 869 | struct fd f = fdget(fd); |
| 870 | 870 | int error = -EBADF; |
| 871 | 871 | |
| 872 | − if (f.file) { | |
| 873 | − error = vfs_fchown(f.file, user, group); | |
| 872 | + if (fd_file(f)) { | |
| 873 | + error = vfs_fchown(fd_file(f), user, group); | |
| 874 | 874 | fdput(f); |
| 875 | 875 | } |
| 876 | 876 | return error; |
| @@ -209,13 +209,13 @@ static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) · 208 unmodified lines | ||
| 209 | 209 | * files, so we use the real file to perform seeks. |
| 210 | 210 | */ |
| 211 | 211 | ovl_inode_lock(inode); |
| 212 | − real.file->f_pos = file->f_pos; | |
| 212 | + fd_file(real)->f_pos = file->f_pos; | |
| 213 | 213 | |
| 214 | 214 | old_cred = ovl_override_creds(inode->i_sb); |
| 215 | − ret = vfs_llseek(real.file, offset, whence); | |
| 215 | + ret = vfs_llseek(fd_file(real), offset, whence); | |
| 216 | 216 | revert_creds(old_cred); |
| 217 | 217 | |
| 218 | − file->f_pos = real.file->f_pos; | |
| 218 | + file->f_pos = fd_file(real)->f_pos; | |
| 219 | 219 | ovl_inode_unlock(inode); |
| 220 | 220 | |
| 221 | 221 | fdput(real); |
| @@ -275,7 +275,7 @@ static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter) · 53 unmodified lines | ||
| 275 | 275 | if (ret) |
| 276 | 276 | return ret; |
| 277 | 277 | |
| 278 | − ret = backing_file_read_iter(real.file, iter, iocb, iocb->ki_flags, | |
| 278 | + ret = backing_file_read_iter(fd_file(real), iter, iocb, iocb->ki_flags, | |
| 279 | 279 | &ctx); |
| 280 | 280 | fdput(real); |
| 281 | 281 | |
| @@ -314,7 +314,7 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) · 32 unmodified lines | ||
| 314 | 314 | * this property in case it is set by the issuer. |
| 315 | 315 | */ |
| 316 | 316 | ifl &= ~IOCB_DIO_CALLER_COMP; |
| 317 | − ret = backing_file_write_iter(real.file, iter, iocb, ifl, &ctx); | |
| 317 | + ret = backing_file_write_iter(fd_file(real), iter, iocb, ifl, &ctx); | |
| 318 | 318 | fdput(real); |
| 319 | 319 | |
| 320 | 320 | out_unlock: |
| @@ -339,7 +339,7 @@ static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, · 18 unmodified lines | ||
| 339 | 339 | if (ret) |
| 340 | 340 | return ret; |
| 341 | 341 | |
| 342 | − ret = backing_file_splice_read(real.file, ppos, pipe, len, flags, &ctx); | |
| 342 | + ret = backing_file_splice_read(fd_file(real), ppos, pipe, len, flags, &ctx); | |
| 343 | 343 | fdput(real); |
| 344 | 344 | |
| 345 | 345 | return ret; |
| @@ -348,7 +348,7 @@ static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, · 2 unmodified lines | ||
| 348 | 348 | /* |
| 349 | 349 | * Calling iter_file_splice_write() directly from overlay's f_op may deadlock |
| 350 | 350 | * due to lock order inversion between pipe->mutex in iter_file_splice_write() |
| 351 | − * and file_start_write(real.file) in ovl_write_iter(). | |
| 351 | + * and file_start_write(fd_file(real)) in ovl_write_iter(). | |
| 352 | 352 | * |
| 353 | 353 | * So do everything ovl_write_iter() does and call iter_file_splice_write() on |
| 354 | 354 | * the real file. |
| @@ -373,7 +373,7 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, · 18 unmodified lines | ||
| 373 | 373 | if (ret) |
| 374 | 374 | goto out_unlock; |
| 375 | 375 | |
| 376 | − ret = backing_file_splice_write(pipe, real.file, ppos, len, flags, &ctx); | |
| 376 | + ret = backing_file_splice_write(pipe, fd_file(real), ppos, len, flags, &ctx); | |
| 377 | 377 | fdput(real); |
| 378 | 378 | |
| 379 | 379 | out_unlock: |
| @@ -397,9 +397,9 @@ static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) · 17 unmodified lines | ||
| 397 | 397 | return ret; |
| 398 | 398 | |
| 399 | 399 | /* Don't sync lower file for fear of receiving EROFS error */ |
| 400 | − if (file_inode(real.file) == ovl_inode_upper(file_inode(file))) { | |
| 400 | + if (file_inode(fd_file(real)) == ovl_inode_upper(file_inode(file))) { | |
| 401 | 401 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 402 | − ret = vfs_fsync_range(real.file, start, end, datasync); | |
| 402 | + ret = vfs_fsync_range(fd_file(real), start, end, datasync); | |
| 403 | 403 | revert_creds(old_cred); |
| 404 | 404 | } |
| 405 | 405 | |
| @@ -439,7 +439,7 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len · 33 unmodified lines | ||
| 439 | 439 | goto out_unlock; |
| 440 | 440 | |
| 441 | 441 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 442 | − ret = vfs_fallocate(real.file, mode, offset, len); | |
| 442 | + ret = vfs_fallocate(fd_file(real), mode, offset, len); | |
| 443 | 443 | revert_creds(old_cred); |
| 444 | 444 | |
| 445 | 445 | /* Update size */ |
| @@ -464,7 +464,7 @@ static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) · 18 unmodified lines | ||
| 464 | 464 | return ret; |
| 465 | 465 | |
| 466 | 466 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 467 | − ret = vfs_fadvise(real.file, offset, len, advice); | |
| 467 | + ret = vfs_fadvise(fd_file(real), offset, len, advice); | |
| 468 | 468 | revert_creds(old_cred); |
| 469 | 469 | |
| 470 | 470 | fdput(real); |
| @@ -509,18 +509,18 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, · 38 unmodified lines | ||
| 509 | 509 | old_cred = ovl_override_creds(file_inode(file_out)->i_sb); |
| 510 | 510 | switch (op) { |
| 511 | 511 | case OVL_COPY: |
| 512 | − ret = vfs_copy_file_range(real_in.file, pos_in, | |
| 513 | − real_out.file, pos_out, len, flags); | |
| 512 | + ret = vfs_copy_file_range(fd_file(real_in), pos_in, | |
| 513 | + fd_file(real_out), pos_out, len, flags); | |
| 514 | 514 | break; |
| 515 | 515 | |
| 516 | 516 | case OVL_CLONE: |
| 517 | − ret = vfs_clone_file_range(real_in.file, pos_in, | |
| 518 | − real_out.file, pos_out, len, flags); | |
| 517 | + ret = vfs_clone_file_range(fd_file(real_in), pos_in, | |
| 518 | + fd_file(real_out), pos_out, len, flags); | |
| 519 | 519 | break; |
| 520 | 520 | |
| 521 | 521 | case OVL_DEDUPE: |
| 522 | − ret = vfs_dedupe_file_range_one(real_in.file, pos_in, | |
| 523 | − real_out.file, pos_out, len, | |
| 522 | + ret = vfs_dedupe_file_range_one(fd_file(real_in), pos_in, | |
| 523 | + fd_file(real_out), pos_out, len, | |
| 524 | 524 | flags); |
| 525 | 525 | break; |
| 526 | 526 | } |
| @@ -583,9 +583,9 @@ static int ovl_flush(struct file *file, fl_owner_t id) · 56 unmodified lines | ||
| 583 | 583 | if (err) |
| 584 | 584 | return err; |
| 585 | 585 | |
| 586 | − if (real.file->f_op->flush) { | |
| 586 | + if (fd_file(real)->f_op->flush) { | |
| 587 | 587 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 588 | − err = real.file->f_op->flush(real.file, id); | |
| 588 | + err = fd_file(real)->f_op->flush(fd_file(real), id); | |
| 589 | 589 | revert_creds(old_cred); |
| 590 | 590 | } |
| 591 | 591 | fdput(real); |
| @@ -980,7 +980,7 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 979 unmodified lines | ||
| 980 | 980 | int ret; |
| 981 | 981 | |
| 982 | 982 | f = fdget_raw(fd); |
| 983 | − if (!f.file) | |
| 983 | + if (!fd_file(f)) | |
| 984 | 984 | return -EBADF; |
| 985 | 985 | |
| 986 | 986 | ret = -EINVAL; |
| @@ -988,12 +988,12 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 1 unmodified line | ||
| 988 | 988 | goto out; |
| 989 | 989 | |
| 990 | 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 | 992 | if (ret) |
| 993 | 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 | 997 | if (quotactl_cmd_onoff(cmds)) |
| 998 | 998 | down_write(&sb->s_umount); |
| 999 | 999 | else |
| @@ -1007,7 +1007,7 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 7 unmodified lines | ||
| 1007 | 1007 | up_read(&sb->s_umount); |
| 1008 | 1008 | |
| 1009 | 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 | 1011 | out: |
| 1012 | 1012 | fdput(f); |
| 1013 | 1013 | return ret; |
| @@ -294,12 +294,12 @@ static off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence) · 293 unmodified lines | ||
| 294 | 294 | { |
| 295 | 295 | off_t retval; |
| 296 | 296 | struct fd f = fdget_pos(fd); |
| 297 | − if (!f.file) | |
| 297 | + if (!fd_file(f)) | |
| 298 | 298 | return -EBADF; |
| 299 | 299 | |
| 300 | 300 | retval = -EINVAL; |
| 301 | 301 | if (whence <= SEEK_MAX) { |
| 302 | − loff_t res = vfs_llseek(f.file, offset, whence); | |
| 302 | + loff_t res = vfs_llseek(fd_file(f), offset, whence); | |
| 303 | 303 | retval = res; |
| 304 | 304 | if (res != (loff_t)retval) |
| 305 | 305 | retval = -EOVERFLOW; /* LFS: should only happen on 32 bit platforms */ |
| @@ -330,14 +330,14 @@ SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned long, offset_high, · 24 unmodified lines | ||
| 330 | 330 | struct fd f = fdget_pos(fd); |
| 331 | 331 | loff_t offset; |
| 332 | 332 | |
| 333 | − if (!f.file) | |
| 333 | + if (!fd_file(f)) | |
| 334 | 334 | return -EBADF; |
| 335 | 335 | |
| 336 | 336 | retval = -EINVAL; |
| 337 | 337 | if (whence > SEEK_MAX) |
| 338 | 338 | goto out_putf; |
| 339 | 339 | |
| 340 | − offset = vfs_llseek(f.file, ((loff_t) offset_high << 32) | offset_low, | |
| 340 | + offset = vfs_llseek(fd_file(f), ((loff_t) offset_high << 32) | offset_low, | |
| 341 | 341 | whence); |
| 342 | 342 | |
| 343 | 343 | retval = (int)offset; |
| @@ -610,15 +610,15 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) · 266 unmodified lines | ||
| 610 | 610 | struct fd f = fdget_pos(fd); |
| 611 | 611 | ssize_t ret = -EBADF; |
| 612 | 612 | |
| 613 | − if (f.file) { | |
| 614 | − loff_t pos, *ppos = file_ppos(f.file); | |
| 613 | + if (fd_file(f)) { | |
| 614 | + loff_t pos, *ppos = file_ppos(fd_file(f)); | |
| 615 | 615 | if (ppos) { |
| 616 | 616 | pos = *ppos; |
| 617 | 617 | ppos = &pos; |
| 618 | 618 | } |
| 619 | − ret = vfs_read(f.file, buf, count, ppos); | |
| 619 | + ret = vfs_read(fd_file(f), buf, count, ppos); | |
| 620 | 620 | if (ret >= 0 && ppos) |
| 621 | − f.file->f_pos = pos; | |
| 621 | + fd_file(f)->f_pos = pos; | |
| 622 | 622 | fdput_pos(f); |
| 623 | 623 | } |
| 624 | 624 | return ret; |
| @@ -634,15 +634,15 @@ ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count) · 9 unmodified lines | ||
| 634 | 634 | struct fd f = fdget_pos(fd); |
| 635 | 635 | ssize_t ret = -EBADF; |
| 636 | 636 | |
| 637 | − if (f.file) { | |
| 638 | − loff_t pos, *ppos = file_ppos(f.file); | |
| 637 | + if (fd_file(f)) { | |
| 638 | + loff_t pos, *ppos = file_ppos(fd_file(f)); | |
| 639 | 639 | if (ppos) { |
| 640 | 640 | pos = *ppos; |
| 641 | 641 | ppos = &pos; |
| 642 | 642 | } |
| 643 | − ret = vfs_write(f.file, buf, count, ppos); | |
| 643 | + ret = vfs_write(fd_file(f), buf, count, ppos); | |
| 644 | 644 | if (ret >= 0 && ppos) |
| 645 | − f.file->f_pos = pos; | |
| 645 | + fd_file(f)->f_pos = pos; | |
| 646 | 646 | fdput_pos(f); |
| 647 | 647 | } |
| 648 | 648 | |
| @@ -665,10 +665,10 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count, · 16 unmodified lines | ||
| 665 | 665 | return -EINVAL; |
| 666 | 666 | |
| 667 | 667 | f = fdget(fd); |
| 668 | − if (f.file) { | |
| 668 | + if (fd_file(f)) { | |
| 669 | 669 | ret = -ESPIPE; |
| 670 | − if (f.file->f_mode & FMODE_PREAD) | |
| 671 | − ret = vfs_read(f.file, buf, count, &pos); | |
| 670 | + if (fd_file(f)->f_mode & FMODE_PREAD) | |
| 671 | + ret = vfs_read(fd_file(f), buf, count, &pos); | |
| 672 | 672 | fdput(f); |
| 673 | 673 | } |
| 674 | 674 | |
| @@ -699,10 +699,10 @@ ssize_t ksys_pwrite64(unsigned int fd, const char __user *buf, · 24 unmodified lines | ||
| 699 | 699 | return -EINVAL; |
| 700 | 700 | |
| 701 | 701 | f = fdget(fd); |
| 702 | − if (f.file) { | |
| 702 | + if (fd_file(f)) { | |
| 703 | 703 | ret = -ESPIPE; |
| 704 | − if (f.file->f_mode & FMODE_PWRITE) | |
| 705 | − ret = vfs_write(f.file, buf, count, &pos); | |
| 704 | + if (fd_file(f)->f_mode & FMODE_PWRITE) | |
| 705 | + ret = vfs_write(fd_file(f), buf, count, &pos); | |
| 706 | 706 | fdput(f); |
| 707 | 707 | } |
| 708 | 708 | |
| @@ -985,15 +985,15 @@ static ssize_t do_readv(unsigned long fd, const struct iovec __user *vec, · 276 unmodified lines | ||
| 985 | 985 | struct fd f = fdget_pos(fd); |
| 986 | 986 | ssize_t ret = -EBADF; |
| 987 | 987 | |
| 988 | − if (f.file) { | |
| 989 | − loff_t pos, *ppos = file_ppos(f.file); | |
| 988 | + if (fd_file(f)) { | |
| 989 | + loff_t pos, *ppos = file_ppos(fd_file(f)); | |
| 990 | 990 | if (ppos) { |
| 991 | 991 | pos = *ppos; |
| 992 | 992 | ppos = &pos; |
| 993 | 993 | } |
| 994 | − ret = vfs_readv(f.file, vec, vlen, ppos, flags); | |
| 994 | + ret = vfs_readv(fd_file(f), vec, vlen, ppos, flags); | |
| 995 | 995 | if (ret >= 0 && ppos) |
| 996 | − f.file->f_pos = pos; | |
| 996 | + fd_file(f)->f_pos = pos; | |
| 997 | 997 | fdput_pos(f); |
| 998 | 998 | } |
| 999 | 999 | |
| @@ -1009,15 +1009,15 @@ static ssize_t do_writev(unsigned long fd, const struct iovec __user *vec, · 9 unmodified lines | ||
| 1009 | 1009 | struct fd f = fdget_pos(fd); |
| 1010 | 1010 | ssize_t ret = -EBADF; |
| 1011 | 1011 | |
| 1012 | − if (f.file) { | |
| 1013 | − loff_t pos, *ppos = file_ppos(f.file); | |
| 1012 | + if (fd_file(f)) { | |
| 1013 | + loff_t pos, *ppos = file_ppos(fd_file(f)); | |
| 1014 | 1014 | if (ppos) { |
| 1015 | 1015 | pos = *ppos; |
| 1016 | 1016 | ppos = &pos; |
| 1017 | 1017 | } |
| 1018 | − ret = vfs_writev(f.file, vec, vlen, ppos, flags); | |
| 1018 | + ret = vfs_writev(fd_file(f), vec, vlen, ppos, flags); | |
| 1019 | 1019 | if (ret >= 0 && ppos) |
| 1020 | − f.file->f_pos = pos; | |
| 1020 | + fd_file(f)->f_pos = pos; | |
| 1021 | 1021 | fdput_pos(f); |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| @@ -1043,10 +1043,10 @@ static ssize_t do_preadv(unsigned long fd, const struct iovec __user *vec, · 19 unmodified lines | ||
| 1043 | 1043 | return -EINVAL; |
| 1044 | 1044 | |
| 1045 | 1045 | f = fdget(fd); |
| 1046 | − if (f.file) { | |
| 1046 | + if (fd_file(f)) { | |
| 1047 | 1047 | ret = -ESPIPE; |
| 1048 | − if (f.file->f_mode & FMODE_PREAD) | |
| 1049 | − ret = vfs_readv(f.file, vec, vlen, &pos, flags); | |
| 1048 | + if (fd_file(f)->f_mode & FMODE_PREAD) | |
| 1049 | + ret = vfs_readv(fd_file(f), vec, vlen, &pos, flags); | |
| 1050 | 1050 | fdput(f); |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| @@ -1066,10 +1066,10 @@ static ssize_t do_pwritev(unsigned long fd, const struct iovec __user *vec, · 13 unmodified lines | ||
| 1066 | 1066 | return -EINVAL; |
| 1067 | 1067 | |
| 1068 | 1068 | f = fdget(fd); |
| 1069 | − if (f.file) { | |
| 1069 | + if (fd_file(f)) { | |
| 1070 | 1070 | ret = -ESPIPE; |
| 1071 | − if (f.file->f_mode & FMODE_PWRITE) | |
| 1072 | − ret = vfs_writev(f.file, vec, vlen, &pos, flags); | |
| 1071 | + if (fd_file(f)->f_mode & FMODE_PWRITE) | |
| 1072 | + ret = vfs_writev(fd_file(f), vec, vlen, &pos, flags); | |
| 1073 | 1073 | fdput(f); |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| @@ -1235,19 +1235,19 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 159 unmodified lines | ||
| 1235 | 1235 | */ |
| 1236 | 1236 | retval = -EBADF; |
| 1237 | 1237 | in = fdget(in_fd); |
| 1238 | − if (!in.file) | |
| 1238 | + if (!fd_file(in)) | |
| 1239 | 1239 | goto out; |
| 1240 | − if (!(in.file->f_mode & FMODE_READ)) | |
| 1240 | + if (!(fd_file(in)->f_mode & FMODE_READ)) | |
| 1241 | 1241 | goto fput_in; |
| 1242 | 1242 | retval = -ESPIPE; |
| 1243 | 1243 | if (!ppos) { |
| 1244 | − pos = in.file->f_pos; | |
| 1244 | + pos = fd_file(in)->f_pos; | |
| 1245 | 1245 | } else { |
| 1246 | 1246 | pos = *ppos; |
| 1247 | − if (!(in.file->f_mode & FMODE_PREAD)) | |
| 1247 | + if (!(fd_file(in)->f_mode & FMODE_PREAD)) | |
| 1248 | 1248 | goto fput_in; |
| 1249 | 1249 | } |
| 1250 | − retval = rw_verify_area(READ, in.file, &pos, count); | |
| 1250 | + retval = rw_verify_area(READ, fd_file(in), &pos, count); | |
| 1251 | 1251 | if (retval < 0) |
| 1252 | 1252 | goto fput_in; |
| 1253 | 1253 | if (count > MAX_RW_COUNT) |
| @@ -1258,13 +1258,13 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 4 unmodified lines | ||
| 1258 | 1258 | */ |
| 1259 | 1259 | retval = -EBADF; |
| 1260 | 1260 | out = fdget(out_fd); |
| 1261 | − if (!out.file) | |
| 1261 | + if (!fd_file(out)) | |
| 1262 | 1262 | goto fput_in; |
| 1263 | − if (!(out.file->f_mode & FMODE_WRITE)) | |
| 1263 | + if (!(fd_file(out)->f_mode & FMODE_WRITE)) | |
| 1264 | 1264 | goto fput_out; |
| 1265 | − in_inode = file_inode(in.file); | |
| 1266 | − out_inode = file_inode(out.file); | |
| 1267 | − out_pos = out.file->f_pos; | |
| 1265 | + in_inode = file_inode(fd_file(in)); | |
| 1266 | + out_inode = file_inode(fd_file(out)); | |
| 1267 | + out_pos = fd_file(out)->f_pos; | |
| 1268 | 1268 | |
| 1269 | 1269 | if (!max) |
| 1270 | 1270 | max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes); |
| @@ -1284,33 +1284,33 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 13 unmodified lines | ||
| 1284 | 1284 | * and the application is arguably buggy if it doesn't expect |
| 1285 | 1285 | * EAGAIN on a non-blocking file descriptor. |
| 1286 | 1286 | */ |
| 1287 | − if (in.file->f_flags & O_NONBLOCK) | |
| 1287 | + if (fd_file(in)->f_flags & O_NONBLOCK) | |
| 1288 | 1288 | fl = SPLICE_F_NONBLOCK; |
| 1289 | 1289 | #endif |
| 1290 | − opipe = get_pipe_info(out.file, true); | |
| 1290 | + opipe = get_pipe_info(fd_file(out), true); | |
| 1291 | 1291 | if (!opipe) { |
| 1292 | − retval = rw_verify_area(WRITE, out.file, &out_pos, count); | |
| 1292 | + retval = rw_verify_area(WRITE, fd_file(out), &out_pos, count); | |
| 1293 | 1293 | if (retval < 0) |
| 1294 | 1294 | goto fput_out; |
| 1295 | − retval = do_splice_direct(in.file, &pos, out.file, &out_pos, | |
| 1295 | + retval = do_splice_direct(fd_file(in), &pos, fd_file(out), &out_pos, | |
| 1296 | 1296 | count, fl); |
| 1297 | 1297 | } else { |
| 1298 | − if (out.file->f_flags & O_NONBLOCK) | |
| 1298 | + if (fd_file(out)->f_flags & O_NONBLOCK) | |
| 1299 | 1299 | fl |= SPLICE_F_NONBLOCK; |
| 1300 | 1300 | |
| 1301 | − retval = splice_file_to_pipe(in.file, opipe, &pos, count, fl); | |
| 1301 | + retval = splice_file_to_pipe(fd_file(in), opipe, &pos, count, fl); | |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | if (retval > 0) { |
| 1305 | 1305 | add_rchar(current, retval); |
| 1306 | 1306 | add_wchar(current, retval); |
| 1307 | − fsnotify_access(in.file); | |
| 1308 | − fsnotify_modify(out.file); | |
| 1309 | − out.file->f_pos = out_pos; | |
| 1307 | + fsnotify_access(fd_file(in)); | |
| 1308 | + fsnotify_modify(fd_file(out)); | |
| 1309 | + fd_file(out)->f_pos = out_pos; | |
| 1310 | 1310 | if (ppos) |
| 1311 | 1311 | *ppos = pos; |
| 1312 | 1312 | else |
| 1313 | − in.file->f_pos = pos; | |
| 1313 | + fd_file(in)->f_pos = pos; | |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | inc_syscr(current); |
| @@ -1583,11 +1583,11 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 266 unmodified lines | ||
| 1583 | 1583 | ssize_t ret = -EBADF; |
| 1584 | 1584 | |
| 1585 | 1585 | f_in = fdget(fd_in); |
| 1586 | − if (!f_in.file) | |
| 1586 | + if (!fd_file(f_in)) | |
| 1587 | 1587 | goto out2; |
| 1588 | 1588 | |
| 1589 | 1589 | f_out = fdget(fd_out); |
| 1590 | − if (!f_out.file) | |
| 1590 | + if (!fd_file(f_out)) | |
| 1591 | 1591 | goto out1; |
| 1592 | 1592 | |
| 1593 | 1593 | ret = -EFAULT; |
| @@ -1595,21 +1595,21 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 1 unmodified line | ||
| 1595 | 1595 | if (copy_from_user(&pos_in, off_in, sizeof(loff_t))) |
| 1596 | 1596 | goto out; |
| 1597 | 1597 | } else { |
| 1598 | − pos_in = f_in.file->f_pos; | |
| 1598 | + pos_in = fd_file(f_in)->f_pos; | |
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | if (off_out) { |
| 1602 | 1602 | if (copy_from_user(&pos_out, off_out, sizeof(loff_t))) |
| 1603 | 1603 | goto out; |
| 1604 | 1604 | } else { |
| 1605 | − pos_out = f_out.file->f_pos; | |
| 1605 | + pos_out = fd_file(f_out)->f_pos; | |
| 1606 | 1606 | } |
| 1607 | 1607 | |
| 1608 | 1608 | ret = -EINVAL; |
| 1609 | 1609 | if (flags != 0) |
| 1610 | 1610 | goto out; |
| 1611 | 1611 | |
| 1612 | − ret = vfs_copy_file_range(f_in.file, pos_in, f_out.file, pos_out, len, | |
| 1612 | + ret = vfs_copy_file_range(fd_file(f_in), pos_in, fd_file(f_out), pos_out, len, | |
| 1613 | 1613 | flags); |
| 1614 | 1614 | if (ret > 0) { |
| 1615 | 1615 | pos_in += ret; |
| @@ -1619,14 +1619,14 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 3 unmodified lines | ||
| 1619 | 1619 | if (copy_to_user(off_in, &pos_in, sizeof(loff_t))) |
| 1620 | 1620 | ret = -EFAULT; |
| 1621 | 1621 | } else { |
| 1622 | − f_in.file->f_pos = pos_in; | |
| 1622 | + fd_file(f_in)->f_pos = pos_in; | |
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | 1625 | if (off_out) { |
| 1626 | 1626 | if (copy_to_user(off_out, &pos_out, sizeof(loff_t))) |
| 1627 | 1627 | ret = -EFAULT; |
| 1628 | 1628 | } else { |
| 1629 | − f_out.file->f_pos = pos_out; | |
| 1629 | + fd_file(f_out)->f_pos = pos_out; | |
| 1630 | 1630 | } |
| 1631 | 1631 | } |
| 1632 | 1632 | |
| @@ -225,10 +225,10 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, · 224 unmodified lines | ||
| 225 | 225 | .dirent = dirent |
| 226 | 226 | }; |
| 227 | 227 | |
| 228 | − if (!f.file) | |
| 228 | + if (!fd_file(f)) | |
| 229 | 229 | return -EBADF; |
| 230 | 230 | |
| 231 | − error = iterate_dir(f.file, &buf.ctx); | |
| 231 | + error = iterate_dir(fd_file(f), &buf.ctx); | |
| 232 | 232 | if (buf.result) |
| 233 | 233 | error = buf.result; |
| 234 | 234 | |
| @@ -318,10 +318,10 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, · 83 unmodified lines | ||
| 318 | 318 | int error; |
| 319 | 319 | |
| 320 | 320 | f = fdget_pos(fd); |
| 321 | − if (!f.file) | |
| 321 | + if (!fd_file(f)) | |
| 322 | 322 | return -EBADF; |
| 323 | 323 | |
| 324 | − error = iterate_dir(f.file, &buf.ctx); | |
| 324 | + error = iterate_dir(fd_file(f), &buf.ctx); | |
| 325 | 325 | if (error >= 0) |
| 326 | 326 | error = buf.error; |
| 327 | 327 | if (buf.prev_reclen) { |
| @@ -401,10 +401,10 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, · 73 unmodified lines | ||
| 401 | 401 | int error; |
| 402 | 402 | |
| 403 | 403 | f = fdget_pos(fd); |
| 404 | − if (!f.file) | |
| 404 | + if (!fd_file(f)) | |
| 405 | 405 | return -EBADF; |
| 406 | 406 | |
| 407 | − error = iterate_dir(f.file, &buf.ctx); | |
| 407 | + error = iterate_dir(fd_file(f), &buf.ctx); | |
| 408 | 408 | if (error >= 0) |
| 409 | 409 | error = buf.error; |
| 410 | 410 | if (buf.prev_reclen) { |
| @@ -483,10 +483,10 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd, · 72 unmodified lines | ||
| 483 | 483 | .dirent = dirent |
| 484 | 484 | }; |
| 485 | 485 | |
| 486 | − if (!f.file) | |
| 486 | + if (!fd_file(f)) | |
| 487 | 487 | return -EBADF; |
| 488 | 488 | |
| 489 | − error = iterate_dir(f.file, &buf.ctx); | |
| 489 | + error = iterate_dir(fd_file(f), &buf.ctx); | |
| 490 | 490 | if (buf.result) |
| 491 | 491 | error = buf.result; |
| 492 | 492 | |
| @@ -569,10 +569,10 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd, · 76 unmodified lines | ||
| 569 | 569 | int error; |
| 570 | 570 | |
| 571 | 571 | f = fdget_pos(fd); |
| 572 | − if (!f.file) | |
| 572 | + if (!fd_file(f)) | |
| 573 | 573 | return -EBADF; |
| 574 | 574 | |
| 575 | − error = iterate_dir(f.file, &buf.ctx); | |
| 575 | + error = iterate_dir(fd_file(f), &buf.ctx); | |
| 576 | 576 | if (error >= 0) |
| 577 | 577 | error = buf.error; |
| 578 | 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 | 538 | for (i = 0, info = same->info; i < count; i++, info++) { |
| 539 | 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 | 542 | if (!dst_file) { |
| 543 | 543 | info->status = -EBADF; |
| @@ -532,10 +532,10 @@ static noinline_for_stack int do_select(int n, fd_set_bits *fds, struct timespec · 531 unmodified lines | ||
| 532 | 532 | continue; |
| 533 | 533 | mask = EPOLLNVAL; |
| 534 | 534 | f = fdget(i); |
| 535 | − if (f.file) { | |
| 535 | + if (fd_file(f)) { | |
| 536 | 536 | wait_key_set(wait, in, out, bit, |
| 537 | 537 | busy_flag); |
| 538 | − mask = vfs_poll(f.file, wait); | |
| 538 | + mask = vfs_poll(fd_file(f), wait); | |
| 539 | 539 | |
| 540 | 540 | fdput(f); |
| 541 | 541 | } |
| @@ -864,13 +864,13 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, · 322 unmodified lines | ||
| 864 | 864 | goto out; |
| 865 | 865 | mask = EPOLLNVAL; |
| 866 | 866 | f = fdget(fd); |
| 867 | − if (!f.file) | |
| 867 | + if (!fd_file(f)) | |
| 868 | 868 | goto out; |
| 869 | 869 | |
| 870 | 870 | /* userland u16 ->events contains POLL... bitmap */ |
| 871 | 871 | filter = demangle_poll(pollfd->events) | EPOLLERR | EPOLLHUP; |
| 872 | 872 | pwait->_key = filter | busy_flag; |
| 873 | − mask = vfs_poll(f.file, pwait); | |
| 873 | + mask = vfs_poll(fd_file(f), pwait); | |
| 874 | 874 | if (mask & busy_flag) |
| 875 | 875 | *can_busy_poll = true; |
| 876 | 876 | 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 | 289 | fd_install(ufd, file); |
| 290 | 290 | } else { |
| 291 | 291 | struct fd f = fdget(ufd); |
| 292 | − if (!f.file) | |
| 292 | + if (!fd_file(f)) | |
| 293 | 293 | return -EBADF; |
| 294 | − ctx = f.file->private_data; | |
| 295 | − if (f.file->f_op != &signalfd_fops) { | |
| 294 | + ctx = fd_file(f)->private_data; | |
| 295 | + if (fd_file(f)->f_op != &signalfd_fops) { | |
| 296 | 296 | fdput(f); |
| 297 | 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 | 92 | src_file = fdget(srcfd); |
| 93 | − if (!src_file.file) { | |
| 93 | + if (!fd_file(src_file)) { | |
| 94 | 94 | rc = -EBADF; |
| 95 | 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 | 99 | rc = -EBADF; |
| 100 | 100 | cifs_dbg(VFS, "src file seems to be from a different filesystem type\n"); |
| 101 | 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 | 105 | rc = -EINVAL; |
| 106 | 106 | if (S_ISDIR(src_inode->i_mode)) |
| 107 | 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 | 110 | src_inode->i_size, 0); |
| 111 | 111 | if (rc > 0) |
| 112 | 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 | 1567 | static int vmsplice_type(struct fd f, int *type) |
| 1568 | 1568 | { |
| 1569 | − if (!f.file) | |
| 1569 | + if (!fd_file(f)) | |
| 1570 | 1570 | return -EBADF; |
| 1571 | − if (f.file->f_mode & FMODE_WRITE) { | |
| 1571 | + if (fd_file(f)->f_mode & FMODE_WRITE) { | |
| 1572 | 1572 | *type = ITER_SOURCE; |
| 1573 | − } else if (f.file->f_mode & FMODE_READ) { | |
| 1573 | + } else if (fd_file(f)->f_mode & FMODE_READ) { | |
| 1574 | 1574 | *type = ITER_DEST; |
| 1575 | 1575 | } else { |
| 1576 | 1576 | fdput(f); |
| @@ -1621,9 +1621,9 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov, · 44 unmodified lines | ||
| 1621 | 1621 | if (!iov_iter_count(&iter)) |
| 1622 | 1622 | error = 0; |
| 1623 | 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 | 1625 | else |
| 1626 | − error = vmsplice_to_user(f.file, &iter, flags); | |
| 1626 | + error = vmsplice_to_user(fd_file(f), &iter, flags); | |
| 1627 | 1627 | |
| 1628 | 1628 | kfree(iov); |
| 1629 | 1629 | out_fdput: |
| @@ -1646,10 +1646,10 @@ SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in, · 16 unmodified lines | ||
| 1646 | 1646 | |
| 1647 | 1647 | error = -EBADF; |
| 1648 | 1648 | in = fdget(fd_in); |
| 1649 | − if (in.file) { | |
| 1649 | + if (fd_file(in)) { | |
| 1650 | 1650 | out = fdget(fd_out); |
| 1651 | − if (out.file) { | |
| 1652 | − error = __do_splice(in.file, off_in, out.file, off_out, | |
| 1651 | + if (fd_file(out)) { | |
| 1652 | + error = __do_splice(fd_file(in), off_in, fd_file(out), off_out, | |
| 1653 | 1653 | len, flags); |
| 1654 | 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 | 2017 | error = -EBADF; |
| 2018 | 2018 | in = fdget(fdin); |
| 2019 | − if (in.file) { | |
| 2019 | + if (fd_file(in)) { | |
| 2020 | 2020 | out = fdget(fdout); |
| 2021 | − if (out.file) { | |
| 2022 | − error = do_tee(in.file, out.file, len, flags); | |
| 2021 | + if (fd_file(out)) { | |
| 2022 | + error = do_tee(fd_file(in), fd_file(out), len, flags); | |
| 2023 | 2023 | fdput(out); |
| 2024 | 2024 | } |
| 2025 | 2025 | fdput(in); |
| @@ -224,9 +224,9 @@ int vfs_fstat(int fd, struct kstat *stat) · 223 unmodified lines | ||
| 224 | 224 | int error; |
| 225 | 225 | |
| 226 | 226 | f = fdget_raw(fd); |
| 227 | − if (!f.file) | |
| 227 | + if (!fd_file(f)) | |
| 228 | 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 | 230 | fdput(f); |
| 231 | 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 | 277 | u32 request_mask) |
| 278 | 278 | { |
| 279 | 279 | CLASS(fd_raw, f)(fd); |
| 280 | − if (!f.file) | |
| 280 | + if (!fd_file(f)) | |
| 281 | 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 | 117 | struct fd f = fdget_raw(fd); |
| 118 | 118 | int error = -EBADF; |
| 119 | − if (f.file) { | |
| 120 | − error = vfs_statfs(&f.file->f_path, st); | |
| 119 | + if (fd_file(f)) { | |
| 120 | + error = vfs_statfs(&fd_file(f)->f_path, st); | |
| 121 | 121 | fdput(f); |
| 122 | 122 | } |
| 123 | 123 | return error; |
| @@ -152,15 +152,15 @@ SYSCALL_DEFINE1(syncfs, int, fd) · 151 unmodified lines | ||
| 152 | 152 | struct super_block *sb; |
| 153 | 153 | int ret, ret2; |
| 154 | 154 | |
| 155 | − if (!f.file) | |
| 155 | + if (!fd_file(f)) | |
| 156 | 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 | 159 | down_read(&sb->s_umount); |
| 160 | 160 | ret = sync_filesystem(sb); |
| 161 | 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 | 165 | fdput(f); |
| 166 | 166 | return ret ? ret : ret2; |
| @@ -208,8 +208,8 @@ static int do_fsync(unsigned int fd, int datasync) · 41 unmodified lines | ||
| 208 | 208 | struct fd f = fdget(fd); |
| 209 | 209 | int ret = -EBADF; |
| 210 | 210 | |
| 211 | − if (f.file) { | |
| 212 | − ret = vfs_fsync(f.file, datasync); | |
| 211 | + if (fd_file(f)) { | |
| 212 | + ret = vfs_fsync(fd_file(f), datasync); | |
| 213 | 213 | fdput(f); |
| 214 | 214 | } |
| 215 | 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 | 361 | ret = -EBADF; |
| 362 | 362 | f = fdget(fd); |
| 363 | − if (f.file) | |
| 364 | − ret = sync_file_range(f.file, offset, nbytes, flags); | |
| 363 | + if (fd_file(f)) | |
| 364 | + ret = sync_file_range(fd_file(f), offset, nbytes, flags); | |
| 365 | 365 | |
| 366 | 366 | fdput(f); |
| 367 | 367 | return ret; |
| @@ -397,9 +397,9 @@ static const struct file_operations timerfd_fops = { · 396 unmodified lines | ||
| 397 | 397 | static int timerfd_fget(int fd, struct fd *p) |
| 398 | 398 | { |
| 399 | 399 | struct fd f = fdget(fd); |
| 400 | − if (!f.file) | |
| 400 | + if (!fd_file(f)) | |
| 401 | 401 | return -EBADF; |
| 402 | − if (f.file->f_op != &timerfd_fops) { | |
| 402 | + if (fd_file(f)->f_op != &timerfd_fops) { | |
| 403 | 403 | fdput(f); |
| 404 | 404 | return -EINVAL; |
| 405 | 405 | } |
| @@ -482,7 +482,7 @@ static int do_timerfd_settime(int ufd, int flags, · 76 unmodified lines | ||
| 482 | 482 | ret = timerfd_fget(ufd, &f); |
| 483 | 483 | if (ret) |
| 484 | 484 | return ret; |
| 485 | − ctx = f.file->private_data; | |
| 485 | + ctx = fd_file(f)->private_data; | |
| 486 | 486 | |
| 487 | 487 | if (isalarm(ctx) && !capable(CAP_WAKE_ALARM)) { |
| 488 | 488 | fdput(f); |
| @@ -546,7 +546,7 @@ static int do_timerfd_gettime(int ufd, struct itimerspec64 *t) · 57 unmodified lines | ||
| 546 | 546 | int ret = timerfd_fget(ufd, &f); |
| 547 | 547 | if (ret) |
| 548 | 548 | return ret; |
| 549 | − ctx = f.file->private_data; | |
| 549 | + ctx = fd_file(f)->private_data; | |
| 550 | 550 | |
| 551 | 551 | spin_lock_irq(&ctx->wqh.lock); |
| 552 | 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 | 115 | return -EINVAL; |
| 116 | 116 | |
| 117 | 117 | f = fdget(fd); |
| 118 | − if (!f.file) | |
| 118 | + if (!fd_file(f)) | |
| 119 | 119 | return -EBADF; |
| 120 | − error = vfs_utimes(&f.file->f_path, times); | |
| 120 | + error = vfs_utimes(&fd_file(f)->f_path, times); | |
| 121 | 121 | fdput(f); |
| 122 | 122 | return error; |
| 123 | 123 | } |
| @@ -697,19 +697,19 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, · 696 unmodified lines | ||
| 697 | 697 | int error; |
| 698 | 698 | |
| 699 | 699 | CLASS(fd, f)(fd); |
| 700 | − if (!f.file) | |
| 700 | + if (!fd_file(f)) | |
| 701 | 701 | return -EBADF; |
| 702 | 702 | |
| 703 | − audit_file(f.file); | |
| 703 | + audit_file(fd_file(f)); | |
| 704 | 704 | error = setxattr_copy(name, &ctx); |
| 705 | 705 | if (error) |
| 706 | 706 | return error; |
| 707 | 707 | |
| 708 | − error = mnt_want_write_file(f.file); | |
| 708 | + error = mnt_want_write_file(fd_file(f)); | |
| 709 | 709 | if (!error) { |
| 710 | − error = do_setxattr(file_mnt_idmap(f.file), | |
| 711 | − f.file->f_path.dentry, &ctx); | |
| 712 | − mnt_drop_write_file(f.file); | |
| 710 | + error = do_setxattr(file_mnt_idmap(fd_file(f)), | |
| 711 | + fd_file(f)->f_path.dentry, &ctx); | |
| 712 | + mnt_drop_write_file(fd_file(f)); | |
| 713 | 713 | } |
| 714 | 714 | kvfree(ctx.kvalue); |
| 715 | 715 | return error; |
| @@ -812,10 +812,10 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, · 96 unmodified lines | ||
| 812 | 812 | struct fd f = fdget(fd); |
| 813 | 813 | ssize_t error = -EBADF; |
| 814 | 814 | |
| 815 | − if (!f.file) | |
| 815 | + if (!fd_file(f)) | |
| 816 | 816 | return error; |
| 817 | − audit_file(f.file); | |
| 818 | − error = getxattr(file_mnt_idmap(f.file), f.file->f_path.dentry, | |
| 817 | + audit_file(fd_file(f)); | |
| 818 | + error = getxattr(file_mnt_idmap(fd_file(f)), fd_file(f)->f_path.dentry, | |
| 819 | 819 | name, value, size); |
| 820 | 820 | fdput(f); |
| 821 | 821 | return error; |
| @@ -888,10 +888,10 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) · 66 unmodified lines | ||
| 888 | 888 | struct fd f = fdget(fd); |
| 889 | 889 | ssize_t error = -EBADF; |
| 890 | 890 | |
| 891 | − if (!f.file) | |
| 891 | + if (!fd_file(f)) | |
| 892 | 892 | return error; |
| 893 | − audit_file(f.file); | |
| 894 | − error = listxattr(f.file->f_path.dentry, list, size); | |
| 893 | + audit_file(fd_file(f)); | |
| 894 | + error = listxattr(fd_file(f)->f_path.dentry, list, size); | |
| 895 | 895 | fdput(f); |
| 896 | 896 | return error; |
| 897 | 897 | } |
| @@ -954,9 +954,9 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) · 56 unmodified lines | ||
| 954 | 954 | char kname[XATTR_NAME_MAX + 1]; |
| 955 | 955 | int error = -EBADF; |
| 956 | 956 | |
| 957 | − if (!f.file) | |
| 957 | + if (!fd_file(f)) | |
| 958 | 958 | return error; |
| 959 | − audit_file(f.file); | |
| 959 | + audit_file(fd_file(f)); | |
| 960 | 960 | |
| 961 | 961 | error = strncpy_from_user(kname, name, sizeof(kname)); |
| 962 | 962 | if (error == 0 || error == sizeof(kname)) |
| @@ -964,11 +964,11 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) · 1 unmodified line | ||
| 964 | 964 | if (error < 0) |
| 965 | 965 | return error; |
| 966 | 966 | |
| 967 | − error = mnt_want_write_file(f.file); | |
| 967 | + error = mnt_want_write_file(fd_file(f)); | |
| 968 | 968 | if (!error) { |
| 969 | − error = removexattr(file_mnt_idmap(f.file), | |
| 970 | − f.file->f_path.dentry, kname); | |
| 971 | − mnt_drop_write_file(f.file); | |
| 969 | + error = removexattr(file_mnt_idmap(fd_file(f)), | |
| 970 | + fd_file(f)->f_path.dentry, kname); | |
| 971 | + mnt_drop_write_file(fd_file(f)); | |
| 972 | 972 | } |
| 973 | 973 | fdput(f); |
| 974 | 974 | return error; |
| @@ -794,9 +794,9 @@ xfs_ioc_exchange_range( · 793 unmodified lines | ||
| 794 | 794 | fxr.flags = args.flags; |
| 795 | 795 | |
| 796 | 796 | file1 = fdget(args.file1_fd); |
| 797 | − if (!file1.file) | |
| 797 | + if (!fd_file(file1)) | |
| 798 | 798 | return -EBADF; |
| 799 | − fxr.file1 = file1.file; | |
| 799 | + fxr.file1 = fd_file(file1); | |
| 800 | 800 | |
| 801 | 801 | error = xfs_exchange_range(&fxr); |
| 802 | 802 | fdput(file1); |
| @@ -92,9 +92,9 @@ xfs_find_handle( · 91 unmodified lines | ||
| 92 | 92 | |
| 93 | 93 | if (cmd == XFS_IOC_FD_TO_HANDLE) { |
| 94 | 94 | f = fdget(hreq->fd); |
| 95 | − if (!f.file) | |
| 95 | + if (!fd_file(f)) | |
| 96 | 96 | return -EBADF; |
| 97 | − inode = file_inode(f.file); | |
| 97 | + inode = file_inode(fd_file(f)); | |
| 98 | 98 | } else { |
| 99 | 99 | error = user_path_at(AT_FDCWD, hreq->path, 0, &path); |
| 100 | 100 | if (error) |
| @@ -1005,33 +1005,33 @@ xfs_ioc_swapext( · 1004 unmodified lines | ||
| 1005 | 1005 | |
| 1006 | 1006 | /* Pull information for the target fd */ |
| 1007 | 1007 | f = fdget((int)sxp->sx_fdtarget); |
| 1008 | − if (!f.file) { | |
| 1008 | + if (!fd_file(f)) { | |
| 1009 | 1009 | error = -EINVAL; |
| 1010 | 1010 | goto out; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | − if (!(f.file->f_mode & FMODE_WRITE) || | |
| 1014 | − !(f.file->f_mode & FMODE_READ) || | |
| 1015 | − (f.file->f_flags & O_APPEND)) { | |
| 1013 | + if (!(fd_file(f)->f_mode & FMODE_WRITE) || | |
| 1014 | + !(fd_file(f)->f_mode & FMODE_READ) || | |
| 1015 | + (fd_file(f)->f_flags & O_APPEND)) { | |
| 1016 | 1016 | error = -EBADF; |
| 1017 | 1017 | goto out_put_file; |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | tmp = fdget((int)sxp->sx_fdtmp); |
| 1021 | − if (!tmp.file) { | |
| 1021 | + if (!fd_file(tmp)) { | |
| 1022 | 1022 | error = -EINVAL; |
| 1023 | 1023 | goto out_put_file; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | − if (!(tmp.file->f_mode & FMODE_WRITE) || | |
| 1027 | − !(tmp.file->f_mode & FMODE_READ) || | |
| 1028 | − (tmp.file->f_flags & O_APPEND)) { | |
| 1026 | + if (!(fd_file(tmp)->f_mode & FMODE_WRITE) || | |
| 1027 | + !(fd_file(tmp)->f_mode & FMODE_READ) || | |
| 1028 | + (fd_file(tmp)->f_flags & O_APPEND)) { | |
| 1029 | 1029 | error = -EBADF; |
| 1030 | 1030 | goto out_put_tmp_file; |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | − if (IS_SWAPFILE(file_inode(f.file)) || | |
| 1034 | − IS_SWAPFILE(file_inode(tmp.file))) { | |
| 1033 | + if (IS_SWAPFILE(file_inode(fd_file(f))) || | |
| 1034 | + IS_SWAPFILE(file_inode(fd_file(tmp)))) { | |
| 1035 | 1035 | error = -EINVAL; |
| 1036 | 1036 | goto out_put_tmp_file; |
| 1037 | 1037 | } |
| @@ -1041,14 +1041,14 @@ xfs_ioc_swapext( · 3 unmodified lines | ||
| 1041 | 1041 | * before we cast and access them as XFS structures as we have no |
| 1042 | 1042 | * control over what the user passes us here. |
| 1043 | 1043 | */ |
| 1044 | − if (f.file->f_op != &xfs_file_operations || | |
| 1045 | − tmp.file->f_op != &xfs_file_operations) { | |
| 1044 | + if (fd_file(f)->f_op != &xfs_file_operations || | |
| 1045 | + fd_file(tmp)->f_op != &xfs_file_operations) { | |
| 1046 | 1046 | error = -EINVAL; |
| 1047 | 1047 | goto out_put_tmp_file; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | − ip = XFS_I(file_inode(f.file)); | |
| 1051 | − tip = XFS_I(file_inode(tmp.file)); | |
| 1050 | + ip = XFS_I(file_inode(fd_file(f))); | |
| 1051 | + tip = XFS_I(file_inode(fd_file(tmp))); | |
| 1052 | 1052 | |
| 1053 | 1053 | if (ip->i_mount != tip->i_mount) { |
| 1054 | 1054 | error = -EINVAL; |
| @@ -98,7 +98,7 @@ const volatile void * __must_check_fn(const volatile void *val) · 97 unmodified lines | ||
| 98 | 98 | * DEFINE_CLASS(fdget, struct fd, fdput(_T), fdget(fd), int fd) |
| 99 | 99 | * |
| 100 | 100 | * CLASS(fdget, f)(fd); |
| 101 | − * if (!f.file) | |
| 101 | + * if (!fd_file(f)) | |
| 102 | 102 | * return -EBADF; |
| 103 | 103 | * |
| 104 | 104 | * // use 'f' without concern |
| @@ -42,10 +42,12 @@ struct fd { · 41 unmodified lines | ||
| 42 | 42 | #define FDPUT_FPUT 1 |
| 43 | 43 | #define FDPUT_POS_UNLOCK 2 |
| 44 | 44 | |
| 45 | +#define fd_file(f) ((f).file) | |
| 46 | + | |
| 45 | 47 | static inline void fdput(struct fd fd) |
| 46 | 48 | { |
| 47 | 49 | if (fd.flags & FDPUT_FPUT) |
| 48 | − fput(fd.file); | |
| 50 | + fput(fd_file(fd)); | |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | 53 | extern struct file *fget(unsigned int fd); |
| @@ -79,7 +81,7 @@ static inline struct fd fdget_pos(int fd) · 27 unmodified lines | ||
| 79 | 81 | static inline void fdput_pos(struct fd f) |
| 80 | 82 | { |
| 81 | 83 | if (f.flags & FDPUT_POS_UNLOCK) |
| 82 | − __f_unlock_pos(f.file); | |
| 84 | + __f_unlock_pos(fd_file(f)); | |
| 83 | 85 | fdput(f); |
| 84 | 86 | } |
| 85 | 87 | |
| @@ -108,14 +108,14 @@ static struct io_sq_data *io_attach_sq_data(struct io_uring_params *p) · 107 unmodified lines | ||
| 108 | 108 | struct fd f; |
| 109 | 109 | |
| 110 | 110 | f = fdget(p->wq_fd); |
| 111 | − if (!f.file) | |
| 111 | + if (!fd_file(f)) | |
| 112 | 112 | return ERR_PTR(-ENXIO); |
| 113 | − if (!io_is_uring_fops(f.file)) { | |
| 113 | + if (!io_is_uring_fops(fd_file(f))) { | |
| 114 | 114 | fdput(f); |
| 115 | 115 | return ERR_PTR(-EINVAL); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | − ctx_attach = f.file->private_data; | |
| 118 | + ctx_attach = fd_file(f)->private_data; | |
| 119 | 119 | sqd = ctx_attach->sq_data; |
| 120 | 120 | if (!sqd) { |
| 121 | 121 | fdput(f); |
| @@ -418,9 +418,9 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx, · 296 unmodified lines | ||
| 418 | 418 | struct fd f; |
| 419 | 419 | |
| 420 | 420 | f = fdget(p->wq_fd); |
| 421 | − if (!f.file) | |
| 421 | + if (!fd_file(f)) | |
| 422 | 422 | return -ENXIO; |
| 423 | − if (!io_is_uring_fops(f.file)) { | |
| 423 | + if (!io_is_uring_fops(fd_file(f))) { | |
| 424 | 424 | fdput(f); |
| 425 | 425 | return -EINVAL; |
| 426 | 426 | } |
| @@ -1085,20 +1085,20 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr, · 1084 unmodified lines | ||
| 1085 | 1085 | audit_mq_sendrecv(mqdes, msg_len, msg_prio, ts); |
| 1086 | 1086 | |
| 1087 | 1087 | f = fdget(mqdes); |
| 1088 | − if (unlikely(!f.file)) { | |
| 1088 | + if (unlikely(!fd_file(f))) { | |
| 1089 | 1089 | ret = -EBADF; |
| 1090 | 1090 | goto out; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | − inode = file_inode(f.file); | |
| 1094 | − if (unlikely(f.file->f_op != &mqueue_file_operations)) { | |
| 1093 | + inode = file_inode(fd_file(f)); | |
| 1094 | + if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) { | |
| 1095 | 1095 | ret = -EBADF; |
| 1096 | 1096 | goto out_fput; |
| 1097 | 1097 | } |
| 1098 | 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 | 1102 | ret = -EBADF; |
| 1103 | 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 | 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 | 1142 | ret = -EAGAIN; |
| 1143 | 1143 | } else { |
| 1144 | 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 | 1199 | audit_mq_sendrecv(mqdes, msg_len, 0, ts); |
| 1200 | 1200 | |
| 1201 | 1201 | f = fdget(mqdes); |
| 1202 | − if (unlikely(!f.file)) { | |
| 1202 | + if (unlikely(!fd_file(f))) { | |
| 1203 | 1203 | ret = -EBADF; |
| 1204 | 1204 | goto out; |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | − inode = file_inode(f.file); | |
| 1208 | − if (unlikely(f.file->f_op != &mqueue_file_operations)) { | |
| 1207 | + inode = file_inode(fd_file(f)); | |
| 1208 | + if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) { | |
| 1209 | 1209 | ret = -EBADF; |
| 1210 | 1210 | goto out_fput; |
| 1211 | 1211 | } |
| 1212 | 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 | 1216 | ret = -EBADF; |
| 1217 | 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 | 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 | 1246 | spin_unlock(&info->lock); |
| 1247 | 1247 | ret = -EAGAIN; |
| 1248 | 1248 | } else { |
| @@ -1356,11 +1356,11 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification) · 107 unmodified lines | ||
| 1356 | 1356 | /* and attach it to the socket */ |
| 1357 | 1357 | retry: |
| 1358 | 1358 | f = fdget(notification->sigev_signo); |
| 1359 | − if (!f.file) { | |
| 1359 | + if (!fd_file(f)) { | |
| 1360 | 1360 | ret = -EBADF; |
| 1361 | 1361 | goto out; |
| 1362 | 1362 | } |
| 1363 | − sock = netlink_getsockbyfilp(f.file); | |
| 1363 | + sock = netlink_getsockbyfilp(fd_file(f)); | |
| 1364 | 1364 | fdput(f); |
| 1365 | 1365 | if (IS_ERR(sock)) { |
| 1366 | 1366 | ret = PTR_ERR(sock); |
| @@ -1379,13 +1379,13 @@ retry: · 12 unmodified lines | ||
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | f = fdget(mqdes); |
| 1382 | − if (!f.file) { | |
| 1382 | + if (!fd_file(f)) { | |
| 1383 | 1383 | ret = -EBADF; |
| 1384 | 1384 | goto out; |
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | − inode = file_inode(f.file); | |
| 1388 | − if (unlikely(f.file->f_op != &mqueue_file_operations)) { | |
| 1387 | + inode = file_inode(fd_file(f)); | |
| 1388 | + if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) { | |
| 1389 | 1389 | ret = -EBADF; |
| 1390 | 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 | 1460 | return -EINVAL; |
| 1461 | 1461 | |
| 1462 | 1462 | f = fdget(mqdes); |
| 1463 | − if (!f.file) | |
| 1463 | + if (!fd_file(f)) | |
| 1464 | 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 | 1467 | fdput(f); |
| 1468 | 1468 | return -EBADF; |
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | − inode = file_inode(f.file); | |
| 1471 | + inode = file_inode(fd_file(f)); | |
| 1472 | 1472 | info = MQUEUE_I(inode); |
| 1473 | 1473 | |
| 1474 | 1474 | spin_lock(&info->lock); |
| 1475 | 1475 | |
| 1476 | 1476 | if (old) { |
| 1477 | 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 | 1480 | if (new) { |
| 1481 | 1481 | audit_mq_getsetattr(mqdes, new); |
| 1482 | − spin_lock(&f.file->f_lock); | |
| 1482 | + spin_lock(&fd_file(f)->f_lock); | |
| 1483 | 1483 | if (new->mq_flags & O_NONBLOCK) |
| 1484 | − f.file->f_flags |= O_NONBLOCK; | |
| 1484 | + fd_file(f)->f_flags |= O_NONBLOCK; | |
| 1485 | 1485 | else |
| 1486 | − f.file->f_flags &= ~O_NONBLOCK; | |
| 1487 | − spin_unlock(&f.file->f_lock); | |
| 1486 | + fd_file(f)->f_flags &= ~O_NONBLOCK; | |
| 1487 | + spin_unlock(&fd_file(f)->f_lock); | |
| 1488 | 1488 | |
| 1489 | 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 | 80 | struct bpf_local_storage_data *sdata; |
| 81 | 81 | struct fd f = fdget_raw(*(int *)key); |
| 82 | 82 | |
| 83 | − if (!f.file) | |
| 83 | + if (!fd_file(f)) | |
| 84 | 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 | 87 | fdput(f); |
| 88 | 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 | 94 | struct bpf_local_storage_data *sdata; |
| 95 | 95 | struct fd f = fdget_raw(*(int *)key); |
| 96 | 96 | |
| 97 | − if (!f.file) | |
| 97 | + if (!fd_file(f)) | |
| 98 | 98 | return -EBADF; |
| 99 | − if (!inode_storage_ptr(file_inode(f.file))) { | |
| 99 | + if (!inode_storage_ptr(file_inode(fd_file(f)))) { | |
| 100 | 100 | fdput(f); |
| 101 | 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 | 105 | (struct bpf_local_storage_map *)map, |
| 106 | 106 | value, map_flags, GFP_ATOMIC); |
| 107 | 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 | 126 | struct fd f = fdget_raw(*(int *)key); |
| 127 | 127 | int err; |
| 128 | 128 | |
| 129 | − if (!f.file) | |
| 129 | + if (!fd_file(f)) | |
| 130 | 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 | 133 | fdput(f); |
| 134 | 134 | return err; |
| 135 | 135 | } |
| @@ -7677,15 +7677,15 @@ struct btf *btf_get_by_fd(int fd) · 7676 unmodified lines | ||
| 7677 | 7677 | |
| 7678 | 7678 | f = fdget(fd); |
| 7679 | 7679 | |
| 7680 | − if (!f.file) | |
| 7680 | + if (!fd_file(f)) | |
| 7681 | 7681 | return ERR_PTR(-EBADF); |
| 7682 | 7682 | |
| 7683 | − if (f.file->f_op != &btf_fops) { | |
| 7683 | + if (fd_file(f)->f_op != &btf_fops) { | |
| 7684 | 7684 | fdput(f); |
| 7685 | 7685 | return ERR_PTR(-EINVAL); |
| 7686 | 7686 | } |
| 7687 | 7687 | |
| 7688 | − btf = f.file->private_data; | |
| 7688 | + btf = fd_file(f)->private_data; | |
| 7689 | 7689 | refcount_inc(&btf->refcnt); |
| 7690 | 7690 | fdput(f); |
| 7691 | 7691 | |
| @@ -829,7 +829,7 @@ static int bpf_map_release(struct inode *inode, struct file *filp) · 828 unmodified lines | ||
| 829 | 829 | |
| 830 | 830 | static fmode_t map_get_sys_perms(struct bpf_map *map, struct fd f) |
| 831 | 831 | { |
| 832 | − fmode_t mode = f.file->f_mode; | |
| 832 | + fmode_t mode = fd_file(f)->f_mode; | |
| 833 | 833 | |
| 834 | 834 | /* Our file permissions may have been overridden by global |
| 835 | 835 | * map permissions facing syscall side. |
| @@ -1423,14 +1423,14 @@ put_token: · 587 unmodified lines | ||
| 1423 | 1423 | */ |
| 1424 | 1424 | struct bpf_map *__bpf_map_get(struct fd f) |
| 1425 | 1425 | { |
| 1426 | − if (!f.file) | |
| 1426 | + if (!fd_file(f)) | |
| 1427 | 1427 | return ERR_PTR(-EBADF); |
| 1428 | − if (f.file->f_op != &bpf_map_fops) { | |
| 1428 | + if (fd_file(f)->f_op != &bpf_map_fops) { | |
| 1429 | 1429 | fdput(f); |
| 1430 | 1430 | return ERR_PTR(-EINVAL); |
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | − return f.file->private_data; | |
| 1433 | + return fd_file(f)->private_data; | |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | 1436 | void bpf_map_inc(struct bpf_map *map) |
| @@ -1651,7 +1651,7 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) · 214 unmodified lines | ||
| 1651 | 1651 | goto free_key; |
| 1652 | 1652 | } |
| 1653 | 1653 | |
| 1654 | − err = bpf_map_update_value(map, f.file, key, value, attr->flags); | |
| 1654 | + err = bpf_map_update_value(map, fd_file(f), key, value, attr->flags); | |
| 1655 | 1655 | if (!err) |
| 1656 | 1656 | maybe_wait_bpf_programs(map); |
| 1657 | 1657 | |
| @@ -2409,14 +2409,14 @@ int bpf_prog_new_fd(struct bpf_prog *prog) · 751 unmodified lines | ||
| 2409 | 2409 | |
| 2410 | 2410 | static struct bpf_prog *____bpf_prog_get(struct fd f) |
| 2411 | 2411 | { |
| 2412 | − if (!f.file) | |
| 2412 | + if (!fd_file(f)) | |
| 2413 | 2413 | return ERR_PTR(-EBADF); |
| 2414 | − if (f.file->f_op != &bpf_prog_fops) { | |
| 2414 | + if (fd_file(f)->f_op != &bpf_prog_fops) { | |
| 2415 | 2415 | fdput(f); |
| 2416 | 2416 | return ERR_PTR(-EINVAL); |
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | − return f.file->private_data; | |
| 2419 | + return fd_file(f)->private_data; | |
| 2420 | 2420 | } |
| 2421 | 2421 | |
| 2422 | 2422 | void bpf_prog_add(struct bpf_prog *prog, int i) |
| @@ -3259,14 +3259,14 @@ struct bpf_link *bpf_link_get_from_fd(u32 ufd) · 836 unmodified lines | ||
| 3259 | 3259 | struct fd f = fdget(ufd); |
| 3260 | 3260 | struct bpf_link *link; |
| 3261 | 3261 | |
| 3262 | − if (!f.file) | |
| 3262 | + if (!fd_file(f)) | |
| 3263 | 3263 | return ERR_PTR(-EBADF); |
| 3264 | − if (f.file->f_op != &bpf_link_fops && f.file->f_op != &bpf_link_fops_poll) { | |
| 3264 | + if (fd_file(f)->f_op != &bpf_link_fops && fd_file(f)->f_op != &bpf_link_fops_poll) { | |
| 3265 | 3265 | fdput(f); |
| 3266 | 3266 | return ERR_PTR(-EINVAL); |
| 3267 | 3267 | } |
| 3268 | 3268 | |
| 3269 | − link = f.file->private_data; | |
| 3269 | + link = fd_file(f)->private_data; | |
| 3270 | 3270 | bpf_link_inc(link); |
| 3271 | 3271 | fdput(f); |
| 3272 | 3272 | |
| @@ -4982,19 +4982,19 @@ static int bpf_obj_get_info_by_fd(const union bpf_attr *attr, · 1709 unmodified lines | ||
| 4982 | 4982 | return -EINVAL; |
| 4983 | 4983 | |
| 4984 | 4984 | f = fdget(ufd); |
| 4985 | − if (!f.file) | |
| 4985 | + if (!fd_file(f)) | |
| 4986 | 4986 | return -EBADFD; |
| 4987 | 4987 | |
| 4988 | − if (f.file->f_op == &bpf_prog_fops) | |
| 4989 | − err = bpf_prog_get_info_by_fd(f.file, f.file->private_data, attr, | |
| 4988 | + if (fd_file(f)->f_op == &bpf_prog_fops) | |
| 4989 | + err = bpf_prog_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr, | |
| 4990 | 4990 | uattr); |
| 4991 | − else if (f.file->f_op == &bpf_map_fops) | |
| 4992 | − err = bpf_map_get_info_by_fd(f.file, f.file->private_data, attr, | |
| 4991 | + else if (fd_file(f)->f_op == &bpf_map_fops) | |
| 4992 | + err = bpf_map_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr, | |
| 4993 | 4993 | uattr); |
| 4994 | − else if (f.file->f_op == &btf_fops) | |
| 4995 | − err = bpf_btf_get_info_by_fd(f.file, f.file->private_data, attr, uattr); | |
| 4996 | − else if (f.file->f_op == &bpf_link_fops || f.file->f_op == &bpf_link_fops_poll) | |
| 4997 | − err = bpf_link_get_info_by_fd(f.file, f.file->private_data, | |
| 4994 | + else if (fd_file(f)->f_op == &btf_fops) | |
| 4995 | + err = bpf_btf_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr, uattr); | |
| 4996 | + else if (fd_file(f)->f_op == &bpf_link_fops || fd_file(f)->f_op == &bpf_link_fops_poll) | |
| 4997 | + err = bpf_link_get_info_by_fd(fd_file(f), fd_file(f)->private_data, | |
| 4998 | 4998 | attr, uattr); |
| 4999 | 4999 | else |
| 5000 | 5000 | err = -EINVAL; |
| @@ -5215,7 +5215,7 @@ static int bpf_map_do_batch(const union bpf_attr *attr, · 214 unmodified lines | ||
| 5215 | 5215 | else if (cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH) |
| 5216 | 5216 | BPF_DO_BATCH(map->ops->map_lookup_and_delete_batch, map, attr, uattr); |
| 5217 | 5217 | else if (cmd == BPF_MAP_UPDATE_BATCH) |
| 5218 | − BPF_DO_BATCH(map->ops->map_update_batch, map, f.file, attr, uattr); | |
| 5218 | + BPF_DO_BATCH(map->ops->map_update_batch, map, fd_file(f), attr, uattr); | |
| 5219 | 5219 | else |
| 5220 | 5220 | BPF_DO_BATCH(map->ops->map_delete_batch, map, attr, uattr); |
| 5221 | 5221 | err_put: |
| @@ -122,10 +122,10 @@ int bpf_token_create(union bpf_attr *attr) · 121 unmodified lines | ||
| 122 | 122 | int err, fd; |
| 123 | 123 | |
| 124 | 124 | f = fdget(attr->token_create.bpffs_fd); |
| 125 | − if (!f.file) | |
| 125 | + if (!fd_file(f)) | |
| 126 | 126 | return -EBADF; |
| 127 | 127 | |
| 128 | − path = f.file->f_path; | |
| 128 | + path = fd_file(f)->f_path; | |
| 129 | 129 | path_get(&path); |
| 130 | 130 | fdput(f); |
| 131 | 131 | |
| @@ -235,14 +235,14 @@ struct bpf_token *bpf_token_get_from_fd(u32 ufd) · 103 unmodified lines | ||
| 235 | 235 | struct fd f = fdget(ufd); |
| 236 | 236 | struct bpf_token *token; |
| 237 | 237 | |
| 238 | − if (!f.file) | |
| 238 | + if (!fd_file(f)) | |
| 239 | 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 | 241 | fdput(f); |
| 242 | 242 | return ERR_PTR(-EINVAL); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | − token = f.file->private_data; | |
| 245 | + token = fd_file(f)->private_data; | |
| 246 | 246 | bpf_token_inc(token); |
| 247 | 247 | fdput(f); |
| 248 | 248 | |
| @@ -6901,10 +6901,10 @@ struct cgroup *cgroup_v1v2_get_from_fd(int fd) · 6900 unmodified lines | ||
| 6901 | 6901 | { |
| 6902 | 6902 | struct cgroup *cgrp; |
| 6903 | 6903 | struct fd f = fdget_raw(fd); |
| 6904 | − if (!f.file) | |
| 6904 | + if (!fd_file(f)) | |
| 6905 | 6905 | return ERR_PTR(-EBADF); |
| 6906 | 6906 | |
| 6907 | − cgrp = cgroup_v1v2_get_from_file(f.file); | |
| 6907 | + cgrp = cgroup_v1v2_get_from_file(fd_file(f)); | |
| 6908 | 6908 | fdput(f); |
| 6909 | 6909 | return cgrp; |
| 6910 | 6910 | } |
| @@ -933,10 +933,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event, · 932 unmodified lines | ||
| 933 | 933 | struct fd f = fdget(fd); |
| 934 | 934 | int ret = 0; |
| 935 | 935 | |
| 936 | − if (!f.file) | |
| 936 | + if (!fd_file(f)) | |
| 937 | 937 | return -EBADF; |
| 938 | 938 | |
| 939 | − css = css_tryget_online_from_dir(f.file->f_path.dentry, | |
| 939 | + css = css_tryget_online_from_dir(fd_file(f)->f_path.dentry, | |
| 940 | 940 | &perf_event_cgrp_subsys); |
| 941 | 941 | if (IS_ERR(css)) { |
| 942 | 942 | ret = PTR_ERR(css); |
| @@ -5898,10 +5898,10 @@ static const struct file_operations perf_fops; · 4955 unmodified lines | ||
| 5898 | 5898 | static inline int perf_fget_light(int fd, struct fd *p) |
| 5899 | 5899 | { |
| 5900 | 5900 | struct fd f = fdget(fd); |
| 5901 | − if (!f.file) | |
| 5901 | + if (!fd_file(f)) | |
| 5902 | 5902 | return -EBADF; |
| 5903 | 5903 | |
| 5904 | − if (f.file->f_op != &perf_fops) { | |
| 5904 | + if (fd_file(f)->f_op != &perf_fops) { | |
| 5905 | 5905 | fdput(f); |
| 5906 | 5906 | return -EBADF; |
| 5907 | 5907 | } |
| @@ -5961,7 +5961,7 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon · 53 unmodified lines | ||
| 5961 | 5961 | ret = perf_fget_light(arg, &output); |
| 5962 | 5962 | if (ret) |
| 5963 | 5963 | return ret; |
| 5964 | − output_event = output.file->private_data; | |
| 5964 | + output_event = fd_file(output)->private_data; | |
| 5965 | 5965 | ret = perf_event_set_output(event, output_event); |
| 5966 | 5966 | fdput(output); |
| 5967 | 5967 | } else { |
| @@ -12549,7 +12549,7 @@ SYSCALL_DEFINE5(perf_event_open, · 6581 unmodified lines | ||
| 12549 | 12549 | err = perf_fget_light(group_fd, &group); |
| 12550 | 12550 | if (err) |
| 12551 | 12551 | goto err_fd; |
| 12552 | − group_leader = group.file->private_data; | |
| 12552 | + group_leader = fd_file(group)->private_data; | |
| 12553 | 12553 | if (flags & PERF_FLAG_FD_OUTPUT) |
| 12554 | 12554 | output_event = group_leader; |
| 12555 | 12555 | if (flags & PERF_FLAG_FD_NO_GROUP) |
| @@ -3211,7 +3211,7 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) · 3210 unmodified lines | ||
| 3211 | 3211 | return -EINVAL; |
| 3212 | 3212 | |
| 3213 | 3213 | f = fdget(fd); |
| 3214 | − err = idempotent_init_module(f.file, uargs, flags); | |
| 3214 | + err = idempotent_init_module(fd_file(f), uargs, flags); | |
| 3215 | 3215 | fdput(f); |
| 3216 | 3216 | return err; |
| 3217 | 3217 | } |
| @@ -550,15 +550,15 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) · 549 unmodified lines | ||
| 550 | 550 | struct nsset nsset = {}; |
| 551 | 551 | int err = 0; |
| 552 | 552 | |
| 553 | − if (!f.file) | |
| 553 | + if (!fd_file(f)) | |
| 554 | 554 | return -EBADF; |
| 555 | 555 | |
| 556 | − if (proc_ns_file(f.file)) { | |
| 557 | − ns = get_proc_ns(file_inode(f.file)); | |
| 556 | + if (proc_ns_file(fd_file(f))) { | |
| 557 | + ns = get_proc_ns(file_inode(fd_file(f))); | |
| 558 | 558 | if (flags && (ns->ops->type != flags)) |
| 559 | 559 | err = -EINVAL; |
| 560 | 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 | 562 | err = check_setns_flags(flags); |
| 563 | 563 | } else { |
| 564 | 564 | err = -EINVAL; |
| @@ -570,10 +570,10 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) · 5 unmodified lines | ||
| 570 | 570 | if (err) |
| 571 | 571 | goto out; |
| 572 | 572 | |
| 573 | − if (proc_ns_file(f.file)) | |
| 573 | + if (proc_ns_file(fd_file(f))) | |
| 574 | 574 | err = validate_ns(&nsset, ns); |
| 575 | 575 | else |
| 576 | − err = validate_nsset(&nsset, pidfd_pid(f.file)); | |
| 576 | + err = validate_nsset(&nsset, pidfd_pid(fd_file(f))); | |
| 577 | 577 | if (!err) { |
| 578 | 578 | commit_nsset(&nsset); |
| 579 | 579 | perf_event_namespaces(current); |
| @@ -540,13 +540,13 @@ struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) · 539 unmodified lines | ||
| 540 | 540 | struct pid *pid; |
| 541 | 541 | |
| 542 | 542 | f = fdget(fd); |
| 543 | − if (!f.file) | |
| 543 | + if (!fd_file(f)) | |
| 544 | 544 | return ERR_PTR(-EBADF); |
| 545 | 545 | |
| 546 | − pid = pidfd_pid(f.file); | |
| 546 | + pid = pidfd_pid(fd_file(f)); | |
| 547 | 547 | if (!IS_ERR(pid)) { |
| 548 | 548 | get_pid(pid); |
| 549 | − *flags = f.file->f_flags; | |
| 549 | + *flags = fd_file(f)->f_flags; | |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | fdput(f); |
| @@ -755,10 +755,10 @@ SYSCALL_DEFINE3(pidfd_getfd, int, pidfd, int, fd, · 202 unmodified lines | ||
| 755 | 755 | return -EINVAL; |
| 756 | 756 | |
| 757 | 757 | f = fdget(pidfd); |
| 758 | − if (!f.file) | |
| 758 | + if (!fd_file(f)) | |
| 759 | 759 | return -EBADF; |
| 760 | 760 | |
| 761 | − pid = pidfd_pid(f.file); | |
| 761 | + pid = pidfd_pid(fd_file(f)); | |
| 762 | 762 | if (IS_ERR(pid)) |
| 763 | 763 | ret = PTR_ERR(pid); |
| 764 | 764 | else |
| @@ -3922,11 +3922,11 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 3921 unmodified lines | ||
| 3922 | 3922 | return -EINVAL; |
| 3923 | 3923 | |
| 3924 | 3924 | f = fdget(pidfd); |
| 3925 | − if (!f.file) | |
| 3925 | + if (!fd_file(f)) | |
| 3926 | 3926 | return -EBADF; |
| 3927 | 3927 | |
| 3928 | 3928 | /* Is this a pidfd? */ |
| 3929 | − pid = pidfd_to_pid(f.file); | |
| 3929 | + pid = pidfd_to_pid(fd_file(f)); | |
| 3930 | 3930 | if (IS_ERR(pid)) { |
| 3931 | 3931 | ret = PTR_ERR(pid); |
| 3932 | 3932 | goto err; |
| @@ -3939,7 +3939,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 6 unmodified lines | ||
| 3939 | 3939 | switch (flags) { |
| 3940 | 3940 | case 0: |
| 3941 | 3941 | /* Infer scope from the type of pidfd. */ |
| 3942 | − if (f.file->f_flags & PIDFD_THREAD) | |
| 3942 | + if (fd_file(f)->f_flags & PIDFD_THREAD) | |
| 3943 | 3943 | type = PIDTYPE_PID; |
| 3944 | 3944 | else |
| 3945 | 3945 | 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 | 1916 | int err; |
| 1917 | 1917 | |
| 1918 | 1918 | exe = fdget(fd); |
| 1919 | − if (!exe.file) | |
| 1919 | + if (!fd_file(exe)) | |
| 1920 | 1920 | return -EBADF; |
| 1921 | 1921 | |
| 1922 | − inode = file_inode(exe.file); | |
| 1922 | + inode = file_inode(fd_file(exe)); | |
| 1923 | 1923 | |
| 1924 | 1924 | /* |
| 1925 | 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 | 1927 | * overall picture. |
| 1928 | 1928 | */ |
| 1929 | 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 | 1931 | goto exit; |
| 1932 | 1932 | |
| 1933 | − err = file_permission(exe.file, MAY_EXEC); | |
| 1933 | + err = file_permission(fd_file(exe), MAY_EXEC); | |
| 1934 | 1934 | if (err) |
| 1935 | 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 | 1938 | exit: |
| 1939 | 1939 | fdput(exe); |
| 1940 | 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 | 420 | fd = nla_get_u32(info->attrs[CGROUPSTATS_CMD_ATTR_FD]); |
| 421 | 421 | f = fdget(fd); |
| 422 | − if (!f.file) | |
| 422 | + if (!fd_file(f)) | |
| 423 | 423 | return 0; |
| 424 | 424 | |
| 425 | 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 | 440 | stats = nla_data(na); |
| 441 | 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 | 444 | if (rc < 0) { |
| 445 | 445 | nlmsg_free(rep_skb); |
| 446 | 446 | goto err; |
| @@ -666,8 +666,8 @@ struct watch_queue *get_watch_queue(int fd) · 665 unmodified lines | ||
| 666 | 666 | struct fd f; |
| 667 | 667 | |
| 668 | 668 | f = fdget(fd); |
| 669 | − if (f.file) { | |
| 670 | − pipe = get_pipe_info(f.file, false); | |
| 669 | + if (fd_file(f)) { | |
| 670 | + pipe = get_pipe_info(fd_file(f), false); | |
| 671 | 671 | if (pipe && pipe->watch_queue) { |
| 672 | 672 | wqueue = pipe->watch_queue; |
| 673 | 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 | 193 | struct fd f = fdget(fd); |
| 194 | 194 | int ret; |
| 195 | 195 | |
| 196 | − if (!f.file) | |
| 196 | + if (!fd_file(f)) | |
| 197 | 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 | 201 | fdput(f); |
| 202 | 202 | return ret; |
| @@ -4393,7 +4393,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 4392 unmodified lines | ||
| 4393 | 4393 | struct cachestat cs; |
| 4394 | 4394 | pgoff_t first_index, last_index; |
| 4395 | 4395 | |
| 4396 | − if (!f.file) | |
| 4396 | + if (!fd_file(f)) | |
| 4397 | 4397 | return -EBADF; |
| 4398 | 4398 | |
| 4399 | 4399 | if (copy_from_user(&csr, cstat_range, |
| @@ -4403,7 +4403,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 3 unmodified lines | ||
| 4403 | 4403 | } |
| 4404 | 4404 | |
| 4405 | 4405 | /* hugetlbfs is not supported */ |
| 4406 | − if (is_file_hugepages(f.file)) { | |
| 4406 | + if (is_file_hugepages(fd_file(f))) { | |
| 4407 | 4407 | fdput(f); |
| 4408 | 4408 | return -EOPNOTSUPP; |
| 4409 | 4409 | } |
| @@ -4417,7 +4417,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 7 unmodified lines | ||
| 4417 | 4417 | last_index = |
| 4418 | 4418 | csr.len == 0 ? ULONG_MAX : (csr.off + csr.len - 1) >> PAGE_SHIFT; |
| 4419 | 4419 | memset(&cs, 0, sizeof(struct cachestat)); |
| 4420 | − mapping = f.file->f_mapping; | |
| 4420 | + mapping = fd_file(f)->f_mapping; | |
| 4421 | 4421 | filemap_cachestat(mapping, first_index, last_index, &cs); |
| 4422 | 4422 | fdput(f); |
| 4423 | 4423 | |
| @@ -1857,26 +1857,26 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 1856 unmodified lines | ||
| 1857 | 1857 | INIT_WORK(&event->remove, memcg_event_remove); |
| 1858 | 1858 | |
| 1859 | 1859 | efile = fdget(efd); |
| 1860 | − if (!efile.file) { | |
| 1860 | + if (!fd_file(efile)) { | |
| 1861 | 1861 | ret = -EBADF; |
| 1862 | 1862 | goto out_kfree; |
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | − event->eventfd = eventfd_ctx_fileget(efile.file); | |
| 1865 | + event->eventfd = eventfd_ctx_fileget(fd_file(efile)); | |
| 1866 | 1866 | if (IS_ERR(event->eventfd)) { |
| 1867 | 1867 | ret = PTR_ERR(event->eventfd); |
| 1868 | 1868 | goto out_put_efile; |
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | 1871 | cfile = fdget(cfd); |
| 1872 | − if (!cfile.file) { | |
| 1872 | + if (!fd_file(cfile)) { | |
| 1873 | 1873 | ret = -EBADF; |
| 1874 | 1874 | goto out_put_eventfd; |
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | /* the process need read permission on control file */ |
| 1878 | 1878 | /* AV: shouldn't we check that it's been opened for read instead? */ |
| 1879 | − ret = file_permission(cfile.file, MAY_READ); | |
| 1879 | + ret = file_permission(fd_file(cfile), MAY_READ); | |
| 1880 | 1880 | if (ret < 0) |
| 1881 | 1881 | goto out_put_cfile; |
| 1882 | 1882 | |
| @@ -1884,7 +1884,7 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 1 unmodified line | ||
| 1884 | 1884 | * The control file must be a regular cgroup1 file. As a regular cgroup |
| 1885 | 1885 | * file can't be renamed, it's safe to access its name afterwards. |
| 1886 | 1886 | */ |
| 1887 | − cdentry = cfile.file->f_path.dentry; | |
| 1887 | + cdentry = fd_file(cfile)->f_path.dentry; | |
| 1888 | 1888 | if (cdentry->d_sb->s_type != &cgroup_fs_type || !d_is_reg(cdentry)) { |
| 1889 | 1889 | ret = -EINVAL; |
| 1890 | 1890 | goto out_put_cfile; |
| @@ -1936,7 +1936,7 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 45 unmodified lines | ||
| 1936 | 1936 | if (ret) |
| 1937 | 1937 | goto out_put_css; |
| 1938 | 1938 | |
| 1939 | − vfs_poll(efile.file, &event->pt); | |
| 1939 | + vfs_poll(fd_file(efile), &event->pt); | |
| 1940 | 1940 | |
| 1941 | 1941 | spin_lock_irq(&memcg->event_list_lock); |
| 1942 | 1942 | list_add(&event->list, &memcg->event_list); |
| @@ -646,7 +646,7 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) · 645 unmodified lines | ||
| 646 | 646 | |
| 647 | 647 | ret = -EBADF; |
| 648 | 648 | f = fdget(fd); |
| 649 | − if (!f.file || !(f.file->f_mode & FMODE_READ)) | |
| 649 | + if (!fd_file(f) || !(fd_file(f)->f_mode & FMODE_READ)) | |
| 650 | 650 | goto out; |
| 651 | 651 | |
| 652 | 652 | /* |
| @@ -655,12 +655,12 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) · 2 unmodified lines | ||
| 655 | 655 | * on this file, then we must return -EINVAL. |
| 656 | 656 | */ |
| 657 | 657 | ret = -EINVAL; |
| 658 | − if (!f.file->f_mapping || !f.file->f_mapping->a_ops || | |
| 659 | − (!S_ISREG(file_inode(f.file)->i_mode) && | |
| 660 | − !S_ISBLK(file_inode(f.file)->i_mode))) | |
| 658 | + if (!fd_file(f)->f_mapping || !fd_file(f)->f_mapping->a_ops || | |
| 659 | + (!S_ISREG(file_inode(fd_file(f))->i_mode) && | |
| 660 | + !S_ISBLK(file_inode(fd_file(f))->i_mode))) | |
| 661 | 661 | goto out; |
| 662 | 662 | |
| 663 | − ret = vfs_fadvise(f.file, offset, count, POSIX_FADV_WILLNEED); | |
| 663 | + ret = vfs_fadvise(fd_file(f), offset, count, POSIX_FADV_WILLNEED); | |
| 664 | 664 | out: |
| 665 | 665 | fdput(f); |
| 666 | 666 | return ret; |
| @@ -711,11 +711,11 @@ struct net *get_net_ns_by_fd(int fd) · 710 unmodified lines | ||
| 711 | 711 | struct fd f = fdget(fd); |
| 712 | 712 | struct net *net = ERR_PTR(-EINVAL); |
| 713 | 713 | |
| 714 | − if (!f.file) | |
| 714 | + if (!fd_file(f)) | |
| 715 | 715 | return ERR_PTR(-EBADF); |
| 716 | 716 | |
| 717 | − if (proc_ns_file(f.file)) { | |
| 718 | − struct ns_common *ns = get_proc_ns(file_inode(f.file)); | |
| 717 | + if (proc_ns_file(fd_file(f))) { | |
| 718 | + struct ns_common *ns = get_proc_ns(file_inode(fd_file(f))); | |
| 719 | 719 | if (ns->ops == &netns_operations) |
| 720 | 720 | net = get_net(container_of(ns, struct net, ns)); |
| 721 | 721 | } |
| @@ -556,8 +556,8 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) · 555 unmodified lines | ||
| 556 | 556 | struct socket *sock; |
| 557 | 557 | |
| 558 | 558 | *err = -EBADF; |
| 559 | − if (f.file) { | |
| 560 | − sock = sock_from_file(f.file); | |
| 559 | + if (fd_file(f)) { | |
| 560 | + sock = sock_from_file(fd_file(f)); | |
| 561 | 561 | if (likely(sock)) { |
| 562 | 562 | *fput_needed = f.flags & FDPUT_FPUT; |
| 563 | 563 | return sock; |
| @@ -2008,8 +2008,8 @@ int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr, · 1444 unmodified lines | ||
| 2008 | 2008 | struct fd f; |
| 2009 | 2009 | |
| 2010 | 2010 | f = fdget(fd); |
| 2011 | − if (f.file) { | |
| 2012 | − ret = __sys_accept4_file(f.file, upeer_sockaddr, | |
| 2011 | + if (fd_file(f)) { | |
| 2012 | + ret = __sys_accept4_file(fd_file(f), upeer_sockaddr, | |
| 2013 | 2013 | upeer_addrlen, flags); |
| 2014 | 2014 | fdput(f); |
| 2015 | 2015 | } |
| @@ -2070,12 +2070,12 @@ int __sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen) · 54 unmodified lines | ||
| 2070 | 2070 | struct fd f; |
| 2071 | 2071 | |
| 2072 | 2072 | f = fdget(fd); |
| 2073 | − if (f.file) { | |
| 2073 | + if (fd_file(f)) { | |
| 2074 | 2074 | struct sockaddr_storage address; |
| 2075 | 2075 | |
| 2076 | 2076 | ret = move_addr_to_kernel(uservaddr, addrlen, &address); |
| 2077 | 2077 | if (!ret) |
| 2078 | − ret = __sys_connect_file(f.file, &address, addrlen, 0); | |
| 2078 | + ret = __sys_connect_file(fd_file(f), &address, addrlen, 0); | |
| 2079 | 2079 | fdput(f); |
| 2080 | 2080 | } |
| 2081 | 2081 | |
| @@ -1068,10 +1068,10 @@ void ima_kexec_cmdline(int kernel_fd, const void *buf, int size) · 1067 unmodified lines | ||
| 1068 | 1068 | return; |
| 1069 | 1069 | |
| 1070 | 1070 | f = fdget(kernel_fd); |
| 1071 | − if (!f.file) | |
| 1071 | + if (!fd_file(f)) | |
| 1072 | 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 | 1075 | buf, size, "kexec-cmdline", KEXEC_CMDLINE, 0, |
| 1076 | 1076 | NULL, false, NULL, 0); |
| 1077 | 1077 | fdput(f); |
| @@ -238,19 +238,19 @@ static struct landlock_ruleset *get_ruleset_from_fd(const int fd, · 237 unmodified lines | ||
| 238 | 238 | struct landlock_ruleset *ruleset; |
| 239 | 239 | |
| 240 | 240 | ruleset_f = fdget(fd); |
| 241 | − if (!ruleset_f.file) | |
| 241 | + if (!fd_file(ruleset_f)) | |
| 242 | 242 | return ERR_PTR(-EBADF); |
| 243 | 243 | |
| 244 | 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 | 246 | ruleset = ERR_PTR(-EBADFD); |
| 247 | 247 | goto out_fdput; |
| 248 | 248 | } |
| 249 | − if (!(ruleset_f.file->f_mode & mode)) { | |
| 249 | + if (!(fd_file(ruleset_f)->f_mode & mode)) { | |
| 250 | 250 | ruleset = ERR_PTR(-EPERM); |
| 251 | 251 | goto out_fdput; |
| 252 | 252 | } |
| 253 | − ruleset = ruleset_f.file->private_data; | |
| 253 | + ruleset = fd_file(ruleset_f)->private_data; | |
| 254 | 254 | if (WARN_ON_ONCE(ruleset->num_layers != 1)) { |
| 255 | 255 | ruleset = ERR_PTR(-EINVAL); |
| 256 | 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 | 278 | /* Handles O_PATH. */ |
| 279 | 279 | f = fdget_raw(fd); |
| 280 | − if (!f.file) | |
| 280 | + if (!fd_file(f)) | |
| 281 | 281 | return -EBADF; |
| 282 | 282 | /* |
| 283 | 283 | * Forbids ruleset FDs, internal filesystems (e.g. nsfs), including |
| 284 | 284 | * pseudo filesystems that will never be mountable (e.g. sockfs, |
| 285 | 285 | * pipefs). |
| 286 | 286 | */ |
| 287 | − if ((f.file->f_op == &ruleset_fops) || | |
| 288 | − (f.file->f_path.mnt->mnt_flags & MNT_INTERNAL) || | |
| 289 | − (f.file->f_path.dentry->d_sb->s_flags & SB_NOUSER) || | |
| 290 | − d_is_negative(f.file->f_path.dentry) || | |
| 291 | − IS_PRIVATE(d_backing_inode(f.file->f_path.dentry))) { | |
| 287 | + if ((fd_file(f)->f_op == &ruleset_fops) || | |
| 288 | + (fd_file(f)->f_path.mnt->mnt_flags & MNT_INTERNAL) || | |
| 289 | + (fd_file(f)->f_path.dentry->d_sb->s_flags & SB_NOUSER) || | |
| 290 | + d_is_negative(fd_file(f)->f_path.dentry) || | |
| 291 | + IS_PRIVATE(d_backing_inode(fd_file(f)->f_path.dentry))) { | |
| 292 | 292 | err = -EBADFD; |
| 293 | 293 | goto out_fdput; |
| 294 | 294 | } |
| 295 | − *path = f.file->f_path; | |
| 295 | + *path = fd_file(f)->f_path; | |
| 296 | 296 | path_get(path); |
| 297 | 297 | |
| 298 | 298 | out_fdput: |
| @@ -296,7 +296,7 @@ static int read_trusted_verity_root_digests(unsigned int fd) · 295 unmodified lines | ||
| 296 | 296 | return -EPERM; |
| 297 | 297 | |
| 298 | 298 | f = fdget(fd); |
| 299 | − if (!f.file) | |
| 299 | + if (!fd_file(f)) | |
| 300 | 300 | return -EINVAL; |
| 301 | 301 | |
| 302 | 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 | 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 | 309 | if (rc < 0) |
| 310 | 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 | 2250 | bool nonatomic = substream->pcm->nonatomic; |
| 2251 | 2251 | CLASS(fd, f)(fd); |
| 2252 | 2252 | |
| 2253 | − if (!f.file) | |
| 2253 | + if (!fd_file(f)) | |
| 2254 | 2254 | return -EBADFD; |
| 2255 | − if (!is_pcm_file(f.file)) | |
| 2255 | + if (!is_pcm_file(fd_file(f))) | |
| 2256 | 2256 | return -EBADFD; |
| 2257 | 2257 | |
| 2258 | − pcm_file = f.file->private_data; | |
| 2258 | + pcm_file = fd_file(f)->private_data; | |
| 2259 | 2259 | substream1 = pcm_file->substream; |
| 2260 | 2260 | |
| 2261 | 2261 | if (substream == substream1) |
| @@ -327,12 +327,12 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) · 326 unmodified lines | ||
| 327 | 327 | seqcount_spinlock_init(&irqfd->irq_entry_sc, &kvm->irqfds.lock); |
| 328 | 328 | |
| 329 | 329 | f = fdget(args->fd); |
| 330 | − if (!f.file) { | |
| 330 | + if (!fd_file(f)) { | |
| 331 | 331 | ret = -EBADF; |
| 332 | 332 | goto out; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | − eventfd = eventfd_ctx_fileget(f.file); | |
| 335 | + eventfd = eventfd_ctx_fileget(fd_file(f)); | |
| 336 | 336 | if (IS_ERR(eventfd)) { |
| 337 | 337 | ret = PTR_ERR(eventfd); |
| 338 | 338 | goto fail; |
| @@ -419,7 +419,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) · 80 unmodified lines | ||
| 419 | 419 | * Check if there was an event already pending on the eventfd |
| 420 | 420 | * before we registered, and trigger it as if we didn't miss it. |
| 421 | 421 | */ |
| 422 | − events = vfs_poll(f.file, &irqfd->pt); | |
| 422 | + events = vfs_poll(fd_file(f), &irqfd->pt); | |
| 423 | 423 | |
| 424 | 424 | if (events & EPOLLIN) |
| 425 | 425 | 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 | 194 | int ret; |
| 195 | 195 | |
| 196 | 196 | f = fdget(fd); |
| 197 | − if (!f.file) | |
| 197 | + if (!fd_file(f)) | |
| 198 | 198 | return -EBADF; |
| 199 | 199 | |
| 200 | 200 | ret = -ENOENT; |
| @@ -202,7 +202,7 @@ static int kvm_vfio_file_del(struct kvm_device *dev, unsigned int fd) · 1 unmodified line | ||
| 202 | 202 | mutex_lock(&kv->lock); |
| 203 | 203 | |
| 204 | 204 | list_for_each_entry(kvf, &kv->file_list, node) { |
| 205 | − if (kvf->file != f.file) | |
| 205 | + if (kvf->file != fd_file(f)) | |
| 206 | 206 | continue; |
| 207 | 207 | |
| 208 | 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 | 240 | return -EFAULT; |
| 241 | 241 | |
| 242 | 242 | f = fdget(param.groupfd); |
| 243 | − if (!f.file) | |
| 243 | + if (!fd_file(f)) | |
| 244 | 244 | return -EBADF; |
| 245 | 245 | |
| 246 | 246 | ret = -ENOENT; |
| @@ -248,7 +248,7 @@ static int kvm_vfio_file_set_spapr_tce(struct kvm_device *dev, · 1 unmodified line | ||
| 248 | 248 | mutex_lock(&kv->lock); |
| 249 | 249 | |
| 250 | 250 | list_for_each_entry(kvf, &kv->file_list, node) { |
| 251 | − if (kvf->file != f.file) | |
| 251 | + if (kvf->file != fd_file(f)) | |
| 252 | 252 | continue; |
| 253 | 253 | |
| 254 | 254 | if (!kvf->iommu_group) { |