android_kernel_motorola_sm6375/kernel/sched
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Eric Biggers e0c03d15cd wait: add wake_up_pollfree()
commit 42288cb44c4b5fff7653bc392b583a2b8bd6a8c0 upstream.

Several ->poll() implementations are special in that they use a
waitqueue whose lifetime is the current task, rather than the struct
file as is normally the case.  This is okay for blocking polls, since a
blocking poll occurs within one task; however, non-blocking polls
require another solution.  This solution is for the queue to be cleared
before it is freed, using 'wake_up_poll(wq, EPOLLHUP | POLLFREE);'.

However, that has a bug: wake_up_poll() calls __wake_up() with
nr_exclusive=1.  Therefore, if there are multiple "exclusive" waiters,
and the wakeup function for the first one returns a positive value, only
that one will be called.  That's *not* what's needed for POLLFREE;
POLLFREE is special in that it really needs to wake up everyone.

Considering the three non-blocking poll systems:

- io_uring poll doesn't handle POLLFREE at all, so it is broken anyway.

- aio poll is unaffected, since it doesn't support exclusive waits.
  However, that's fragile, as someone could add this feature later.

- epoll doesn't appear to be broken by this, since its wakeup function
  returns 0 when it sees POLLFREE.  But this is fragile.

Although there is a workaround (see epoll), it's better to define a
function which always sends POLLFREE to all waiters.  Add such a
function.  Also make it verify that the queue really becomes empty after
all waiters have been woken up.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20211209010455.42744-2-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-12-14 14:49:02 +01:00
..
autogroup.c
autogroup.h
clock.c
completion.c
core.c sched/uclamp: Fix rq->uclamp_max not set on first enqueue 2021-12-08 09:01:13 +01:00
cpuacct.c
cpudeadline.c
cpudeadline.h
cpufreq.c
cpufreq_schedutil.c cpufreq: schedutil: Use kobject release() method to free sugov_tunables 2021-10-06 15:42:29 +02:00
cpupri.c
cpupri.h
cputime.c
deadline.c sched/deadline: Fix missing clock update in migrate_task_rq_dl() 2021-09-15 09:47:26 +02:00
debug.c sched/debug: Fix cgroup_path[] serialization 2021-05-14 09:44:26 +02:00
fair.c kthread: Fix PF_KTHREAD vs to_kthread() race 2021-09-12 08:56:39 +02:00
features.h
idle.c rcu/nocb: Perform deferred wake up before last idle's need_resched() check 2021-03-04 10:26:47 +01:00
isolation.c
loadavg.c timers/nohz: Update NOHZ load in remote tick 2020-03-05 16:43:36 +01:00
Makefile
membarrier.c sched/membarrier: fix missing local execution of ipi_sync_rq_state() 2021-03-17 17:03:57 +01:00
pelt.c
pelt.h
psi.c sched/psi: Fix OOB write when writing 0 bytes to PSI files 2020-02-28 17:22:21 +01:00
rt.c sched/rt: Fix RT utilization tracking during policy change 2021-07-14 16:53:24 +02:00
sched-pelt.h
sched.h sched/deadline: Fix reset_on_fork reporting of DL tasks 2021-09-15 09:47:26 +02:00
stats.c
stats.h
stop_task.c
swait.c
topology.c sched: correct SD_flags returned by tl->sd_flags() 2020-08-19 08:15:54 +02:00
wait.c wait: add wake_up_pollfree() 2021-12-14 14:49:02 +01:00
wait_bit.c