Skip to content

Commit fa721e5

Browse files
gonzouaSasha Levin
authored andcommitted
ovl: properly handle large files in ovl_security_fileattr
commit 3b6b99e upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 422a70e commit fa721e5

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
@@ -593,8 +593,13 @@ static int ovl_security_fileattr(const struct path *realpath, struct fileattr *f
593593
struct file *file;
594594
unsigned int cmd;
595595
int err;
596+
unsigned int flags;
597+
598+
flags = O_RDONLY;
599+
if (force_o_largefile())
600+
flags |= O_LARGEFILE;
596601

597-
file = dentry_open(realpath, O_RDONLY, current_cred());
602+
file = dentry_open(realpath, flags, current_cred());
598603
if (IS_ERR(file))
599604
return PTR_ERR(file);
600605

0 commit comments

Comments
 (0)