Skip to content

Commit

Permalink
printk: return -EINVAL if the message len is bigger than the buf size
Browse files Browse the repository at this point in the history
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: Kay Sievers <kay@vrfy.org>
Acked-by: Fengguang Wu <wfg@linux.intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Yuanhan Liu authored and Greg Kroah-Hartman committed Jun 16, 2012
1 parent 4a77a5a commit b56a39a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b56a39a

Please sign in to comment.