linux-stable/include
David Howells ad26df1875 certs: Fix blacklist flag type confusion
[ Upstream commit 4993e1f947 ]

KEY_FLAG_KEEP is not meant to be passed to keyring_alloc() or key_alloc(),
as these only take KEY_ALLOC_* flags.  KEY_FLAG_KEEP has the same value as
KEY_ALLOC_BYPASS_RESTRICTION, but fortunately only key_create_or_update()
uses it.  LSMs using the key_alloc hook don't check that flag.

KEY_FLAG_KEEP is then ignored but fortunately (again) the root user cannot
write to the blacklist keyring, so it is not possible to remove a key/hash
from it.

Fix this by adding a KEY_ALLOC_SET_KEEP flag that tells key_alloc() to set
KEY_FLAG_KEEP on the new key.  blacklist_init() can then, correctly, pass
this to keyring_alloc().

We can also use this in ima_mok_init() rather than setting the flag
manually.

Note that this doesn't fix an observable bug with the current
implementation but it is required to allow addition of new hashes to the
blacklist in the future without making it possible for them to be removed.

Fixes: 734114f878 ("KEYS: Add a system blacklist keyring")
Reported-by: Mickaël Salaün <mic@linux.microsoft.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Mickaël Salaün <mic@linux.microsoft.com>
cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-03 18:22:46 +01:00
..
acpi PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup() 2020-12-29 13:47:04 +01:00
asm-generic vmlinux.lds.h: add DWARF v5 sections 2021-03-03 18:22:36 +01:00
clocksource
crypto crypto: af_alg - fix use-after-free in af_alg_accept() due to bh_lock_sock() 2020-07-09 09:36:30 +02:00
drm drm: mst: Fix query_payload ack reply struct 2019-12-31 12:36:46 +01:00
dt-bindings dt-bindings: reset: meson8b: fix duplicate reset IDs 2020-01-23 08:20:29 +01:00
keys KEYS: Don't write out to userspace while holding key semaphore 2020-04-24 08:01:25 +02:00
kvm KVM: arm/arm64: Sync ICH_VMCR_EL2 back when about to block 2019-08-25 10:50:18 +02:00
linux certs: Fix blacklist flag type confusion 2021-03-03 18:22:46 +01:00
math-emu math-emu/soft-fp.h: (_FP_ROUND_ZERO) cast 0 to void to fix warning 2019-12-17 20:38:02 +01:00
media media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros 2020-02-28 16:36:00 +01:00
memory
misc
net tcp: fix TLP timer not set when CA_STATE changes from DISORDER to OPEN 2021-02-03 23:22:23 +01:00
pcmcia
ras
rdma IB/mlx4: Avoid implicit enumerated type conversion 2019-11-24 08:23:05 +01:00
scsi scsi: libiscsi: Fix NOP race condition 2020-12-02 08:34:42 +01:00
soc irqchip/eznps: Fix build error for !ARC700 builds 2020-09-23 10:46:27 +02:00
sound ALSA: compress: fix partial_drain completion state 2020-07-22 09:22:17 +02:00
target scsi: target: fix hang when multiple threads try to destroy the same iscsi session 2020-04-24 08:00:58 +02:00
trace memcg: fix a crash in wb_workfn when a device disappears 2021-02-23 14:00:30 +01:00
uapi uapi: move constants from <linux/kernel.h> to <linux/const.h> 2021-01-09 13:37:37 +01:00
video
xen Xen/gntdev: correct error checking in gntdev_map_grant_pages() 2021-02-23 14:00:33 +01:00