linux-stable/include
Suren Baghdasaryan 2fd752ed77 psi: Fix uaf issue when psi trigger is destroyed while being polled
commit a06247c680 upstream.

With write operation on psi files replacing old trigger with a new one,
the lifetime of its waitqueue is totally arbitrary. Overwriting an
existing trigger causes its waitqueue to be freed and pending poll()
will stumble on trigger->event_wait which was destroyed.
Fix this by disallowing to redefine an existing psi trigger. If a write
operation is used on a file descriptor with an already existing psi
trigger, the operation will fail with EBUSY error.
Also bypass a check for psi_disabled in the psi_trigger_destroy as the
flag can be flipped after the trigger is created, leading to a memory
leak.

Fixes: 0e94682b73 ("psi: introduce psi monitor")
Reported-by: syzbot+cdb5dd11c97cc532efad@syzkaller.appspotmail.com
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Analyzed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220111232309.1786347-1-surenb@google.com
[surenb: backported to 5.4 kernel]
CC: stable@vger.kernel.org # 5.4
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-05 12:35:36 +01:00
..
acpi ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions 2022-01-27 09:19:45 +01:00
asm-generic tlb: mmu_gather: add tlb_flush_*_range APIs 2021-11-26 10:47:23 +01:00
clocksource
crypto crypto: public_key: fix overflow during implicit conversion 2021-09-22 12:26:21 +02:00
drm drm: Return -ENOTTY for non-drm ioctls 2021-07-28 13:31:01 +02:00
dt-bindings
keys certs: Add EFI_CERT_X509_GUID support for dbx entries 2021-06-30 08:47:55 -04:00
kvm
linux psi: Fix uaf issue when psi trigger is destroyed while being polled 2022-02-05 12:35:36 +01:00
math-emu
media media: subdev: disallow ioctl for saa6588/davinci 2021-07-19 08:53:17 +02:00
misc
net ipv4: remove sparse error in ip_neigh_gw4() 2022-02-01 17:24:39 +01:00
pcmcia
ras
rdma RDMA/netlink: Add __maybe_unused to static inline in C file 2021-11-26 10:47:18 +01:00
scsi scsi: iscsi: Fix conn use after free during resets 2021-07-20 16:10:43 +02:00
soc irqchip/eznps: Fix build error for !ARC700 builds 2020-09-17 13:47:47 +02:00
sound ALSA: hda: hdac_ext_stream: fix potential locking issues 2021-11-26 10:47:23 +01:00
target scsi: target: Fix ordered tag handling 2021-11-26 10:47:16 +01:00
trace f2fs: fix up f2fs_lookup tracepoints 2021-11-26 10:47:17 +01:00
uapi uapi: fix linux/nfc.h userspace compilation errors 2022-01-05 12:37:45 +01:00
vdso
video
xen xen: sync include/xen/interface/io/ring.h with Xen's newest version 2021-12-01 09:23:35 +01:00