Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b56a39ac authored by Yuanhan Liu's avatar Yuanhan Liu Committed by Greg Kroah-Hartman
Browse files

printk: return -EINVAL if the message len is bigger than the buf size



Just like what devkmsg_read() does, return -EINVAL if the message len is
bigger than the buf size, or it will trigger a segfault error.

Acked-by: default avatarKay Sievers <kay@vrfy.org>
Acked-by: default avatarFengguang Wu <wfg@linux.intel.com>
Signed-off-by: default avatarYuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4a77a5a0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -880,7 +880,9 @@ static int syslog_print(char __user *buf, int size)
	syslog_seq++;
	raw_spin_unlock_irq(&logbuf_lock);

	if (len > 0 && copy_to_user(buf, text, len))
	if (len > size)
		len = -EINVAL;
	else if (len > 0 && copy_to_user(buf, text, len))
		len = -EFAULT;

	kfree(text);