]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
ecryptfs_lookup_interpose(): lower_dentry->d_parent is not stable either
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 3 Nov 2019 18:55:43 +0000 (13:55 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:16:22 +0000 (13:16 +0100)
commitac365c0d1ac49e437168317e1b18bc6dc868c804
treeb9a8b54525b08d4d1998b4a12dfa48b3dc2917b9
parent4a19d1451a0e6cc25c1e833c1abab8d218bded5b
ecryptfs_lookup_interpose(): lower_dentry->d_parent is not stable either

BugLink: https://bugs.launchpad.net/bugs/1853915
commit 762c69685ff7ad5ad7fee0656671e20a0c9c864d upstream.

We need to get the underlying dentry of parent; sure, absent the races
it is the parent of underlying dentry, but there's nothing to prevent
losing a timeslice to preemtion in the middle of evaluation of
lower_dentry->d_parent->d_inode, having another process move lower_dentry
around and have its (ex)parent not pinned anymore and freed on memory
pressure.  Then we regain CPU and try to fetch ->d_inode from memory
that is freed by that point.

dentry->d_parent *is* stable here - it's an argument of ->lookup() and
we are guaranteed that it won't be moved anywhere until we feed it
to d_add/d_splice_alias.  So we safely go that way to get to its
underlying dentry.

Cc: stable@vger.kernel.org # since 2009 or so
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/ecryptfs/inode.c