linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>,
	Suren Baghdasaryan <surenb@google.com>,
	 Bagas Sanjaya <bagasdotme@gmail.com>,
	Jacob Young <jacobly.alt@gmail.com>,
	 Laurent Dufour <ldufour@linux.ibm.com>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Memory Management <linux-mm@kvack.org>,
	 Linux PowerPC <linuxppc-dev@lists.ozlabs.org>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	 Linux regressions mailing list <regressions@lists.linux.dev>
Subject: Re: Fwd: Memory corruption in multithreaded user space program while calling fork
Date: Sat, 8 Jul 2023 11:04:49 -0700	[thread overview]
Message-ID: <CAHk-=wh498i3s+BgOF=pUOF=Qe_A0A16-mFcH2YGy+iZXvNChQ@mail.gmail.com> (raw)
In-Reply-To: <20230708103936.4f6655cd0d8e8a0478509e25@linux-foundation.org>

On Sat, 8 Jul 2023 at 10:39, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> That was the v1 fix, but after some discussion
> (https://lkml.kernel.org/r/20230705063711.2670599-1-surenb@google.com)
> it was decided to take the "excessive" approach.

That makes absolutely _zero_ sense.

It seems to be complete voodoo programming.

To some degree I don't care what happens in stable kernels, but
there's no way we'll do that kind of thing in mainline without some
logic or reason, when it makes no sense.

flush_cache_dup_mm() is entirely irrelevant to the whole issue, for
several reason, but the core one being that it only matters on broken
virtually indexed caches, so none of the architectures that do per-vma
locking.

And the argument that "After the mmap_write_lock_killable(), there
will still be a period where page faults can happen" may be true
(that's kind of the *point* of per-vma locking), but it's irrelevant.

It's true for *all* users of mmap_write_lock_killable, whether in fork
or anywhere else. What makes fork() so magically special?

It's why we have that vma_start_write(), to say "I'm now modifying
*this* vma, so stop accessing it in parallel".

Because no, flush_cache_dup_mm() is not the magical reason to do that thing.

Maybe there is something else going on, but no, we don't write crazy
code without a reason for it. That's completely unmaintainable,
because people will look at that code, not understand it (because
there is nothing to understand) and be afraid to touch it. For no
actual reason.

The obvious place to say "I'm now starting to modify the vma" is when
you actually start to modify the vma.

> Also, this change needs a couple more updates:

Those updates seem sane, and come with explanations of why they exist.
Looks fine to me.

Suren, please send me the proper fixes. Not the voodoo one. The ones
you can explain.

And if stable wants to do something else, then that's fine. But for
the development kernel,. we have two options:

 - fix the PER_VMA_LOCK code

 - decide that it's not worth it, and just revert it all

and honestly, I'm ok with that second option, simply because this has
all been way too much pain.

But no, we don't mark it broken thinking we can't deal with it, or do
random non-sensible code code we can't explain.

            Linus


  reply	other threads:[~2023-07-08 18:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-02 12:27 Bagas Sanjaya
2023-07-02 12:40 ` Jacob Young
2023-07-02 14:11   ` Bagas Sanjaya
2023-07-03  9:53 ` Fwd: " Linux regression tracking (Thorsten Leemhuis)
2023-07-03 18:08   ` Suren Baghdasaryan
2023-07-03 18:27     ` Suren Baghdasaryan
2023-07-03 18:44       ` Greg KH
2023-07-04  7:45         ` Suren Baghdasaryan
2023-07-04  8:00           ` Greg KH
2023-07-04 16:18             ` Andrew Morton
2023-07-04 20:22               ` Suren Baghdasaryan
2023-07-04 21:28                 ` Andrew Morton
2023-07-04 22:04                   ` Suren Baghdasaryan
2023-07-05  6:42                     ` Suren Baghdasaryan
2023-07-05  7:08                 ` Greg KH
2023-07-05  8:51                   ` Linux regression tracking (Thorsten Leemhuis)
2023-07-05  9:27                     ` Greg KH
2023-07-05 15:49                     ` Andrew Morton
2023-07-05 16:14                       ` Suren Baghdasaryan
2023-07-05 17:17                         ` Suren Baghdasaryan
2023-07-08 11:35                       ` Thorsten Leemhuis
2023-07-08 17:29                         ` Linus Torvalds
2023-07-08 17:39                           ` Andrew Morton
2023-07-08 18:04                             ` Linus Torvalds [this message]
2023-07-08 18:40                               ` Suren Baghdasaryan
2023-07-08 19:05                                 ` Linus Torvalds
2023-07-08 19:17                                   ` Suren Baghdasaryan
2023-07-08 19:22                                     ` Linus Torvalds
2023-07-08 19:41                                       ` Suren Baghdasaryan

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='CAHk-=wh498i3s+BgOF=pUOF=Qe_A0A16-mFcH2YGy+iZXvNChQ@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=bagasdotme@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jacobly.alt@gmail.com \
    --cc=ldufour@linux.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=regressions@leemhuis.info \
    --cc=regressions@lists.linux.dev \
    --cc=surenb@google.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