Skip to content

Commit 0a650b5

Browse files
author
Miklos Szeredi
committed
ovl: properly handle large files in ovl_security_fileattr
JIRA: https://issues.redhat.com/browse/RHEL-83562 commit 3b6b99e Author: Oleksandr Tymoshenko <ovt@google.com> Date: Wed Oct 30 00:28:55 2024 +0000 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: 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: Miklos Szeredi <mszeredi@redhat.com>
1 parent 0e5b52d commit 0a650b5

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)