Go to file
Lorenzo Stoakes a08241812f mm: unconditionally close VMAs on error
[ Upstream commit 4080ef1579 ]

Incorrect invocation of VMA callbacks when the VMA is no longer in a
consistent state is bug prone and risky to perform.

With regards to the important vm_ops->close() callback We have gone to
great lengths to try to track whether or not we ought to close VMAs.

Rather than doing so and risking making a mistake somewhere, instead
unconditionally close and reset vma->vm_ops to an empty dummy operations
set with a NULL .close operator.

We introduce a new function to do so - vma_close() - and simplify existing
vms logic which tracked whether we needed to close or not.

This simplifies the logic, avoids incorrect double-calling of the .close()
callback and allows us to update error paths to simply call vma_close()
unconditionally - making VMA closure idempotent.

Link: https://lkml.kernel.org/r/28e89dda96f68c505cb6f8e9fc9b57c3e9f74b42.1730224667.git.lorenzo.stoakes@oracle.com
Fixes: deb0f65628 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails")
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reported-by: Jann Horn <jannh@google.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Jann Horn <jannh@google.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Helge Deller <deller@gmx.de>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Will Deacon <will@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-14 19:50:38 +01:00
arch KVM: VMX: Bury Intel PT virtualization (guest/host mode) behind CONFIG_BROKEN 2024-12-14 19:50:36 +01:00
block block: Fix elevator_get_default() checking for NULL q->tag_set 2024-11-17 15:06:24 +01:00
certs
crypto crypto: xor - fix template benchmarking 2024-10-17 15:10:42 +02:00
Documentation arm64: errata: Expand speculative SSBS workaround once more 2024-10-17 15:11:45 +02:00
drivers media: dvbdev: fix the logic when DVB_DYNAMIC_MINORS is not set 2024-12-14 19:50:37 +01:00
fs NFSD: Never decrement pending_async_copies on error 2024-12-14 19:50:37 +01:00
include fs: create kiocb_{start,end}_write() helpers 2024-11-14 13:13:40 +01:00
init
io_uring io_uring: fix possible deadlock in io_register_iowq_max_workers() 2024-11-17 15:06:25 +01:00
ipc
kernel ftrace: Fix regression with module command in stack_trace_filter 2024-12-14 19:50:33 +01:00
lib lib/buildid: Fix build ID parsing logic 2024-12-14 19:50:37 +01:00
LICENSES
mm mm: unconditionally close VMAs on error 2024-12-14 19:50:38 +01:00
net mptcp: cope racing subflow creation in mptcp_rcv_space_adjust 2024-12-14 19:50:38 +01:00
samples samples: pktgen: correct dev to DEV 2024-12-14 19:50:35 +01:00
scripts kconfig: qconf: fix buffer overflow in debug links 2024-10-17 15:11:43 +02:00
security security/keys: fix slab-out-of-bounds in key_task_permission 2024-11-14 13:13:36 +01:00
sound sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML 2024-11-17 15:06:25 +01:00
tools usbip: tools: Fix detach_port() invalid port error path 2024-11-08 16:25:54 +01:00
usr
virt KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin() 2024-10-22 15:40:41 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore Remove *.orig pattern from .gitignore 2024-10-17 15:11:10 +02:00
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile Linux 5.15.173 2024-11-17 15:06:26 +01:00
README

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.

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.