sigqueue: In capability mode, only allow signalling self
This is copied from the check in kern_kill. Approved by: so Security: FreeBSD-SA-26:28.capsicum Security: CVE-2026-45259 Reviewed by: markj, oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57244 (cherry picked from commit b9d16b7fd2fa6bc4b3e8364804cbdc1b76ebe8a5) (cherry picked from commit defd9b86ef995ce70363eae9b323d616bda865be) (cherry picked from commit d11ff01b3aec336128e6babbff7a421fbce82015)
This commit is contained in:
parent
564070c417
commit
a6716e8cb1
2 changed files with 19 additions and 3 deletions
|
|
@ -747,8 +747,8 @@ FORK_TEST(Capmode, NewThread) {
|
|||
close(thread_pipe[1]);
|
||||
}
|
||||
|
||||
static volatile sig_atomic_t had_signal = 0;
|
||||
static void handle_signal(int) { had_signal = 1; }
|
||||
static volatile sig_atomic_t signal_cnt = 0;
|
||||
static void handle_signal(int) { signal_cnt++; }
|
||||
|
||||
FORK_TEST(Capmode, SelfKill) {
|
||||
pid_t me = getpid();
|
||||
|
|
@ -766,7 +766,13 @@ FORK_TEST(Capmode, SelfKill) {
|
|||
// Can only kill(2) to own pid.
|
||||
EXPECT_CAPMODE(kill(child, SIGUSR1));
|
||||
EXPECT_OK(kill(me, SIGUSR1));
|
||||
EXPECT_EQ(1, had_signal);
|
||||
EXPECT_EQ(1, signal_cnt);
|
||||
|
||||
union sigval sv;
|
||||
sv.sival_int = 0x1234;
|
||||
EXPECT_CAPMODE(sigqueue(child, SIGUSR1, sv));
|
||||
EXPECT_OK(sigqueue(me, SIGUSR1, sv));
|
||||
EXPECT_EQ(2, signal_cnt);
|
||||
|
||||
signal(SIGUSR1, original);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2041,6 +2041,16 @@ kern_sigqueue(struct thread *td, pid_t pid, int signumf, union sigval *value)
|
|||
if (pid <= 0)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* A process in capability mode can send signals only to itself.
|
||||
*/
|
||||
if (pid != td->td_proc->p_pid) {
|
||||
if (CAP_TRACING(td))
|
||||
ktrcapfail(CAPFAIL_SIGNAL, &signum);
|
||||
if (IN_CAPABILITY_MODE(td))
|
||||
return (ECAPMODE);
|
||||
}
|
||||
|
||||
if ((signumf & __SIGQUEUE_TID) == 0) {
|
||||
if ((p = pfind_any(pid)) == NULL)
|
||||
return (ESRCH);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue