Kernel sources for Moto G9 (Play) (Guamp)
Find a file
Thomas Gleixner fd9fd8a9b3 futex: Handle faults correctly for PI futexes
commit 34b1a1ce1458f50ef27c54e28eb9b1947012907a upstream

fixup_pi_state_owner() tries to ensure that the state of the rtmutex,
pi_state and the user space value related to the PI futex are consistent
before returning to user space. In case that the user space value update
faults and the fault cannot be resolved by faulting the page in via
fault_in_user_writeable() the function returns with -EFAULT and leaves
the rtmutex and pi_state owner state inconsistent.

A subsequent futex_unlock_pi() operates on the inconsistent pi_state and
releases the rtmutex despite not owning it which can corrupt the RB tree of
the rtmutex and cause a subsequent kernel stack use after free.

It was suggested to loop forever in fixup_pi_state_owner() if the fault
cannot be resolved, but that results in runaway tasks which is especially
undesired when the problem happens due to a programming error and not due
to malice.

As the user space value cannot be fixed up, the proper solution is to make
the rtmutex and the pi_state consistent so both have the same owner. This
leaves the user space value out of sync. Any subsequent operation on the
futex will fail because the 10th rule of PI futexes (pi_state owner and
user space value are consistent) has been violated.

As a consequence this removes the inept attempts of 'fixing' the situation
in case that the current task owns the rtmutex when returning with an
unresolvable fault by unlocking the rtmutex which left pi_state::owner and
rtmutex::owner out of sync in a different and only slightly less dangerous
way.

Change-Id: Ic19f2e16d6de16db63594706eae5f547e38ea852
Fixes: 1b7558e457 ("futexes: fix fault handling in futex_lock_pi")
Reported-by: gzobqq@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 6e7bfa046d
Git-repo: https://android.googlesource.com/kernel/msm
Signed-off-by: PavanKumar S.R. <pavasr@codeaurora.org>
2021-08-17 08:23:23 -07:00
android
arch Merge "defconfig: Enable thermal emergency poweroff delay" 2021-08-15 22:11:31 -07:00
block Merge android-4.19-stable.157 (8ee67bc) into msm-4.19 2020-12-18 18:35:06 +05:30
certs
crypto Merge android-4.19-stable.157 (8ee67bc) into msm-4.19 2020-12-18 18:35:06 +05:30
Documentation BACKPORT: cgroup: make per-cgroup pressure stall tracking configurable 2021-07-01 23:43:00 -07:00
drivers Merge "USB: diag: Add check for ctxt in usb_diag_request_size()" 2021-08-16 14:38:58 -07:00
firmware
fs ANDROID: Incremental fs: Set credentials before reading/writing 2021-06-18 16:58:31 +05:30
include dt-bindings: Add gpr header required for AR on kona 2021-08-03 04:10:12 -07:00
init Merge android-4.19-stable.157 (8ee67bc) into msm-4.19 2020-12-18 18:35:06 +05:30
ipc
kernel futex: Handle faults correctly for PI futexes 2021-08-17 08:23:23 -07:00
lib Merge android-4.19-stable.157 (8ee67bc) into msm-4.19 2020-12-18 18:35:06 +05:30
LICENSES
mm mm: cma: Print correct request pages 2021-03-02 18:45:12 +08:00
net netfilter: nf_conntrack_h323: lost .data_len definition for Q.931/ipv6 2021-05-18 14:41:27 +05:30
samples Merge 4.19.154 into android-4.19-stable 2020-10-30 11:43:26 +01:00
scripts Merge android-4.19-stable.157 (8ee67bc) into msm-4.19 2020-12-18 18:35:06 +05:30
security Revert "ANDROID: security,perf: Allow further restriction of perf_event_open" 2021-04-30 00:21:50 -07:00
sound From bbfaa7d36c1eb465f120f2a3dfe25c1fe022195d Mon Sep 17 00:00:00 2001 2021-07-06 10:08:25 +05:30
techpack
tools Merge 4.19.156 into android-4.19-stable 2020-11-10 13:23:09 +01:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
Android.bp Use environment variable to find unifdef tool 2021-06-25 00:24:52 -07:00
AndroidKernel.mk
build.config.aarch64 Revert "ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple" 2020-11-10 11:47:24 -08:00
build.config.allmodconfig Revert "ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple" 2020-11-10 11:47:24 -08:00
build.config.allmodconfig.aarch64
build.config.allmodconfig.arm
build.config.allmodconfig.x86_64
build.config.arm Revert "ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple" 2020-11-10 11:47:24 -08:00
build.config.common
build.config.gki
build.config.gki-debug.aarch64
build.config.gki-debug.x86_64
build.config.gki.aarch64
build.config.gki.x86_64
build.config.gki_kasan
build.config.gki_kasan.aarch64
build.config.gki_kasan.x86_64
build.config.goldfish.arm
build.config.goldfish.arm64
build.config.goldfish.mips
build.config.goldfish.mips64
build.config.goldfish.x86
build.config.goldfish.x86_64
build.config.x86_64 Revert "ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple" 2020-11-10 11:47:24 -08:00
COPYING TDK-Robotics-RB5 drivers source code files 2021-01-27 15:12:37 +01:00
CREDITS
gen_headers_arm.bp Merge "Change the subprocess argument to fix the build issue" 2021-06-30 01:35:21 -07:00
gen_headers_arm64.bp Merge "Change the subprocess argument to fix the build issue" 2021-06-30 01:35:21 -07:00
Kbuild
Kconfig
kernel_headers.py Change the subprocess argument to fix the build issue 2021-06-28 16:47:30 +05:30
MAINTAINERS UPSTREAM: HID: playstation: Initial DualSense USB support 2021-08-06 12:46:40 +05:30
Makefile Revert "kbuild: force to build vmlinux if CONFIG_MODVERSION=y" 2021-07-23 18:30:57 +05:30
README
verity_dev_keys.x509

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.