Skip to contentSkip to conversation

ovl: properly handle large files in ovl_security_fileattr

PATCH Applied Oleksandr Tymoshenko 2 participants 2 messages Oct 30, 2024 – Nov 4, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Fixes 72db82115d2b ("ovl: copy up sync/noatime fileattr flags")
Cc [email protected] # v5.15+
---
 fs/overlayfs/inode.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/overlayfs/inode.c +6 -1
index 35fd3e3e1778..baa54c718bd7 100644
@@ -616,8 +616,13 @@ static int ovl_security_fileattr(const struct path *realpath, struct fileattr *f
 	struct file *file;
 	unsigned int cmd;
 	int err;
+	unsigned int flags;
+
+	flags = O_RDONLY;
+	if (force_o_largefile())
+		flags |= O_LARGEFILE;
 
-	file = dentry_open(realpath, O_RDONLY, current_cred());
+	file = dentry_open(realpath, flags, current_cred());
 	if (IS_ERR(file))
 		return PTR_ERR(file);
 
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
maintainer Applied
#1 lore raw
Quoted 17 lines · Oleksandr Tymoshenko

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
Quoted 6 lines

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

Fixes 72db82115d2b ("ovl: copy up sync/noatime fileattr flags")
Cc [email protected] # v5.15+

Applied.

Thanks,
Amir,

Quoted 26 lines
---
 fs/overlayfs/inode.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/overlayfs/inode.c +6 -2
index 35fd3e3e1778..baa54c718bd7 100644
@@ -616,8 +616,13 @@ static int ovl_security_fileattr(const struct path *realpath, struct fileattr *f
        struct file *file;
        unsigned int cmd;
        int err;
+       unsigned int flags;
+
+       flags = O_RDONLY;
+       if (force_o_largefile())
+               flags |= O_LARGEFILE;
 
-       file = dentry_open(realpath, O_RDONLY, current_cred());
+       file = dentry_open(realpath, flags, current_cred());
        if (IS_ERR(file))
                return PTR_ERR(file);
 
--

2.47.0.163.g1226f6d8fa-goog