ovl: stacked file operation for mmap
PATCH 1/1 ovl: stacked file operation for mmap
From: root <[email protected]>
Currently only mmap does not behave as stacked file operation, although in practice there is less change to open a file in RDONLY mode and take long time to do mmap but the fix looks reasonable.
Signed-off-by root <[email protected]>
--- fs/overlayfs/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/overlayfs/file.c +8 -2
@@ -461,6 +461,7 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma) {struct file *realfile = file->private_data;const struct cred *old_cred; +struct fd real;int ret;if (!realfile->f_op->mmap)
@@ -469,7 +470,11 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma)if (WARN_ON (file != vma->vm_file))return -EIO ; - vma->vm_file =get_file (realfile); + ret =ovl_real_fdget (file, &real); +if (ret) +return ret; + + vma->vm_file =get_file (real.file); old_cred =ovl_override_creds (file_inode (file)->i_sb); ret =call_mmap (vma->vm_file, vma);
@@ -477,13 +482,14 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma)if (ret) {/* Drop reference count from new vm_file value */ -fput (realfile); +fput (real.file); }else {/* Drop reference count from previous vm_file value */ fput (file); }ovl_file_accessed (file); +fdput (real);return ret; }
Signature · 1 line
2.26.2