Skip to content

Commit 371e65d

Browse files
gonzouamehmetb0
authored andcommitted
ovl: properly handle large files in ovl_security_fileattr
BugLink: https://bugs.launchpad.net/bugs/2095283 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 <ovt@google.com> Fixes: 72db821 ("ovl: copy up sync/noatime fileattr flags") Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
1 parent d27e0d1 commit 371e65d

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
@@ -519,8 +519,13 @@ static int ovl_security_fileattr(struct path *realpath, struct fileattr *fa,
519519
struct file *file;
520520
unsigned int cmd;
521521
int err;
522+
unsigned int flags;
523+
524+
flags = O_RDONLY;
525+
if (force_o_largefile())
526+
flags |= O_LARGEFILE;
522527

523-
file = dentry_open(realpath, O_RDONLY, current_cred());
528+
file = dentry_open(realpath, flags, current_cred());
524529
if (IS_ERR(file))
525530
return PTR_ERR(file);
526531

0 commit comments

Comments
 (0)