On Fri, Apr 16, 2021 at 06:00:38PM +0200, Christian Brauner wrote: > (dma_buf_fd() seems like another good candidate. But again, I don't have > any plans to shove this down anyone's throat.) Sure, there are candidates for such a helper. Just as there are legitimate users of anon_inode_getfd(). However, it is *NOT* something we can use as a vehicle for some hooks (pardon the obscenity); it won't be consistently used in all cases - it simply is not feasible for many of the fd_install() users. Incidentally, looking at the user of receive_fd_user(), I would say that it would be easier to follow in this form: case VDUSE_IOTLB_GET_ENTRY: { struct vduse_iotlb_entry entry; struct vhost_iotlb_map *map; struct vduse_iova_domain *domain = dev->domain; struct file *f = NULL; if (copy_from_user(&entry, argp, sizeof(entry))) return -EFAULT; entry.fd = get_unused_fd_flags(perm_to_file_flags(entry.perm)); if (entry.fd < 0) return entry.fd; spin_lock(&domain->iotlb_lock); map = vhost_iotlb_itree_first(domain->iotlb, entry.start, entry.start + 1); if (map) { struct vdpa_map_file *map_file = map->opaque; f = get_file(map_file->file); entry.offset = map_file->offset; entry.start = map->start; entry.last = map->last; entry.perm = map->perm; } spin_unlock(&domain->iotlb_lock); if (!f) { put_unused_fd(entry.fd); return -EINVAL; } if (copy_to_user(argp, &entry, sizeof(entry))) { put_unused_fd(entry.fd); fput(f); return -EFAULT; } // point of no return fd_install(entry.fd, f); return 0; }