linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org
Subject: [PATCH AUTOSEL 5.8 57/72] seccomp: Fix ioctl number for SECCOMP_IOCTL_NOTIF_ID_VALID
Date: Sat,  8 Aug 2020 19:35:26 -0400	[thread overview]
Message-ID: <20200808233542.3617339-57-sashal@kernel.org> (raw)
In-Reply-To: <20200808233542.3617339-1-sashal@kernel.org>

From: Kees Cook <keescook@chromium.org>

[ Upstream commit 47e33c05f9f07cac3de833e531bcac9ae052c7ca ]

When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced it had the wrong
direction flag set. While this isn't a big deal as nothing currently
enforces these bits in the kernel, it should be defined correctly. Fix
the define and provide support for the old command until it is no longer
needed for backward compatibility.

Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace")
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/uapi/linux/seccomp.h                  | 3 ++-
 kernel/seccomp.c                              | 9 +++++++++
 tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h
index c1735455bc536..965290f7dcc28 100644
--- a/include/uapi/linux/seccomp.h
+++ b/include/uapi/linux/seccomp.h
@@ -123,5 +123,6 @@ struct seccomp_notif_resp {
 #define SECCOMP_IOCTL_NOTIF_RECV	SECCOMP_IOWR(0, struct seccomp_notif)
 #define SECCOMP_IOCTL_NOTIF_SEND	SECCOMP_IOWR(1,	\
 						struct seccomp_notif_resp)
-#define SECCOMP_IOCTL_NOTIF_ID_VALID	SECCOMP_IOR(2, __u64)
+#define SECCOMP_IOCTL_NOTIF_ID_VALID	SECCOMP_IOW(2, __u64)
+
 #endif /* _UAPI_LINUX_SECCOMP_H */
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index d653d8426de90..c461ba9925136 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -42,6 +42,14 @@
 #include <linux/uaccess.h>
 #include <linux/anon_inodes.h>
 
+/*
+ * When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced, it had the
+ * wrong direction flag in the ioctl number. This is the broken one,
+ * which the kernel needs to keep supporting until all userspaces stop
+ * using the wrong command number.
+ */
+#define SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR	SECCOMP_IOR(2, __u64)
+
 enum notify_state {
 	SECCOMP_NOTIFY_INIT,
 	SECCOMP_NOTIFY_SENT,
@@ -1186,6 +1194,7 @@ static long seccomp_notify_ioctl(struct file *file, unsigned int cmd,
 		return seccomp_notify_recv(filter, buf);
 	case SECCOMP_IOCTL_NOTIF_SEND:
 		return seccomp_notify_send(filter, buf);
+	case SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR:
 	case SECCOMP_IOCTL_NOTIF_ID_VALID:
 		return seccomp_notify_id_valid(filter, buf);
 	default:
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 252140a525531..ccf276e138829 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -180,7 +180,7 @@ struct seccomp_metadata {
 #define SECCOMP_IOCTL_NOTIF_RECV	SECCOMP_IOWR(0, struct seccomp_notif)
 #define SECCOMP_IOCTL_NOTIF_SEND	SECCOMP_IOWR(1,	\
 						struct seccomp_notif_resp)
-#define SECCOMP_IOCTL_NOTIF_ID_VALID	SECCOMP_IOR(2, __u64)
+#define SECCOMP_IOCTL_NOTIF_ID_VALID	SECCOMP_IOW(2, __u64)
 
 struct seccomp_notif {
 	__u64 id;
-- 
2.25.1


  parent reply	other threads:[~2020-08-08 23:49 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-08 23:34 [PATCH AUTOSEL 5.8 01/72] ARM: dts: stm32: fix uart nodes ordering in stm32mp15-pinctrl Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 02/72] ARM: dts: stm32: fix uart7_pins_a comments " Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 03/72] x86/mce/inject: Fix a wrong assignment of i_mce.status Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 04/72] perf/x86/intel/uncore: Fix oops when counting IMC uncore events on some TGL Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 05/72] x86, sched: check for counters overflow in frequency invariant accounting Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 06/72] x86, sched: Bail out of frequency invariance if turbo frequency is unknown Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 07/72] x86, sched: Bail out of frequency invariance if turbo_freq/base_freq gives 0 Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 08/72] sched/fair: Fix NOHZ next idle balance Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 09/72] sched: correct SD_flags returned by tl->sd_flags() Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 10/72] arm64: dts: rockchip: fix rk3368-lion gmac reset gpio Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 11/72] arm64: dts: rockchip: fix rk3399-puma vcc5v0-host gpio Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 12/72] arm64: dts: rockchip: fix rk3399-puma gmac reset gpio Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 13/72] EDAC: Fix reference count leaks Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 14/72] crc-t10dif: Fix potential crypto notify dead-lock Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 15/72] arm64: dts: qcom: msm8916: Replace invalid bias-pull-none property Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 16/72] memory: tegra: Fix an error handling path in tegra186_emc_probe() Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 17/72] blktrace: fix debugfs use after free Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 18/72] soc: qcom: rpmh-rsc: Don't use ktime for timeout in write_tcs_reg_sync() Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 19/72] crypto: ccree - fix resource leak on error path Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 20/72] ARM: exynos: MCPM: Restore big.LITTLE cpuidle support Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 21/72] rcu/tree: Repeat the monitor if any free channel is busy Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 22/72] firmware: arm_scmi: Fix SCMI genpd domain probing Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 23/72] arm64: dts: sun50i-pinephone: dldo4 must not be >= 1.8V Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 24/72] arm64: dts: exynos: Fix silent hang after boot on Espresso Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 25/72] sched/uclamp: Fix initialization of struct uclamp_rq Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 26/72] crypto: qat - allow xts requests not multiple of block Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 27/72] clk: scmi: Fix min and max rate when registering clocks with discrete rates Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 28/72] m68k: mac: Don't send IOP message until channel is idle Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 29/72] m68k: mac: Fix IOP status/control register writes Sasha Levin
2020-08-08 23:34 ` [PATCH AUTOSEL 5.8 30/72] platform/x86: intel-hid: Fix return value check in check_acpi_dev() Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 31/72] platform/x86: intel-vbtn: " Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 32/72] ARM: dts: gose: Fix ports node name for adv7180 Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 33/72] arm64: dts: renesas: Fix SD Card/eMMC interface device node names Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 34/72] ARM: dts: gose: Fix ports node name for adv7612 Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 35/72] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init() Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 36/72] ARM: dts: exynos: Disable frequency scaling for FSYS bus on Odroid XU3 family Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 37/72] reset: intel: fix a compile warning about REG_OFFSET redefined Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 38/72] ARM: dts: at91: sama5d3_xplained: change phy-mode Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 39/72] ARM: dts: sunxi: bananapi-m2-plus-v1.2: Add regulator supply to all CPU cores Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 40/72] ARM: dts: sunxi: bananapi-m2-plus-v1.2: Fix CPU supply voltages Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 41/72] ARM: dts: stm32: Fix spi4 pins in stm32mp15-pinctrl Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 42/72] spi: dw-dma: Fix Tx DMA channel working too fast Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 43/72] spi: lantiq: fix: Rx overflow error in full duplex mode Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 44/72] crypto: x86/crc32c - fix building with clang ias Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 45/72] tpm: Require that all digests are present in TCG_PCR_EVENT2 structures Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 46/72] recordmcount: only record relocation of type R_AARCH64_CALL26 on arm64 Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 47/72] regulator: fix memory leak on error path of regulator_register() Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 48/72] io_uring: fix sq array offset calculation Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 49/72] arm64: dts: meson: misc fixups for w400 dtsi Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 50/72] arm64: dts: meson: fix mmc0 tuning error on Khadas VIM3 Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 51/72] soc: qcom: pdr: Reorder the PD state indication ack Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 52/72] spi: rockchip: Fix error in SPI slave pio read Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 53/72] ARM: socfpga: PM: add missing put_device() call in socfpga_setup_ocram_self_refresh() Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 54/72] iocost: Fix check condition of iocg abs_vdebt Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 55/72] scripts/selinux/mdp: fix initial SID handling Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 56/72] irqchip/ti-sci-inta: Fix return value about devm_ioremap_resource() Sasha Levin
2020-08-08 23:35 ` Sasha Levin [this message]
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 58/72] md: raid0/linear: fix dereference before null check on pointer mddev Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 59/72] irqchip/loongson-htvec: Fix potential resource leak Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 60/72] irqchip/loongson-htvec: Check return value of irq_domain_translate_onecell() Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 61/72] irqchip/loongson-pch-pic: Check return value of irq_domain_translate_twocell() Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 62/72] irqchip/loongson-liointc: Fix potential dead lock Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 63/72] kunit: tool: fix broken default args in unit tests Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 64/72] kunit: tool: fix improper treatment of file location Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 65/72] irqchip/irq-bcm7038-l1: Guard uses of cpu_logical_map Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 66/72] irqchip/gic-v4.1: Use GFP_ATOMIC flag in allocate_vpe_l1_table() Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 67/72] nvme-tcp: fix controller reset hang during traffic Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 68/72] nvme-rdma: " Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 69/72] nvme-multipath: fix logic for non-optimized paths Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 70/72] nvme-multipath: do not fall back to __nvme_find_path() " Sasha Levin
2020-08-10 15:37   ` Martin Wilck
2020-08-16 13:50     ` Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 71/72] irqchip/loongson-pch-pic: Fix the misused irq flow handler Sasha Levin
2020-08-08 23:35 ` [PATCH AUTOSEL 5.8 72/72] block: don't do revalidate zones on invalid devices Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200808233542.3617339-57-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).