Skip to content

Commit

Permalink
autofs4: check kernel communication pipe is valid for write
Browse files Browse the repository at this point in the history
It is possible for an autofs mount to become catatonic (and for the daemon
communication pipe to become NULL) after a wait has been initiallized but
before the request has been sent to the daemon.  We need to check for this
before sending the request packet.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
raven-au authored and torvalds committed Jul 24, 2008
1 parent f4c7da0 commit e64be33
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions fs/autofs4/waitq.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
union autofs_packet_union v4_pkt;
union autofs_v5_packet_union v5_pkt;
} pkt;
struct file *pipe = NULL;
size_t pktsz;

DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d",
Expand Down Expand Up @@ -164,8 +165,19 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
return;
}

if (autofs4_write(sbi->pipe, &pkt, pktsz))
autofs4_catatonic_mode(sbi);
/* Check if we have become catatonic */
mutex_lock(&sbi->wq_mutex);
if (!sbi->catatonic) {
pipe = sbi->pipe;
get_file(pipe);
}
mutex_unlock(&sbi->wq_mutex);

if (pipe) {
if (autofs4_write(pipe, &pkt, pktsz))
autofs4_catatonic_mode(sbi);
fput(pipe);
}
}

static int autofs4_getpath(struct autofs_sb_info *sbi,
Expand Down

0 comments on commit e64be33

Please sign in to comment.