NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/44093: puffs is too sensitive to signal



>Number:         44093
>Category:       kern
>Synopsis:       puffs is too sensitive to signal
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 15 15:20:01 +0000 2010
>Originator:     YAMAMOTO Takashi
>Release:        NetBSD-current
>Organization:
        
>Environment:
        
>Description:
        puffs is too sensitive to signal.
        filesystem operations should not be interrupted by arbitrary signals.
>How-To-Repeat:
        "git clone" to a puffs-based filesystem and see "write error".
>Fix:

Index: puffs_msgif.c
===================================================================
RCS file: /cvsroot/src/sys/fs/puffs/puffs_msgif.c,v
retrieving revision 1.83
diff -u -p -r1.83 puffs_msgif.c
--- puffs_msgif.c       12 Nov 2010 17:46:09 -0000      1.83
+++ puffs_msgif.c       15 Nov 2010 15:13:20 -0000
@@ -378,17 +378,30 @@ puffs_msg_enqueue(struct puffs_mount *pm
        if (__predict_false((park->park_flags & PARKFLAG_WANTREPLY)
           && (park->park_flags & PARKFLAG_CALL) == 0
           && (l->l_flag & LW_PENDSIG) != 0 && sigispending(l, 0))) {
-               park->park_flags |= PARKFLAG_HASERROR;
-               preq->preq_rv = EINTR;
-               if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN
-                   && (preq->preq_optype == PUFFS_VN_INACTIVE
-                    || preq->preq_optype == PUFFS_VN_RECLAIM)) {
-                       park->park_preq->preq_opclass |= PUFFSOPFLAG_FAF;
-                       park->park_flags &= ~PARKFLAG_WANTREPLY;
-                       DPRINTF(("puffs_msg_enqueue: converted to FAF %p\n",
-                           park));
-               } else {
-                       return;
+               sigset_t ss;
+
+               /*
+                * see the comment about signals in puffs_msg_wait.
+                */
+               sigpending1(l, &ss);
+               if (sigismember(&ss, SIGINT) ||
+                   sigismember(&ss, SIGTERM) ||
+                   sigismember(&ss, SIGKILL) ||
+                   sigismember(&ss, SIGHUP) ||
+                   sigismember(&ss, SIGQUIT)) {
+                       park->park_flags |= PARKFLAG_HASERROR;
+                       preq->preq_rv = EINTR;
+                       if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN
+                           && (preq->preq_optype == PUFFS_VN_INACTIVE
+                            || preq->preq_optype == PUFFS_VN_RECLAIM)) {
+                               park->park_preq->preq_opclass |=
+                                   PUFFSOPFLAG_FAF;
+                               park->park_flags &= ~PARKFLAG_WANTREPLY;
+                               DPRINTF(("puffs_msg_enqueue: "
+                                   "converted to FAF %p\n", park));
+                       } else {
+                               return;
+                       }
                }
        }
 
@@ -426,10 +439,30 @@ puffs_msg_enqueue(struct puffs_mount *pm
 int
 puffs_msg_wait(struct puffs_mount *pmp, struct puffs_msgpark *park)
 {
+       lwp_t *l = curlwp;
+       proc_t *p = l->l_proc;
        struct puffs_req *preq = park->park_preq; /* XXX: hmmm */
+       sigset_t ss;
+       sigset_t oss;
        int error = 0;
        int rv;
 
+       /*
+        * block unimportant signals.
+        *
+        * The set of "important" signals here was chosen to be same as
+        * nfs interruptible mount.
+        */
+       sigfillset(&ss);
+       sigdelset(&ss, SIGINT);
+       sigdelset(&ss, SIGTERM);
+       sigdelset(&ss, SIGKILL);
+       sigdelset(&ss, SIGHUP);
+       sigdelset(&ss, SIGQUIT);
+       mutex_enter(p->p_lock);
+       sigprocmask1(l, SIG_BLOCK, &ss, &oss);
+       mutex_exit(p->p_lock);
+
        mutex_enter(&pmp->pmp_lock);
        puffs_mp_reference(pmp);
        mutex_exit(&pmp->pmp_lock);
@@ -503,6 +536,10 @@ puffs_msg_wait(struct puffs_mount *pmp, 
        puffs_mp_release(pmp);
        mutex_exit(&pmp->pmp_lock);
 
+       mutex_enter(p->p_lock);
+       sigprocmask1(l, SIG_SETMASK, &oss, NULL);
+       mutex_exit(p->p_lock);
+
        return rv;
 }
 

>Unformatted:
        
        


Home | Main Index | Thread Index | Old Index