From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>,
Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 0/7] mm, exec: fix the MADV_DOEXEC code we carry from Oracle
Date: Wed, 14 Oct 2026 19:12:19 +0200 [thread overview]
Message-ID: <20261014-b4-prep-khorenko-vstor-149847-3-doexec-oracle-fixes-v1-0-e34cbe0d1440@virtuozzo.com> (raw)
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
next reply other threads:[~2026-10-14 17:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 17:12 Konstantin Khorenko [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014-b4-prep-khorenko-vstor-149847-3-doexec-oracle-fixes-v1-0-e34cbe0d1440@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=devel@openvz.org \
--cc=ptikhomirov@virtuozzo.com \
--cc=vasileios.almpanis@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.