public inbox for [email protected]
 help / color / mirror / Atom feed
* bcachefs: suspicious mm pointer in struct dio_write
@ 2024-11-27 16:57 Jann Horn
  2024-11-27 18:09 ` Jens Axboe
  2024-11-27 20:23 ` Kent Overstreet
  0 siblings, 2 replies; 17+ messages in thread
From: Jann Horn @ 2024-11-27 16:57 UTC (permalink / raw)
  To: Kent Overstreet, linux-bcachefs
  Cc: kernel list, Jens Axboe, Pavel Begunkov, io-uring

Hi!

In fs/bcachefs/fs-io-direct.c, "struct dio_write" contains a pointer
to an mm_struct. This pointer is grabbed in bch2_direct_write()
(without any kind of refcount increment), and used in
bch2_dio_write_continue() for kthread_use_mm()/kthread_unuse_mm()
which are used to enable userspace memory access from kthread context.
I believe kthread_use_mm()/kthread_unuse_mm() require that the caller
guarantees that the MM hasn't gone through exit_mmap() yet (normally
by holding an mmget() reference).

If we reach this codepath via io_uring, do we have a guarantee that
the mm_struct that called bch2_direct_write() is still alive and
hasn't yet gone through exit_mmap() when it is accessed from
bch2_dio_write_continue()?

I don't know the async direct I/O codepath particularly well, so I
cc'ed the uring maintainers, who probably know this better than me.

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

end of thread, other threads:[~2024-11-27 21:59 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-27 16:57 bcachefs: suspicious mm pointer in struct dio_write Jann Horn
2024-11-27 18:09 ` Jens Axboe
2024-11-27 19:43   ` Jann Horn
2024-11-27 20:01     ` Jens Axboe
2024-11-27 20:31       ` Kent Overstreet
2024-11-27 20:25   ` Kent Overstreet
2024-11-27 20:44     ` Jann Horn
2024-11-27 21:08       ` Kent Overstreet
2024-11-27 21:16         ` Jens Axboe
2024-11-27 21:27           ` Kent Overstreet
2024-11-27 21:51             ` Jens Axboe
2024-11-27 21:58               ` Kent Overstreet
2024-11-27 21:59                 ` Jens Axboe
2024-11-27 21:39           ` Jann Horn
2024-11-27 21:52             ` Jens Axboe
2024-11-27 21:53               ` Jann Horn
2024-11-27 20:23 ` Kent Overstreet

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