linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* copying from/to user question
@ 2024-09-09  8:50 Christian Brauner
  2024-09-09  9:18 ` Christian Brauner
  2024-09-09 14:55 ` Al Viro
  0 siblings, 2 replies; 6+ messages in thread
From: Christian Brauner @ 2024-09-09  8:50 UTC (permalink / raw)
  To: Jan Kara, Linus Torvalds, Amir Goldstein, Aleksa Sarai,
	Mike Rapoport, Vlastimil Babka, Matthew Wilcox
  Cc: linux-mm, linux-fsdevel

Hey,

This is another round of Christian's asking sus questions about kernel
apis. I asked them a few people and generally the answers I got was
"Good question, I don't know." or the reasoning varied a lot. So I take
it I'm not the only one with that question.

I was looking at a potential epoll() bug and it got me thinking about
dos & don'ts for put_user()/copy_from_user() and related helpers as
epoll does acquire the epoll mutex and then goes on to loop over a list
of ready items and calls __put_user() for each item. Granted, it only
puts a __u64 and an integer but still that seems adventurous to me and I
wondered why.

Generally, new vfs apis always try hard to call helpers that copy to or
from userspace without any locks held as my understanding has been that
this is best practice as to avoid risking taking page faults while
holding a mutex or semaphore even though that's supposedly safe.

Is this understanding correct? And aside from best practice is it in
principle safe to copy to or from userspace with sleeping locks held?


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

end of thread, other threads:[~2024-09-09 17:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-09  8:50 copying from/to user question Christian Brauner
2024-09-09  9:18 ` Christian Brauner
2024-09-09 12:14   ` Arnd Bergmann
2024-09-09 14:31     ` Thomas Gleixner
2024-09-09 17:14   ` Linus Torvalds
2024-09-09 14:55 ` Al Viro

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