linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* untagged_addr_remote() in do_madvise()
@ 2025-01-14 19:43 Liam R. Howlett
  2025-01-14 20:15 ` Dave Hansen
  2025-01-14 20:41 ` Lorenzo Stoakes
  0 siblings, 2 replies; 5+ messages in thread
From: Liam R. Howlett @ 2025-01-14 19:43 UTC (permalink / raw)
  To: dave.hansen, kirill.shutemov
  Cc: Shakeel Butt, SeongJae Park, David Hildenbrand, Lorenzo Stoakes,
	Vlastimil Babka, Andrew Morton, Jens Axboe, Pavel Begunkov,
	linux-kernel, linux-mm, Ryan Roberts

Hello,

I noticed that mm/madivse.c:do_madvise() calls untagged_addr_remote()
after validating start.

Looking through git blame shows that this line was moved in
428e106ae1ad4 ("mm: Introduce untagged_addr_remote()") [1], with the
reason being:

    The new helper untagged_addr_remote() has to be used when the address
    targets remote process. It requires the mmap lock for target mm to be
    taken.

Although this may be needed, we cannot move the untagging below
validating the start/end because we have not validated the start/end
that will be used for the operation, or at least, isn't clear why it's
okay?

Can anyone tell me why the code today is correct?  That is, how can we
trust the validation of start/end is still okay after we change the
start/end by untagging the start?

I think we have to move the locking and the untagging above the
validation for this to work as expected?

[1] https://lore.kernel.org/all/20230312112612.31869-6-kirill.shutemov@linux.intel.com/

Thanks,
Liam


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

end of thread, other threads:[~2025-01-15 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-14 19:43 untagged_addr_remote() in do_madvise() Liam R. Howlett
2025-01-14 20:15 ` Dave Hansen
2025-01-14 20:41 ` Lorenzo Stoakes
2025-01-14 21:13   ` Dave Hansen
2025-01-15 11:55     ` Lorenzo Stoakes

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