fusefs: interruptibility improvements suggested by kib

* Block stop signals in fticket_wait_answer
* Hold ps_mtx while checking signal disposition
* style(9) changes

PR:		346357
Reported by:	kib
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-04-24 15:54:18 +00:00
parent 9a17702912
commit ebbfe00ec2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=346640
2 changed files with 10 additions and 6 deletions

View File

@ -430,10 +430,11 @@ fticket_wait_answer(struct fuse_ticket *ftick)
{
struct thread *td = curthread;
sigset_t blockedset, oldset;
int err = 0;
int err = 0, stops_deferred;
struct fuse_data *data;
SIGEMPTYSET(blockedset);
SIGEMPTYSET(blockedset);
stops_deferred = sigdeferstop(SIGDEFERSTOP_SILENT);
kern_sigprocmask(td, SIG_BLOCK, NULL, &oldset, 0);
fuse_lck_mtx_lock(ftick->tk_aw_mtx);
@ -476,6 +477,7 @@ fticket_wait_answer(struct fuse_ticket *ftick)
* or EAGAIN to the interrupt.
*/
int sig;
bool fatal;
SDT_PROBE2(fusefs, , ipc, trace, 4,
"fticket_wait_answer: interrupt");
@ -485,11 +487,12 @@ fticket_wait_answer(struct fuse_ticket *ftick)
PROC_LOCK(td->td_proc);
mtx_lock(&td->td_proc->p_sigacts->ps_mtx);
sig = cursig(td);
fatal = sig_isfatal(td->td_proc, sig);
mtx_unlock(&td->td_proc->p_sigacts->ps_mtx);
PROC_UNLOCK(td->td_proc);
fuse_lck_mtx_lock(ftick->tk_aw_mtx);
if (!sig_isfatal(td->td_proc, sig)) {
if (!fatal) {
/*
* Block the just-delivered signal while we wait for an
* interrupt response
@ -512,6 +515,7 @@ fticket_wait_answer(struct fuse_ticket *ftick)
err = ENXIO;
}
fuse_lck_mtx_unlock(ftick->tk_aw_mtx);
sigallowstop(stops_deferred);
return err;
}

View File

@ -929,16 +929,16 @@ osigreturn(struct thread *td, struct osigreturn_args *uap)
#endif
#endif /* COMPAT_43 */
/* Will this signal be fatal to the current process ? */
/* Would this signal be fatal to the current process, if it were caught ? */
bool
sig_isfatal(struct proc *p, int sig)
{
intptr_t act;
int prop;
mtx_assert(&p->p_sigacts->ps_mtx, MA_OWNED);
act = (intptr_t)p->p_sigacts->ps_sigact[_SIG_IDX(sig)];
if ((intptr_t)SIG_DFL == act) {
int prop;
prop = sigprop(sig);
return (0 != (prop & (SIGPROP_KILL | SIGPROP_CORE)));
} else {