OSDN Git Service

ceph: don't try to handle hashed dentries in non-O_CREAT atomic_open
authorJeff Layton <jlayton@kernel.org>
Wed, 30 Oct 2019 16:15:10 +0000 (12:15 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 5 Nov 2019 14:42:44 +0000 (15:42 +0100)
commit5bb5e6ee6f5c557dcd19822eccd7bcced1e1a410
treef8a1b79914122633ee4e1ec4139d9b8ff751f4bd
parent1f08529c84cfecaf1261ed9b7e17fab18541c58f
ceph: don't try to handle hashed dentries in non-O_CREAT atomic_open

If ceph_atomic_open is handed a !d_in_lookup dentry, then that means
that it already passed d_revalidate so we *know* that it's negative (or
at least was very recently). Just return -ENOENT in that case.

This also addresses a subtle bug in dentry handling. Non-O_CREAT opens
call atomic_open with the parent's i_rwsem shared, but calling
d_splice_alias on a hashed dentry requires the exclusive lock.

If ceph_atomic_open receives a hashed, negative dentry on a non-O_CREAT
open, and another client were to race in and create the file before we
issue our OPEN, ceph_fill_trace could end up calling d_splice_alias on
the dentry with the new inode with insufficient locks.

Cc: stable@vger.kernel.org
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/file.c