Re: [PATCH 2/2] copy_file_range: limit size if in compat mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 12 Aug 2025 at 16:36, Amir Goldstein <amir73il@xxxxxxxxx> wrote:
>
> On Tue, Aug 5, 2025 at 8:30 PM Miklos Szeredi <mszeredi@xxxxxxxxxx> wrote:

> > +       /* Make sure return value doesn't overflow in 32bit compat mode */
> > +       if (in_compat_syscall() && len > MAX_RW_COUNT)
> > +               len = MAX_RW_COUNT;
> > +
>
> 1. Note that generic_copy_file_checks() can already shorten len,
>     so maybe this should also be done there?? not sure..

I guess it doesn't really matter, since all of these functions are
local.  I've decided to do it directly in vfs_copy_file_range because
in other cases MAX_RW_COUNTS are  checked directly in vfs_...

> 2. Both ->remap_file_range() and splice cases already trim to MAX_RW_COUNT
>     so the only remaining case for len > MAX_RW_COUNT are filesystems
>     that implement ->copy_file_range() and actually support copying ranges
>     larger than 2MB (don't know if they actually exist)
>
> IOW, if we do:
>
> if (splice || !file_out->f_op->copy_file_range || in_compat_syscall())
>         len = min_t(loff_t, MAX_RW_COUNT, len);
>
> We will not need to repeat the same trim of len in 3 different places
> in this function.

Makes sense.

Thanks,
Miklos





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux