The patch titled /dev/kmsg: properly support writev() to avoid interleaved printk() lines has been removed from the -mm tree. Its filename was dev-kmsg-properly-support-writev-to-avoid-interleaved-printk-lines.patch This patch was dropped because it was merged into mainline or a subsystem tree The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: /dev/kmsg: properly support writev() to avoid interleaved printk() lines From: Kay Sievers <kay.sievers@xxxxxxxx> We should avoid calling printk() in a loop when we pass a single string to /dev/kmsg with writev(). Signed-off-by: Kay Sievers <kay.sievers@xxxxxxxx> Cc: Lennart Poettering <lennart@xxxxxxxxxxxxxx> Cc: Greg KH <gregkh@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/char/mem.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff -puN drivers/char/mem.c~dev-kmsg-properly-support-writev-to-avoid-interleaved-printk-lines drivers/char/mem.c --- a/drivers/char/mem.c~dev-kmsg-properly-support-writev-to-avoid-interleaved-printk-lines +++ a/drivers/char/mem.c @@ -806,29 +806,40 @@ static const struct file_operations oldm }; #endif -static ssize_t kmsg_write(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) +static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv, + unsigned long count, loff_t pos) { - char *tmp; - ssize_t ret; - - tmp = kmalloc(count + 1, GFP_KERNEL); - if (tmp == NULL) + char *line, *p; + int len, i; + ssize_t ret = -EFAULT; + + len = iov_length(iv, count); + line = p = kmalloc(len + 1, GFP_KERNEL); + if (line == NULL) return -ENOMEM; - ret = -EFAULT; - if (!copy_from_user(tmp, buf, count)) { - tmp[count] = 0; - ret = printk("%s", tmp); - if (ret > count) - /* printk can add a prefix */ - ret = count; + + /* + * copy all vectors into a single string, to ensure we do + * not interleave our log line with other printk calls + */ + for (i = 0; i < count; i++) { + if (copy_from_user(p, iv[i].iov_base, iv[i].iov_len)) + goto out; + p += iv[i].iov_len; } - kfree(tmp); + p[0] = '\0'; + + ret = printk("%s", line); + /* printk can add a prefix */ + if (ret > len) + ret = len; +out: + kfree(line); return ret; } static const struct file_operations kmsg_fops = { - .write = kmsg_write, + .aio_write = kmsg_writev, .llseek = noop_llseek, }; _ Patches currently in -mm which might be from kay.sievers@xxxxxxxx are linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html