On Wed, Sep 11, 2019 at 07:12:06AM +0900, Tetsuo Handa wrote: > >> +static ssize_t memalloc_write(struct file *file, const char __user *buf, > >> + size_t count, loff_t *ppos) > >> +{ > >> + struct task_struct *task; > >> + char buffer[5]; > >> + int rc = count; > >> + > >> + memset(buffer, 0, sizeof(buffer)); > >> + if (count != sizeof(buffer) - 1) > >> + return -EINVAL; > >> + > >> + if (copy_from_user(buffer, buf, count)) > > copy_from_user() / copy_to_user() might involve memory allocation > via page fault which has to be done under the mask? Moreover, since > just open()ing this file can involve memory allocation, do we forbid > open("/proc/thread-self/memalloc") ? Not saying that I'm okay with the approach in general, but I don't think this a problem. The application has to set allocation policy before inserting itself into IO or FS path. -- Kirill A. Shutemov