linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Julian Orth <ju.orth@gmail.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Regression: mmap rejects shared, read-only mappings of write-sealed memfds
Date: Wed, 27 Nov 2024 21:49:29 +0100	[thread overview]
Message-ID: <CAHijbEUMhvJTN9Xw1GmbM266FXXv=U7s4L_Jem5x3AaPZxrYpQ@mail.gmail.com> (raw)

Since around

    5de19506 mm: resolve faulty mmap_region() error path behaviour

mmap rejects shared, read-only mapping of memfds that have a write-seal applied.

Before the commit, the code in mmap_region was

    if (file) {
        vma->vm_file = get_file(file);
        error = mmap_file(file, vma);
        if (error)
            goto unmap_and_free_vma;

        if (vma_is_shared_maywrite(vma)) {
            error = mapping_map_writable(file->f_mapping);

where mmap_file would clear the VM_MAYWRITE flag for write-sealed memfds.

After the commit, the code in mmap_region is simply

    if (file && is_shared_maywrite(vm_flags)) {
        int error = mapping_map_writable(file->f_mapping);

with mmap_file not being called until much later.

This regression seems to have been first released in 6.12 and is still
present on master.


             reply	other threads:[~2024-11-27 20:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27 20:49 Julian Orth [this message]
2024-11-27 21:59 ` Lorenzo Stoakes

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='CAHijbEUMhvJTN9Xw1GmbM266FXXv=U7s4L_Jem5x3AaPZxrYpQ@mail.gmail.com' \
    --to=ju.orth@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox