]> git.baikalelectronics.ru Git - 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)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 10 Nov 2019 16:57:45 +0000 (11:57 -0500)
commit9f120ee3ffd47c0f75da2775e9298b096c940a36
tree9dd2bdbab0f29a6ed9014f56db9ec384c327a282
parent0d2b397dc3f6b371805c71e01f69c7115b6e20b0
ecryptfs_lookup_interpose(): lower_dentry->d_parent is not stable either

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>
fs/ecryptfs/inode.c