Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ovl: properly handle large files in ovl_security_fileattr

dentry_open in ovl_security_fileattr fails for any file
larger than 2GB if open method of the underlying filesystem
calls generic_file_open (e.g. fusefs).

The issue can be reproduce using the following script:
(passthrough_ll is an example app from libfuse).

$ D=/opt/test/mnt
$ mkdir -p ${D}/{source,base,top/uppr,top/work,ovlfs}
$ dd if=/dev/zero of=${D}/source/zero.bin bs=1G count=2
$ passthrough_ll -o source=${D}/source ${D}/base
$ mount -t overlay overlay \
-olowerdir=${D}/base,upperdir=${D}/top/uppr,workdir=${D}/top/work \
${D}/ovlfs
$ chmod 0777 ${D}/mnt/ovlfs/zero.bin

Running this script results in "Value too large for defined data type"
error message from chmod.

Signed-off-by: Oleksandr Tymoshenko <ovt@google.com>
Fixes: 72db82115d2b ("ovl: copy up sync/noatime fileattr flags")
Cc: stable@vger.kernel.org # v5.15+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>

authored by

Oleksandr Tymoshenko and committed by
Amir Goldstein
3b6b99ef 2d5404ca

+6 -1
+6 -1
fs/overlayfs/inode.c
··· 616 616 struct file *file; 617 617 unsigned int cmd; 618 618 int err; 619 + unsigned int flags; 619 620 620 - file = dentry_open(realpath, O_RDONLY, current_cred()); 621 + flags = O_RDONLY; 622 + if (force_o_largefile()) 623 + flags |= O_LARGEFILE; 624 + 625 + file = dentry_open(realpath, flags, current_cred()); 621 626 if (IS_ERR(file)) 622 627 return PTR_ERR(file); 623 628