On 2023/04/12 22:13, Matthew Wilcox wrote: >> Also, since Documentation/filesystems/fiemap.rst says that "If an error >> is encountered while copying the extent to user memory, -EFAULT will be >> returned.", I assume that ioctl(FS_IOC_FIEMAP) users can handle -EFAULT >> error. > > What? No, that doesn't mean "You can return -EFAULT because random luck". > That means "If you pass it an invalid address, you'll get -EFAULT back". > > NACK. Then, why does fiemap.rst say "If an error is encountered" rather than "If an invalid address is passed" ? Does the definition of -EFAULT limited to "the caller does not have permission to access this address" ? ---------- int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical, u64 phys, u64 len, u32 flags) { struct fiemap_extent extent; struct fiemap_extent __user *dest = fieinfo->fi_extents_start; /* only count the extents */ if (fieinfo->fi_extents_max == 0) { fieinfo->fi_extents_mapped++; return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; } if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max) return 1; if (flags & SET_UNKNOWN_FLAGS) flags |= FIEMAP_EXTENT_UNKNOWN; if (flags & SET_NO_UNMOUNTED_IO_FLAGS) flags |= FIEMAP_EXTENT_ENCODED; if (flags & SET_NOT_ALIGNED_FLAGS) flags |= FIEMAP_EXTENT_NOT_ALIGNED; memset(&extent, 0, sizeof(extent)); extent.fe_logical = logical; extent.fe_physical = phys; extent.fe_length = len; extent.fe_flags = flags; dest += fieinfo->fi_extents_mapped; if (copy_to_user(dest, &extent, sizeof(extent))) return -EFAULT; fieinfo->fi_extents_mapped++; if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max) return 1; return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; } ---------- If copy_to_user() must not fail other than "the caller does not have permission to access this address", what should we do for now? Just remove ntfs_fiemap() and return -EOPNOTSUPP ?