From: David Hildenbrand <david@redhat.com>
To: Mateusz Guzik <mjguzik@gmail.com>, linux-kernel@vger.kernel.org
Cc: torvalds@linux-foundation.org, brauner@kernel.org,
ebiederm@xmission.com, akpm@linux-foundation.org,
linux-mm@kvack.org, koct9i@gmail.com, oleg@redhat.com,
dave@stgolabs.net
Subject: Re: [PATCH v2] kernel/fork: stop playing lockless games for exe_file replacement
Date: Tue, 15 Aug 2023 09:29:16 +0200 [thread overview]
Message-ID: <39b65258-5ab5-fdff-099a-999f5a4350ee@redhat.com> (raw)
In-Reply-To: <20230814172140.1777161-1-mjguzik@gmail.com>
On 14.08.23 19:21, Mateusz Guzik wrote:
> xchg originated in 6e399cd144d8 ("prctl: avoid using mmap_sem for
> exe_file serialization"). While the commit message does not explain
> *why* the change, I found the original submission [1] which ultimately
> claims it cleans things up by removing dependency of exe_file on the
> semaphore.
>
> However, fe69d560b5bd ("kernel/fork: always deny write access to current
> MM exe_file") added a semaphore up/down cycle to synchronize the state
> of exe_file against fork, defeating the point of the original change.
>
> This is on top of semaphore trips already present both in the replacing
> function and prctl (the only consumer).
>
> Normally replacing exe_file does not happen for busy processes, thus
> write-locking is not an impediment to performance in the intended use
> case. If someone keeps invoking the routine for a busy processes they
> are trying to play dirty and that's another reason to avoid any
> trickery.
>
> As such I think the atomic here only adds complexity for no benefit.
>
> Just write-lock around the replacement.
>
> I also note that replacement races against the mapping check loop as
> nothing synchronizes actual assignment with with said checks but I am
> not addressing it in this patch. (Is the loop of any use to begin with?)
>
> V2:
> - fix up comments
> - tweak commit message
>
> Link: https://lore.kernel.org/linux-mm/1424979417.10344.14.camel@stgolabs.net/ [1]
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
> ---
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2023-08-15 7:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 17:21 Mateusz Guzik
2023-08-14 18:11 ` Oleg Nesterov
2023-08-15 7:29 ` David Hildenbrand [this message]
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=39b65258-5ab5-fdff-099a-999f5a4350ee@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=dave@stgolabs.net \
--cc=ebiederm@xmission.com \
--cc=koct9i@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mjguzik@gmail.com \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.org \
/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