Messages in this thread | | | Date | Wed, 24 Sep 2014 20:17:27 +0100 | From | Al Viro <> | Subject | Re: [PATCH] kernfs: use stack-buf for small writes. |
| |
On Tue, Sep 23, 2014 at 02:06:33PM +1000, NeilBrown wrote: > > For a write <= 128 characters, don't use kmalloc. > > mdmon, part of mdadm, will sometimes need to write > to a sysfs file in order to allow writes to the array > to continue. This is important to support RAID metadata > types that the kernel doesn't know about. > > It is important that this write doesn't block on > memory allocation. The safest way to ensure that is to > use an on-stack buffer.
Is it, now? What happens if caller of write(2) loses CPU and gets the page it's writing from swapped out, just as it's getting to issuing the actual syscall? copy_from_user() will fault and cause memory allocation for you...
> Writes are always small, typically less than 10 characters.
Translation: "but my userland code uses it _that_ way; surely, nobody would do anything else..."
| |