All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there
@ 2020-04-29 21:49 ` Jann Horn
  0 siblings, 0 replies; 100+ messages in thread
From: Jann Horn @ 2020-04-29 21:49 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Rich Felker, linux-c6x-dev, Yoshinori Sato, linux-sh,
	linux-kernel, Oleg Nesterov, linux-mm, Alexander Viro,
	Mark Salter, linux-fsdevel, Russell King, Aurelien Jacquiot,
	Linus Torvalds, Christoph Hellwig, linux-arm-kernel,
	Eric W . Biederman

At the moment, we have that rather ugly mmget_still_valid() helper to
work around <https://crbug.com/project-zero/1790>: ELF core dumping
doesn't take the mmap_sem while traversing the task's VMAs, and if
anything (like userfaultfd) then remotely messes with the VMA tree,
fireworks ensue. So at the moment we use mmget_still_valid() to bail
out in any writers that might be operating on a remote mm's VMAs.

With this series, I'm trying to get rid of the need for that as
cleanly as possible.
In particular, I want to avoid holding the mmap_sem across unbounded
sleeps.


Patches 1, 2 and 3 are relatively unrelated cleanups in the core
dumping code.

Patches 4 and 5 implement the main change: Instead of repeatedly
accessing the VMA list with sleeps in between, we snapshot it at the
start with proper locking, and then later we just use our copy of
the VMA list. This ensures that the kernel won't crash, that VMA
metadata in the coredump is consistent even in the presence of
concurrent modifications, and that any virtual addresses that aren't
being concurrently modified have their contents show up in the core
dump properly.

The disadvantage of this approach is that we need a bit more memory
during core dumping for storing metadata about all VMAs.

After this series has landed, we should be able to rip out
mmget_still_valid().


Testing done so far:

 - Creating a simple core dump on X86-64 still works.
 - The created coredump on X86-64 opens in GDB, and both the stack and the
   exectutable look vaguely plausible.
 - 32-bit ARM compiles with FDPIC support, both with MMU and !MMU config.

I'm CCing some folks from the architectures that use FDPIC in case
anyone wants to give this a spin.


This series is based on
<https://lore.kernel.org/linux-fsdevel/20200427200626.1622060-1-hch@lst.de/>
(Christoph Hellwig's "remove set_fs calls from the coredump code v4").


changed in v2:
 - replace "Fix handling of partial writes in dump_emit()" with
   "Let dump_emit() bail out on short writes" (Linus)
 - get rid of the useless complicated cache flushing in
   "Take mmap_sem in get_dump_page()" (Linus)

Jann Horn (5):
  binfmt_elf_fdpic: Stop using dump_emit() on user pointers on !MMU
  coredump: Let dump_emit() bail out on short writes
  coredump: Refactor page range dumping into common helper
  binfmt_elf, binfmt_elf_fdpic: Use a VMA list snapshot
  mm/gup: Take mmap_sem in get_dump_page()

 fs/binfmt_elf.c          | 170 ++++++++++++---------------------------
 fs/binfmt_elf_fdpic.c    | 106 +++++++++---------------
 fs/coredump.c            | 123 +++++++++++++++++++++++++---
 include/linux/coredump.h |  12 +++
 mm/gup.c                 |  60 +++++++-------
 5 files changed, 245 insertions(+), 226 deletions(-)


base-commit: 6a8b55ed4056ea5559ebe4f6a4b247f627870d4c
prerequisite-patch-id: c0a20b414eebc48fe0a8ca570b05de34c7980396
prerequisite-patch-id: 51973b8db0fa4b114e0c3fd8936b634d9d5061c5
prerequisite-patch-id: 0e1e8de282ca6d458dc6cbdc6b6ec5879edd8a05
prerequisite-patch-id: d5ee749c4d3a22ec80bd0dd88aadf89aeb569db8
prerequisite-patch-id: 46ce14e59e98e212a1eca0aef69c6dcdb62b8242
-- 
2.26.2.526.g744177e7f7-goog

^ permalink raw reply	[flat|nested] 100+ messages in thread

end of thread, other threads:[~2020-08-11  3:07 UTC | newest]

Thread overview: 100+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 21:49 [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there Jann Horn
2020-04-29 21:49 ` Jann Horn
2020-04-29 21:49 ` Jann Horn
2020-04-29 21:49 ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 1/5] binfmt_elf_fdpic: Stop using dump_emit() on user pointers on !MMU Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-05-05 10:48   ` Christoph Hellwig
2020-05-05 10:48     ` Christoph Hellwig
2020-05-05 10:48     ` Christoph Hellwig
2020-05-05 11:42     ` Jann Horn
2020-05-05 11:42       ` Jann Horn
2020-05-05 11:42       ` Jann Horn
2020-05-05 11:42       ` Jann Horn
2020-05-05 12:15       ` Christoph Hellwig
2020-05-05 12:15         ` Christoph Hellwig
2020-05-05 12:15         ` Christoph Hellwig
2020-08-11  3:05         ` Jann Horn
2020-08-11  3:05           ` Jann Horn
2020-08-11  3:05           ` Jann Horn
2020-08-11  3:05           ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 2/5] coredump: Let dump_emit() bail out on short writes Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 3/5] coredump: Refactor page range dumping into common helper Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-05-05 10:50   ` Christoph Hellwig
2020-05-05 10:50     ` Christoph Hellwig
2020-05-05 10:50     ` Christoph Hellwig
2020-05-05 11:44     ` Jann Horn
2020-05-05 11:44       ` Jann Horn
2020-05-05 11:44       ` Jann Horn
2020-05-05 11:44       ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 4/5] binfmt_elf, binfmt_elf_fdpic: Use a VMA list snapshot Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-05-05 11:03   ` Christoph Hellwig
2020-05-05 11:03     ` Christoph Hellwig
2020-05-05 11:03     ` Christoph Hellwig
2020-05-05 12:11     ` Jann Horn
2020-05-05 12:11       ` Jann Horn
2020-05-05 12:11       ` Jann Horn
2020-05-05 12:11       ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 5/5] mm/gup: Take mmap_sem in get_dump_page() Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:56 ` [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there Russell King - ARM Linux admin
2020-04-29 21:56   ` Russell King - ARM Linux admin
2020-04-29 21:56   ` Russell King - ARM Linux admin
2020-04-29 23:03   ` Linus Torvalds
2020-04-29 23:03     ` Linus Torvalds
2020-04-29 23:03     ` Linus Torvalds
2020-04-29 23:03     ` Linus Torvalds
2020-04-30  1:27     ` Nicolas Pitre
2020-04-30  1:27       ` Nicolas Pitre
2020-04-30  1:27       ` Nicolas Pitre
2020-04-30  1:27       ` Nicolas Pitre
2020-04-30 14:10     ` Greg Ungerer
2020-04-30 14:10       ` Greg Ungerer
2020-04-30 14:10       ` Greg Ungerer
2020-04-30 14:51       ` Rich Felker
2020-04-30 14:51         ` Rich Felker
2020-04-30 14:51         ` Rich Felker
2020-04-30 21:13         ` Rob Landley
2020-04-30 21:13           ` Rob Landley
2020-04-30 21:13           ` Rob Landley
2020-05-01  6:00         ` Greg Ungerer
2020-05-01  6:00           ` Greg Ungerer
2020-05-01  6:00           ` Greg Ungerer
2020-05-01 19:09           ` Rob Landley
2020-05-01 19:09             ` Rob Landley
2020-05-01 19:09             ` Rob Landley
2020-04-30 16:54       ` Linus Torvalds
2020-04-30 16:54         ` Linus Torvalds
2020-04-30 16:54         ` Linus Torvalds
2020-04-30 16:54         ` Linus Torvalds
2020-04-30 19:07         ` Eric W. Biederman
2020-04-30 19:07           ` Eric W. Biederman
2020-04-30 19:07           ` Eric W. Biederman
2020-04-30 19:07           ` Eric W. Biederman
2020-05-01  5:44           ` Greg Ungerer
2020-05-01  5:44             ` Greg Ungerer
2020-05-01  5:44             ` Greg Ungerer
2020-05-01 11:13             ` Eric W. Biederman
2020-05-01 11:13               ` Eric W. Biederman
2020-05-01 11:13               ` Eric W. Biederman
2020-05-01 11:13               ` Eric W. Biederman
2020-05-01  7:14         ` Greg Ungerer
2020-05-01  7:14           ` Greg Ungerer
2020-05-01  7:14           ` Greg Ungerer
2020-04-30  1:59   ` Nicolas Pitre
2020-04-30  1:59     ` Nicolas Pitre
2020-04-30  1:59     ` Nicolas Pitre
2020-04-30  1:59     ` Nicolas Pitre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.