]> 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)
commit8bdfea522d63ffa785f641fe9ac269f9d3e449f5
treec63531a963fbe14bb83641c22185e8c5f72812c9
parent5086fd030ee7275beaf7a7d87544cea14a90cd38
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: f42f5bca70ca ("ovl: override creds with the ones from the superblock mounter")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/dir.c