Go to file
Oleg Nesterov c649c46fc4 ipc/mqueue.c: change __do_notify() to bypass check_kill_permission()
commit b5f2006144c6ae941726037120fa1001ddede784 upstream.

Commit cc731525f26a ("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;
	}

[manfred@colorfullife.com: 1) Add self_exec_id evaluation so that the implementation matches do_notify_parent 2) use PIDTYPE_TGID everywhere]
Fixes: cc731525f26a ("signal: Remove kernel interal si_code magic")
Reported-by: Yoji <yoji.fujihar.min@gmail.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Markus Elfring <elfring@users.sourceforge.net>
Cc: <1vier1@web.de>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/e2a782e4-eab9-4f5c-c749-c07a8f7a4e66@colorfullife.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-16 16:27:39 +08:00
Documentation USB: hub: Revert commit bd0e6c9614b9 ("usb: hub: try old enumeration scheme first for high speed devices") 2021-03-16 16:26:56 +08:00
LICENSES Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
arch arm64: hugetlb: avoid potential NULL dereference 2021-03-16 16:27:39 +08:00
block blk-mq: Put driver tag in blk_mq_dispatch_rq_list() when no budget 2021-03-16 16:27:15 +08:00
certs Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
crypto crypto: rng - Fix a refcounting bug in crypto_rng_reset() 2021-03-16 16:26:09 +08:00
drivers drm: ingenic-drm: add MODULE_DEVICE_TABLE 2021-03-16 16:27:39 +08:00
fs cifs: do not share tcons with DFS 2021-03-16 16:27:28 +08:00
include tunnel: Propagate ECT(1) when decapsulating as recommended by RFC6040 2021-03-16 16:27:35 +08:00
init printk: queue wake_up_klogd irq_work only if per-CPU areas are ready 2021-03-16 16:27:05 +08:00
ipc ipc/mqueue.c: change __do_notify() to bypass check_kill_permission() 2021-03-16 16:27:39 +08:00
kernel tracing: Add a vmalloc_sync_mappings() for safe measure 2021-03-16 16:27:38 +08:00
lib lib: devres: add a helper function for ioremap_uc 2021-03-16 16:27:29 +08:00
mm mm/mremap: Add comment explaining the untagging behaviour of mremap() 2021-03-16 16:27:30 +08:00
net sctp: Fix bundling of SHUTDOWN with COOKIE-ACK 2021-03-16 16:27:37 +08:00
package config/arm64: OPEN CONFIG_PSI and phytium configs 2021-03-16 11:02:59 +08:00
samples vmalloc: fix remap_vmalloc_range() bounds checks 2021-03-16 16:26:56 +08:00
scripts scripts/config: allow colons in option strings for sed 2021-03-16 16:27:27 +08:00
security selinux: properly handle multiple messages in selinux_netlink_send() 2021-03-16 16:27:24 +08:00
sound ALSA: hda: Match both PCI ID and SSID for driver blacklist 2021-03-16 16:27:30 +08:00
tools tools headers UAPI: Sync copy of arm64's asm/unistd.h with the kernel sources 2021-03-16 16:27:31 +08:00
usr Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
virt KVM: arm64: Fix 32bit PC wrap-around 2021-03-16 16:27:39 +08:00
.clang-format Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
.cocciconfig Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
.get_maintainer.ignore Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
.gitattributes Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
.gitignore Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
COPYING Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
CREDITS Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Kbuild Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Kconfig Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
MAINTAINERS Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Makefile Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
README Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
README.md Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
backport_remove_lists.txt Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tools_key.pub Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00

README.md

Tencent Linux Kernel 4.0