]> git.baikalelectronics.ru Git - kernel.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)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 15 Jun 2016 12:18:59 +0000 (14:18 +0200)
commitb4e809ee8162563c7601ce890297729fd5429784
treec63531a963fbe14bb83641c22185e8c5f72812c9
parenta3d4783982af5a27cc936abb67fc4c7a6ff9dd43
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: 3123017109b6 ("ovl: override creds with the ones from the superblock mounter")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/dir.c