On 03/13, Linus Torvalds wrote: > > On Mar 13, 2014 8:11 AM, "Oleg Nesterov" <o...@redhat.com> wrote: > > > > Suppose that a kernel thread T does, say, > > > > use_mm(foreign_mm); > > get_user(...); > > unuse_mm(); > > That would be a major bug. Kernel threads cannot access use memory.
Unless a kernel thread does use_mm() ;) > Has > somebody added anything that crazy? Hmm. aio no longer uses use_mm()... But there are other users: drivers/usb/gadget/inode.c 582 use_mm(mm); drivers/vhost/vhost.c 211 use_mm(dev->mm); virt/kvm/async_pf.c 68 use_mm(mm); And yes, they do copy_to/from_user(). Hmm, but at first glance async_pf_execute() doesn't need use_mm() at all. And perhaps other callers can use get_user_pages() too. > The kernel thread "use_mm" is to avoid unnecessary context switches of the > tlb when switching to a kennel thread, exactly *because* a kernel thread is > never supposed to access use space, so it cannot care what user memory is > attached. It seems that you are talking about switch_mm-like things or I misunderstood. use_mm() actually changes ->mm, not only ->active_mm. > So I object vet much to making kernel threads special on this context, > unless the "special" bit is some VM_BUG_ON() or similar. See above. Perhaps we can kill use_mm() (personally I don't think we should), but until then vmacache needs this check afaics. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/