2022-06-15 22:00 GMT+09:00, Amir Goldstein <amir73il@xxxxxxxxx>: > A regression has been reported by Nicolas Boichat, found while using the > copy_file_range syscall to copy a tracefs file. Before commit > 5dae222a5ff0 ("vfs: allow copy_file_range to copy across devices") the > kernel would return -EXDEV to userspace when trying to copy a file across > different filesystems. After this commit, the syscall doesn't fail anymore > and instead returns zero (zero bytes copied), as this file's content is > generated on-the-fly and thus reports a size of zero. > > Another regression has been reported by He Zhe - the assertion of > WARN_ON_ONCE(ret == -EOPNOTSUPP) can be triggered from userspace when > copying from a sysfs file whose read operation may return -EOPNOTSUPP. > > Since we do not have test coverage for copy_file_range() between any > two types of filesystems, the best way to avoid these sort of issues > in the future is for the kernel to be more picky about filesystems that > are allowed to do copy_file_range(). > > This patch restores some cross-filesystem copy restrictions that existed > prior to commit 5dae222a5ff0 ("vfs: allow copy_file_range to copy across > devices"), namely, cross-sb copy is not allowed for filesystems that do > not implement ->copy_file_range(). > > Filesystems that do implement ->copy_file_range() have full control of > the result - if this method returns an error, the error is returned to > the user. Before this change this was only true for fs that did not > implement the ->remap_file_range() operation (i.e. nfsv3). > > Filesystems that do not implement ->copy_file_range() still fall-back to > the generic_copy_file_range() implementation when the copy is within the > same sb. This helps the kernel can maintain a more consistent story > about which filesystems support copy_file_range(). > > nfsd and ksmbd servers are modified to fall-back to the > generic_copy_file_range() implementation in case vfs_copy_file_range() > fails with -EOPNOTSUPP or -EXDEV, which preserves behavior of > server-side-copy. > > fall-back to generic_copy_file_range() is not implemented for the smb > operation FSCTL_DUPLICATE_EXTENTS_TO_FILE, which is arguably a correct > change of behavior. > > Fixes: 5dae222a5ff0 ("vfs: allow copy_file_range to copy across devices") > Link: > https://lore.kernel.org/linux-fsdevel/20210212044405.4120619-1-drinkcat@xxxxxxxxxxxx/ > Link: > https://lore.kernel.org/linux-fsdevel/CANMq1KDZuxir2LM5jOTm0xx+BnvW=ZmpsG47CyHFJwnw7zSX6Q@xxxxxxxxxxxxxx/ > Link: > https://lore.kernel.org/linux-fsdevel/20210126135012.1.If45b7cdc3ff707bc1efa17f5366057d60603c45f@changeid/ > Link: > https://lore.kernel.org/linux-fsdevel/20210630161320.29006-1-lhenriques@xxxxxxx/ > Reported-by: Nicolas Boichat <drinkcat@xxxxxxxxxxxx> > Reported-by: kernel test robot <oliver.sang@xxxxxxxxx> > Signed-off-by: Luis Henriques <lhenriques@xxxxxxx> > Fixes: 64bf5ff58dff ("vfs: no fallback for ->copy_file_range") > Link: > https://lore.kernel.org/linux-fsdevel/20f17f64-88cb-4e80-07c1-85cb96c83619@xxxxxxxxxxxxx/ > Reported-by: He Zhe <zhe.he@xxxxxxxxxxxxx> > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> > --- > Hi Luis, Namje, > > Thank you for testing v14 [1]. Unfortunately (or fortunately), > kernel test robot has alerted me on LTP test failure [2] with v14. > > The patch had changed behavior of same sb case when it should not have. > So I did not apply you Tested-by and I would like to request from you > to test v15. Works fine. You can add tested-by tag for ksmbd. Tested-by: Namjae Jeon <linkinjeon@xxxxxxxxxx> Thanks!