From: Greg Kroah-Hartman Date: Fri, 31 Mar 2006 23:37:06 +0000 (-0800) Subject: [PATCH] sysfs: zero terminate sysfs write buffers X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6e0dd741a89be35defa05bd79f4211c5a2762825;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [PATCH] sysfs: zero terminate sysfs write buffers No one should be writing a PAGE_SIZE worth of data to a normal sysfs file, so properly terminate the buffer. Thanks to Al Viro for pointing out my supidity here. Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 830f76fa098c..f1cb1ddde511 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -183,7 +183,7 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t return -ENOMEM; if (count >= PAGE_SIZE) - count = PAGE_SIZE; + count = PAGE_SIZE - 1; error = copy_from_user(buffer->page,buf,count); buffer->needs_read_fill = 1; return error ? -EFAULT : count;