aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-01-10 22:20:12 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-11 00:19:12 -0500
commit4041bcdc7bef06a2fb29c57394c713a74bd13b08 (patch)
treeadaf5dee1b8312cdd37a2b37551770af461212a3 /fs
parentb3f2a92447b8443360ac117a3d7c06689562a70c (diff)
autofs4: autofs4_wait() vs. autofs4_catatonic_mode() race
We need to recheck ->catatonic after autofs4_wait() got ->wq_mutex for good, or we might end up with wq inserted into queue after autofs4_catatonic_mode() had done its thing. It will stick there forever, since there won't be anything to clear its ->name.name. A bit of a complication: validate_request() drops and regains ->wq_mutex. It actually ends up the most convenient place to stick the check into... Acked-by: Ian Kent <raven@themaw.net> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/autofs4/waitq.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index e1fbdeef85db..c13273afd546 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -257,6 +257,9 @@ static int validate_request(struct autofs_wait_queue **wait,
257 struct autofs_wait_queue *wq; 257 struct autofs_wait_queue *wq;
258 struct autofs_info *ino; 258 struct autofs_info *ino;
259 259
260 if (sbi->catatonic)
261 return -ENOENT;
262
260 /* Wait in progress, continue; */ 263 /* Wait in progress, continue; */
261 wq = autofs4_find_wait(sbi, qstr); 264 wq = autofs4_find_wait(sbi, qstr);
262 if (wq) { 265 if (wq) {
@@ -289,6 +292,9 @@ static int validate_request(struct autofs_wait_queue **wait,
289 if (mutex_lock_interruptible(&sbi->wq_mutex)) 292 if (mutex_lock_interruptible(&sbi->wq_mutex))
290 return -EINTR; 293 return -EINTR;
291 294
295 if (sbi->catatonic)
296 return -ENOENT;
297
292 wq = autofs4_find_wait(sbi, qstr); 298 wq = autofs4_find_wait(sbi, qstr);
293 if (wq) { 299 if (wq) {
294 *wait = wq; 300 *wait = wq;
@@ -389,7 +395,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
389 395
390 ret = validate_request(&wq, sbi, &qstr, dentry, notify); 396 ret = validate_request(&wq, sbi, &qstr, dentry, notify);
391 if (ret <= 0) { 397 if (ret <= 0) {
392 if (ret == 0) 398 if (ret != -EINTR)
393 mutex_unlock(&sbi->wq_mutex); 399 mutex_unlock(&sbi->wq_mutex);
394 kfree(qstr.name); 400 kfree(qstr.name);
395 return ret; 401 return ret;