[BACK]Return to linux_signal.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / compat / linux / common

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/compat/linux/common/linux_signal.c between version 1.58 and 1.58.6.3

version 1.58, 2007/12/20 23:02:56 version 1.58.6.3, 2009/01/17 13:28:45
Line 15 
Line 15 
  * 2. Redistributions in binary form must reproduce the above copyright   * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the   *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.   *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software  
  *    must display the following acknowledgement:  
  *      This product includes software developed by the NetBSD  
  *      Foundation, Inc. and its contributors.  
  * 4. Neither the name of The NetBSD Foundation nor the names of its  
  *    contributors may be used to endorse or promote products derived  
  *    from this software without specific prior written permission.  
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS   * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
Line 89  __KERNEL_RCSID(0, "$NetBSD$");
Line 82  __KERNEL_RCSID(0, "$NetBSD$");
 /* Locally used defines (in bsd<->linux conversion functions): */  /* Locally used defines (in bsd<->linux conversion functions): */
 #define linux_sigemptyset(s)    memset((s), 0, sizeof(*(s)))  #define linux_sigemptyset(s)    memset((s), 0, sizeof(*(s)))
 #define linux_sigismember(s, n) ((s)->sig[((n) - 1) / LINUX__NSIG_BPW]  \  #define linux_sigismember(s, n) ((s)->sig[((n) - 1) / LINUX__NSIG_BPW]  \
                                         & (1 << ((n) - 1) % LINUX__NSIG_BPW))                                          & (1L << ((n) - 1) % LINUX__NSIG_BPW))
 #define linux_sigaddset(s, n)   ((s)->sig[((n) - 1) / LINUX__NSIG_BPW]  \  #define linux_sigaddset(s, n)   ((s)->sig[((n) - 1) / LINUX__NSIG_BPW]  \
                                         |= (1 << ((n) - 1) % LINUX__NSIG_BPW))                                          |= (1L << ((n) - 1) % LINUX__NSIG_BPW))
   
 #ifdef DEBUG_LINUX  #ifdef DEBUG_LINUX
 #define DPRINTF(a)      uprintf a  #define DPRINTF(a)      uprintf a
Line 357  linux_sigprocmask1(struct lwp *l, int ho
Line 350  linux_sigprocmask1(struct lwp *l, int ho
                         return (error);                          return (error);
                 linux_old_to_native_sigset(&nbss, &nlss);                  linux_old_to_native_sigset(&nbss, &nlss);
         }          }
         mutex_enter(&p->p_smutex);          mutex_enter(p->p_lock);
         error = sigprocmask1(l, how,          error = sigprocmask1(l, how,
             set ? &nbss : NULL, oset ? &obss : NULL);              set ? &nbss : NULL, oset ? &obss : NULL);
         mutex_exit(&p->p_smutex);          mutex_exit(p->p_lock);
         if (error)          if (error)
                 return (error);                  return (error);
         if (oset) {          if (oset) {
Line 413  linux_sys_rt_sigprocmask(struct lwp *l, 
Line 406  linux_sys_rt_sigprocmask(struct lwp *l, 
                         return (error);                          return (error);
                 linux_to_native_sigset(&nbss, &nlss);                  linux_to_native_sigset(&nbss, &nlss);
         }          }
         mutex_enter(&p->p_smutex);          mutex_enter(p->p_lock);
         error = sigprocmask1(l, how,          error = sigprocmask1(l, how,
             set ? &nbss : NULL, oset ? &obss : NULL);              set ? &nbss : NULL, oset ? &obss : NULL);
         mutex_exit(&p->p_smutex);          mutex_exit(p->p_lock);
         if (!error && oset) {          if (!error && oset) {
                 native_to_linux_sigset(&olss, &obss);                  native_to_linux_sigset(&olss, &obss);
                 error = copyout(&olss, oset, sizeof(olss));                  error = copyout(&olss, oset, sizeof(olss));
Line 590  linux_sys_sigaltstack(struct lwp *l, con
Line 583  linux_sys_sigaltstack(struct lwp *l, con
                         return error;                          return error;
                 linux_to_native_sigaltstack(&nss, &ss);                  linux_to_native_sigaltstack(&nss, &ss);
   
                 mutex_enter(&p->p_smutex);                  mutex_enter(p->p_lock);
   
                 if (nss.ss_flags & ~SS_ALLBITS)                  if (nss.ss_flags & ~SS_ALLBITS)
                         error = EINVAL;                          error = EINVAL;
Line 603  linux_sys_sigaltstack(struct lwp *l, con
Line 596  linux_sys_sigaltstack(struct lwp *l, con
                 if (error == 0)                  if (error == 0)
                         l->l_sigstk = nss;                          l->l_sigstk = nss;
   
                 mutex_exit(&p->p_smutex);                  mutex_exit(p->p_lock);
         }          }
   
         return error;          return error;
Line 611  linux_sys_sigaltstack(struct lwp *l, con
Line 604  linux_sys_sigaltstack(struct lwp *l, con
 #endif /* LINUX_SS_ONSTACK */  #endif /* LINUX_SS_ONSTACK */
   
 #ifdef LINUX_NPTL  #ifdef LINUX_NPTL
   static int
   linux_do_tkill(struct lwp *l, int tgid, int tid, int signum)
   {
           struct proc *p;
           int error;
           ksiginfo_t ksi;
           struct linux_emuldata *led;
   
           if (signum < 0 || signum >= LINUX__NSIG)
                   return EINVAL;
           signum = linux_to_native_signo[signum];
   
           KSI_INIT(&ksi);
           ksi.ksi_signo = signum;
           ksi.ksi_code = SI_LWP;
           ksi.ksi_pid = l->l_proc->p_pid;
           ksi.ksi_uid = kauth_cred_geteuid(l->l_cred);
   
           mutex_enter(proc_lock);
           if ((p = p_find(tid, PFIND_LOCKED)) == NULL) {
                   mutex_exit(proc_lock);
                   return ESRCH;
           }
           led = p->p_emuldata;
           if (tgid > 0 && led->s->group_pid != tgid) {
                   mutex_exit(proc_lock);
                   return ESRCH;
           }
           mutex_enter(p->p_lock);
           error = kauth_authorize_process(l->l_cred,
               KAUTH_PROCESS_SIGNAL, p, KAUTH_ARG(signum), NULL, NULL);
           if (!error && signum)
                   kpsignal2(p, &ksi);
           mutex_exit(p->p_lock);
           mutex_exit(proc_lock);
   
           return error;
   }
   
 int  int
 linux_sys_tkill(struct lwp *l, const struct linux_sys_tkill_args *uap, register_t *retval)  linux_sys_tkill(struct lwp *l, const struct linux_sys_tkill_args *uap, register_t *retval)
 {  {
Line 618  linux_sys_tkill(struct lwp *l, const str
Line 650  linux_sys_tkill(struct lwp *l, const str
                 syscallarg(int) tid;                  syscallarg(int) tid;
                 syscallarg(int) sig;                  syscallarg(int) sig;
         } */          } */
         struct linux_sys_kill_args cup;  
   
         /* We use the PID as the TID ... */          if (SCARG(uap, tid) <= 0)
         SCARG(&cup, pid) = SCARG(uap, tid);                  return EINVAL;
         SCARG(&cup, signum) = SCARG(uap, sig);  
   
         return linux_sys_kill(l, &cup, retval);          return linux_do_tkill(l, 0, SCARG(uap, tid), SCARG(uap, sig));
 }  }
   
 int  int
Line 635  linux_sys_tgkill(struct lwp *l, const st
Line 665  linux_sys_tgkill(struct lwp *l, const st
                 syscallarg(int) tid;                  syscallarg(int) tid;
                 syscallarg(int) sig;                  syscallarg(int) sig;
         } */          } */
         struct linux_sys_kill_args cup;  
         struct linux_emuldata *led;  
         struct proc *p;  
   
         SCARG(&cup, pid) = SCARG(uap, tid);          if (SCARG(uap, tid) <= 0 || SCARG(uap, tgid) <= 0)
         SCARG(&cup, signum) = SCARG(uap, sig);                  return EINVAL;
   
         if (SCARG(uap, tgid) == -1)  
                 return linux_sys_kill(l, &cup, retval);  
   
         /* We use the PID as the TID, but make sure the group ID is right */  
         if ((p = pfind(SCARG(uap, tid))) == NULL)  
                 return ESRCH;  
   
         if (p->p_emul != &emul_linux)          return linux_do_tkill(l, SCARG(uap, tgid), SCARG(uap, tid), SCARG(uap, sig));
                 return ESRCH;  }
   
         led = p->p_emuldata;  int
   native_to_linux_si_code(int code)
   {
           int si_codes[] = {
               LINUX_SI_USER, LINUX_SI_QUEUE, LINUX_SI_TIMER, LINUX_SI_ASYNCIO,
               LINUX_SI_MESGQ, LINUX_SI_TKILL /* SI_LWP */
           };
   
         if (led->s->group_pid != SCARG(uap, tgid))          if (code <= 0 && -code < __arraycount(si_codes))
                 return ESRCH;                  return si_codes[-code];
   
         return linux_sys_kill(l, &cup, retval);          return code;
 }  }
 #endif /* LINUX_NPTL */  #endif /* LINUX_NPTL */

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.58.6.3

CVSweb <webmaster@jp.NetBSD.org>