Skip to content

Commit

Permalink
freebsd/libshare: nfs: don't send SIGHUP to all processes
Browse files Browse the repository at this point in the history
pidfile_open() sets *pidptr to -1 if the process currently holding
the lock is between pidfile_open() and pidfile_write(),
the subsequent kill(mountdpid) would potentially SIGHUP all
non-system processes except init: just sleep for half a millisecond
and try again in that case

Reviewed-by: Don Brady <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: John Kennedy <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes openzfs#12067
  • Loading branch information
nabijaczleweli authored and Ryan Moeller committed Jan 18, 2022
1 parent 9279b29 commit 7fc49ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/libshare/os/freebsd/nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,22 @@ nfs_commit_shares(void)
struct pidfh *pfh;
pid_t mountdpid;

start:
pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid);
if (pfh != NULL) {
/* Mountd is not running. */
/* mountd(8) is not running. */
pidfile_remove(pfh);
return (SA_OK);
}
if (errno != EEXIST) {
/* Cannot open pidfile for some reason. */
return (SA_SYSTEM_ERR);
}
if (mountdpid == -1) {
/* mountd(8) exists, but didn't write the PID yet */
usleep(500);
goto start;
}
/* We have mountd(8) PID in mountdpid variable. */
kill(mountdpid, SIGHUP);
return (SA_OK);
Expand Down

0 comments on commit 7fc49ae

Please sign in to comment.