Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

autofs4: Fix wait validation

It is possible for the check in wait.c:validate_request() to return
an incorrect result if the dentry that was mounted upon has changed
during the callback.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Ian Kent and committed by
Al Viro
9e3fea16 66511493

+16 -1
+16 -1
fs/autofs4/waitq.c
··· 309 309 * completed while we waited on the mutex ... 310 310 */ 311 311 if (notify == NFY_MOUNT) { 312 + struct dentry *new = NULL; 313 + int valid = 1; 314 + 312 315 /* 313 316 * If the dentry was successfully mounted while we slept 314 317 * on the wait queue mutex we can return success. If it ··· 319 316 * a multi-mount with no mount at it's base) we can 320 317 * continue on and create a new request. 321 318 */ 319 + if (!IS_ROOT(dentry)) { 320 + if (dentry->d_inode && d_unhashed(dentry)) { 321 + struct dentry *parent = dentry->d_parent; 322 + new = d_lookup(parent, &dentry->d_name); 323 + if (new) 324 + dentry = new; 325 + } 326 + } 322 327 if (have_submounts(dentry)) 323 - return 0; 328 + valid = 0; 329 + 330 + if (new) 331 + dput(new); 332 + return valid; 324 333 } 325 334 326 335 return 1;