OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 0/7] mm, exec: fix the MADV_DOEXEC code we carry from Oracle
@ 2026-10-14 17:12 Konstantin Khorenko
  2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 1/7] oracle/mm: take a file reference when preserving a file-backed VMA Konstantin Khorenko
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Konstantin Khorenko @ 2026-10-14 17:12 UTC (permalink / raw)
  To: Pavel Tikhomirov, Andrey Drobyshev, Vasileios Almpanis; +Cc: devel

Fixes in the existing Oracle MADV_DOEXEC code, found while working on
VSTOR-149847, and a refusal of preserved memory across setuid exec.
Applies on top of "mm: keep DMA-pinned MADV_DOEXEC memory working across
exec".

- 1: vma_dup() takes no file reference for a file-backed VMA, so a
  private /dev/zero mapping marked MADV_DOEXEC is put twice
  (use-after-free of struct file, reachable unprivileged).
- 2: a private VM_PFNMAP VMA with NULL vm_ops passed as anonymous and
  its PAT memtype was freed twice; refuse VM_SPECIAL.
- 3: MADV_DOEXEC never cleared VM_MAYEXEC and MADV_DONTEXEC granted it
  unconditionally, also on noexec mounts; the copies made by exec and
  fork get back what do_mmap() granted.
- 4: load_elf_binary() looked for the opt-in note only in the last
  PT_NOTE segment; a binary whose linker puts it elsewhere silently got
  no preserved memory.
- 5: a setuid/secureexec exec with preserved memory is refused with
  EPERM before the point of no return: long-term pins driven from
  another process would keep writing into the privileged image.
- 6, 7: selftests for 5 and for 1 and 3.

Tested with the whole stack on release and debug kernels (MADV_DOEXEC
selftests, gup_test, a Container start/exec/stop).

https://virtuozzo.atlassian.net/browse/VSTOR-150232

---
Konstantin Khorenko (7):
      oracle/mm: take a file reference when preserving a file-backed VMA
      oracle/mm: refuse MADV_DOEXEC on special mappings
      oracle/mm: keep a MADV_DOEXEC range from becoming executable
      oracle/exec, elf: look for the opt-in note in every PT_NOTE segment
      exec: refuse to preserve memory across a privilege-changing exec
      selftests/mm: check that a setuid exec refuses preserved memory
      selftests/mm: check MADV_DOEXEC on /dev/zero and exec permission

 fs/binfmt_elf.c                     |  87 +++++++++------
 fs/exec.c                           |   4 +
 include/linux/mm.h                  |   1 +
 kernel/fork.c                       |   4 +-
 mm/madvise.c                        |  12 +-
 mm/mmap.c                           |  17 ++-
 tools/testing/selftests/mm/doexec.c | 211 +++++++++++++++++++++++++++++++++++-
 7 files changed, 290 insertions(+), 46 deletions(-)
---
base-commit: 0f7fa776e32c8e6832e7604dc157d05d3af14513
change-id: 20261014-b4-prep-khorenko-vstor-149847-3-doexec-oracle-fixes-33341d1abc4d

Best regards,
--  
Konstantin Khorenko <khorenko@virtuozzo.com>

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

end of thread, other threads:[~2026-10-14 17:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-14 17:12 [Devel] [PATCH hci-8.1 0/7] mm, exec: fix the MADV_DOEXEC code we carry from Oracle Konstantin Khorenko
2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 1/7] oracle/mm: take a file reference when preserving a file-backed VMA Konstantin Khorenko
2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 2/7] oracle/mm: refuse MADV_DOEXEC on special mappings Konstantin Khorenko
2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 3/7] oracle/mm: keep a MADV_DOEXEC range from becoming executable Konstantin Khorenko
2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 4/7] oracle/exec, elf: look for the opt-in note in every PT_NOTE segment Konstantin Khorenko
2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 5/7] exec: refuse to preserve memory across a privilege-changing exec Konstantin Khorenko
2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 6/7] selftests/mm: check that a setuid exec refuses preserved memory Konstantin Khorenko
2026-10-14 17:12 ` [Devel] [PATCH hci-8.1 7/7] selftests/mm: check MADV_DOEXEC on /dev/zero and exec permission Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox