[RFC PATCH for 5.4 0/7] Membarrier fixes and cleanups

From: Mathieu Desnoyers
Date: Thu Sep 19 2019 - 13:38:33 EST


Hi,

Those series of fixes and cleanups are initially motivated by the report
of race in membarrier, which can load p->mm->membarrier_state after mm
has been freed (use-after-free).

Thanks,

Mathieu

Mathieu Desnoyers (7):
Fix: sched/membarrier: Private expedited registration check
Cleanup: sched/membarrier: Remove redundant check
Cleanup: sched/membarrier: Only sync_core before usermode for same mm
Fix: sched/membarrier: p->mm->membarrier_state racy load (v4)
selftests: sched/membarrier: Add multi-threaded test
sched/membarrier: Skip IPIs when mm->mm_users == 1
sched/membarrier: Return -ENOMEM to userspace on memory allocation
failure

fs/exec.c | 2 +-
include/linux/mm_types.h | 14 +-
include/linux/sched/mm.h | 10 +-
kernel/sched/core.c | 4 +-
kernel/sched/membarrier.c | 236 +++++++++++-------
kernel/sched/sched.h | 34 +++
tools/testing/selftests/membarrier/.gitignore | 3 +-
tools/testing/selftests/membarrier/Makefile | 5 +-
...mbarrier_test.c => membarrier_test_impl.h} | 40 +--
.../membarrier/membarrier_test_multi_thread.c | 73 ++++++
.../membarrier_test_single_thread.c | 24 ++
11 files changed, 329 insertions(+), 116 deletions(-)
rename tools/testing/selftests/membarrier/{membarrier_test.c => membarrier_test_impl.h} (95%)
create mode 100644 tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
create mode 100644 tools/testing/selftests/membarrier/membarrier_test_single_thread.c

--
2.17.1