Skip to content

Commit 0acffb2

Browse files
committed
Merge tag 'ovl-fixes-6.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs
Pull overlayfs fixes from Miklos Szeredi: "Fix two bugs, a recent one introduced in the last cycle, and an older one from v5.11" * tag 'ovl-fixes-6.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs: ovl: fail on invalid uid/gid mapping at copy up ovl: fix tmpfile leak
2 parents 76e26e3 + 4f11ada commit 0acffb2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/overlayfs/copy_up.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c)
792792
if (!c->metacopy && c->stat.size) {
793793
err = ovl_copy_up_file(ofs, c->dentry, tmpfile, c->stat.size);
794794
if (err)
795-
return err;
795+
goto out_fput;
796796
}
797797

798798
err = ovl_copy_up_metadata(c, temp);
@@ -1011,6 +1011,10 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
10111011
if (err)
10121012
return err;
10131013

1014+
if (!kuid_has_mapping(current_user_ns(), ctx.stat.uid) ||
1015+
!kgid_has_mapping(current_user_ns(), ctx.stat.gid))
1016+
return -EOVERFLOW;
1017+
10141018
ctx.metacopy = ovl_need_meta_copy_up(dentry, ctx.stat.mode, flags);
10151019

10161020
if (parent) {

0 commit comments

Comments
 (0)