aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2012-11-27 10:22:40 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2012-11-27 10:22:40 +0000
commit8890f5d020567d7c82cdf9051bafd0610cc75ffe (patch)
treef06915591c05c31a4cb30e1119662eddc2c2f658 /sys/kern/kern_sig.c
parentb62d05fcf98af783df851ad05904ebbd49f04116 (diff)
downloadsrc-8890f5d020567d7c82cdf9051bafd0610cc75ffe.tar.gz
src-8890f5d020567d7c82cdf9051bafd0610cc75ffe.zip
Allow to use kill(2) in capability mode, but process can send a signal only
to himself. For example abort(3) at first tries to do kill(getpid(), SIGABRT) which was failing in capability mode, so the code was failing back to exit(1). Reviewed by: rwatson Obtained from: WHEEL Systems MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=243610
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 56597ea871e6..a0b5809f1c2a 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1679,6 +1679,14 @@ sys_kill(struct thread *td, struct kill_args *uap)
struct proc *p;
int error;
+ /*
+ * A process in capability mode can send signals only to himself.
+ * The main rationale behind this is that abort(3) is implemented as
+ * kill(getpid(), SIGABRT).
+ */
+ if (IN_CAPABILITY_MODE(td) && uap->pid != td->td_proc->p_pid)
+ return (ECAPMODE);
+
AUDIT_ARG_SIGNUM(uap->signum);
AUDIT_ARG_PID(uap->pid);
if ((u_int)uap->signum > _SIG_MAXSIG)