Commit a3e47bc9 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Linus Torvalds

[PATCH] Buffer overrun in arch/x86_64/sys_ia32.c:sys32_ni_syscall()

With Chris Wright <chrisw@osdl.org>

struct task_struct.comm is defined to be 16 chars, but
arch/x86_64/sys_ia32.c:sys32_ni_syscall() and sys32_vm86_warning() copy it
into a static 8 byte buffer, which will surely cause problems.  This patch
makes lastcomm[] the right size, and makes sure it can't be overrun.  Since
the code also goes to the effort of getting a local copy of current in "me",
we may as well use it for printing the message.
Signed-off-by: default avatarChris Wright <chrisw@osdl.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b7aacd4a
...@@ -525,11 +525,12 @@ sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options) ...@@ -525,11 +525,12 @@ sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
int sys32_ni_syscall(int call) int sys32_ni_syscall(int call)
{ {
struct task_struct *me = current; struct task_struct *me = current;
static char lastcomm[8]; static char lastcomm[sizeof(me->comm)];
if (strcmp(lastcomm, me->comm)) {
printk(KERN_INFO "IA32 syscall %d from %s not implemented\n", call, if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
current->comm); printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",
strcpy(lastcomm, me->comm); call, me->comm);
strncpy(lastcomm, me->comm, sizeof(lastcomm));
} }
return -ENOSYS; return -ENOSYS;
} }
...@@ -1125,11 +1126,11 @@ long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, ...@@ -1125,11 +1126,11 @@ long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
long sys32_vm86_warning(void) long sys32_vm86_warning(void)
{ {
struct task_struct *me = current; struct task_struct *me = current;
static char lastcomm[8]; static char lastcomm[sizeof(me->comm)];
if (strcmp(lastcomm, me->comm)) { if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n", printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
me->comm); me->comm);
strcpy(lastcomm, me->comm); strncpy(lastcomm, me->comm, sizeof(lastcomm));
} }
return -ENOSYS; return -ENOSYS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment