Skip to content

Commit 3b6b99e

Browse files
gonzouaamir73il
authored andcommitted
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 <[email protected]> Fixes: 72db821 ("ovl: copy up sync/noatime fileattr flags") Cc: [email protected] # v5.15+ Signed-off-by: Amir Goldstein <[email protected]>
1 parent 2d5404c commit 3b6b99e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/overlayfs/inode.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,13 @@ static int ovl_security_fileattr(const struct path *realpath, struct fileattr *f
616616
struct file *file;
617617
unsigned int cmd;
618618
int err;
619+
unsigned int flags;
620+
621+
flags = O_RDONLY;
622+
if (force_o_largefile())
623+
flags |= O_LARGEFILE;
619624

620-
file = dentry_open(realpath, O_RDONLY, current_cred());
625+
file = dentry_open(realpath, flags, current_cred());
621626
if (IS_ERR(file))
622627
return PTR_ERR(file);
623628

0 commit comments

Comments
 (0)