On 24/11/2019 02:08, Jens Axboe wrote: > On 11/23/19 3:49 PM, Pavel Begunkov wrote: >> There is a bug hunging my system when run fixed-link with /dev/urandom >> instead of /dev/zero (see patch 1/2). >> >> As for me, the easiest way to fix is to grab mm and use userspace >> address for this specific case (as it's done in patches). The other >> way is to kmap/vmap, but the first should be short-lived and the >> second needs mm anyway. >> >> Ideas how to do it better way? Suggestions and corrections are welcome. > > OK, took a quick look. kmap() etc doesn't need context, but the copy Thanks! What copy do you mean? The first and pretty short version was with kmap. e.g. while(count) { read(kmap()); ...; knumap(); } I'll send this shortly. What I don't like here, is that it passes kmapped virtual address as "void __user *". Is that ok? > does. How about just ensuring we grab the mm for cases that don't have > ->read_iter() or ->write_iter() and then just map and copy in that > loop that handles that exact case? I think that's cleaner than what > you have. > -- Pavel Begunkov