Oleg Nesterov
1f3aa3e028
ipc/mqueue.c: change __do_notify() to bypass check_kill_permission()
commit b5f2006144c6ae941726037120fa1001ddede784 upstream.
Commit cc731525f2 ("signal: Remove kernel interal si_code magic")
changed the value of SI_FROMUSER(SI_MESGQ), this means that mq_notify() no
longer works if the sender doesn't have rights to send a signal.
Change __do_notify() to use do_send_sig_info() instead of kill_pid_info()
to avoid check_kill_permission().
This needs the additional notify.sigev_signo != 0 check, shouldn't we
change do_mq_notify() to deny sigev_signo == 0 ?
Test-case:
#include <signal.h>
#include <mqueue.h>
#include <unistd.h>
#include <sys/wait.h>
#include <assert.h>
static int notified;
static void sigh(int sig)
{
notified = 1;
}
int main(void)
{
signal(SIGIO, sigh);
int fd = mq_open("/mq", O_RDWR|O_CREAT, 0666, NULL);
assert(fd >= 0);
struct sigevent se = {
.sigev_notify = SIGEV_SIGNAL,
.sigev_signo = SIGIO,
};
assert(mq_notify(fd, &se) == 0);
if (!fork()) {
assert(setuid(1) == 0);
mq_send(fd, "",1,0);
return 0;
}
wait(NULL);
mq_unlink("/mq");
assert(notified);
return 0;
}
[[email protected]: 1) Add self_exec_id evaluation so that the implementation matches do_notify_parent 2) use PIDTYPE_TGID everywhere]
Fixes: cc731525f2 ("signal: Remove kernel interal si_code magic")
Reported-by: Yoji <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
Signed-off-by: Manfred Spraul <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: "Eric W. Biederman" <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Markus Elfring <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
2020-05-14 07:58:26 +02:00 |
| .. |
|
compat.c
|
|
|
|
ipc_sysctl.c
|
proc/sysctl: add shared variables for range check
|
2019-07-18 17:08:07 -07:00 |
|
Makefile
|
|
|
|
mq_sysctl.c
|
|
|
|
mqueue.c
|
ipc/mqueue.c: change __do_notify() to bypass check_kill_permission()
|
2020-05-14 07:58:26 +02:00 |
|
msg.c
|
ipc/msg.c: consolidate all xxxctl_down() functions
|
2020-02-11 04:35:07 -08:00 |
|
msgutil.c
|
|
|
|
namespace.c
|
|
|
|
sem.c
|
Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()"
|
2020-02-28 17:22:20 +01:00 |
|
shm.c
|
|
|
|
syscall.c
|
|
|
|
util.c
|
ipc/util.c: sysvipc_find_ipc() should increase position index
|
2020-04-29 16:33:00 +02:00 |
|
util.h
|
ipc: fix sparc64 ipc() wrapper
|
2019-09-07 21:42:25 +02:00 |