Skip to content

Commit 6025f64

Browse files
Al Virogregkh
authored andcommitted
nfs4_setup_readdir(): insufficient locking for ->d_parent->d_inode dereferencing
[ Upstream commit a890a2e ] Theoretically it's an oopsable race, but I don't believe one can manage to hit it on real hardware; might become doable on a KVM, but it still won't be easy to attack. Anyway, it's easy to deal with - since xdr_encode_hyper() is just a call of put_unaligned_be64(), we can put that under ->d_lock and be done with that. Signed-off-by: Al Viro <[email protected]> Signed-off-by: Anna Schumaker <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 0123f97 commit 6025f64

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/nfs/nfs4proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dent
355355
*p++ = htonl(attrs); /* bitmap */
356356
*p++ = htonl(12); /* attribute buffer length */
357357
*p++ = htonl(NF4DIR);
358+
spin_lock(&dentry->d_lock);
358359
p = xdr_encode_hyper(p, NFS_FILEID(d_inode(dentry->d_parent)));
360+
spin_unlock(&dentry->d_lock);
359361

360362
readdir->pgbase = (char *)p - (char *)start;
361363
readdir->count -= readdir->pgbase;

0 commit comments

Comments
 (0)