Re: [syzbot] BUG: sleeping function called from invalid context in _copy_to_iter
From: Al Viro
Date: Mon Aug 09 2021 - 16:04:51 EST
On Mon, Aug 09, 2021 at 12:40:03PM -0700, Shoaib Rao wrote:
> Page faults occur all the time, the page may not even be in the cache or the
> mapping is not there (mmap), so I would not consider this a bug. The code
> should complain about all other calls as they are also copying to user
> pages. I must not be following some semantics for the code to be triggered
> but I can not figure that out. What is the recommended interface to do user
> copy from kernel?
What are you talking about? Yes, page faults happen. No, they
must not be triggered in contexts when you cannot afford going to sleep.
In particular, you can't do that while holding a spinlock.
There are things that can't be done under a spinlock. If your
commit is attempting that, it's simply broken.