]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ovl: fix uid/gid when creating over whiteout
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 15 Jun 2016 12:18:59 +0000 (14:18 +0200)
committerShan Hai <shan.hai@oracle.com>
Fri, 4 Aug 2017 05:48:37 +0000 (13:48 +0800)
commit13a40a5f1c27872d2234ec0a34695fb064277006
tree29e14abc0146b842d78b46610a398094396bf21c
parent550f7025888744e822eb17dd7cf26996fba0d004
ovl: fix uid/gid when creating over whiteout

Fix a regression when creating a file over a whiteout.  The new
file/directory needs to use the current fsuid/fsgid, not the ones from the
mounter's credentials.

The refcounting is a bit tricky: prepare_creds() sets an original refcount,
override_creds() gets one more, which revert_cred() drops.  So

  1) we need to expicitly put the mounter's credentials when overriding
     with the updated one

  2) we need to put the original ref to the updated creds (and this can
     safely be done before revert_creds(), since we'll still have the ref
     from override_creds()).

Reported-by: Stephen Smalley <sds@tycho.nsa.gov>
Fixes: 3fe6e52f0626 ("ovl: override creds with the ones from the superblock mounter")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Orabug: 26401569

(backport upstream commit d0e13f5bbe4be7c8f27736fc40503dcec04b7de0)

Signed-off-by: Shan Hai <shan.hai@oracle.com>
Reviewed-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
fs/overlayfs/dir.c