Skip to content

Commit

Permalink
lguest: make sure cpu is initialized before accessing it
Browse files Browse the repository at this point in the history
If req is LHREQ_INITIALIZE, and the guest has been initialized before
(unlikely), it will attempt to access cpu->tsk even though cpu is not yet
initialized.

Signed-off-by: Eugene Teo <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
eugeneteo authored and rustyrussell committed Mar 10, 2008
1 parent cdeeeae commit f73d1e6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/lguest/lguest_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,16 @@ static ssize_t write(struct file *file, const char __user *in,
cpu = &lg->cpus[cpu_id];
if (!cpu)
return -EINVAL;
}

/* Once the Guest is dead, all you can do is read() why it died. */
if (lg && lg->dead)
return -ENOENT;
/* Once the Guest is dead, you can only read() why it died. */
if (lg->dead)
return -ENOENT;

/* If you're not the task which owns the Guest, you can only break */
if (lg && current != cpu->tsk && req != LHREQ_BREAK)
return -EPERM;
/* If you're not the task which owns the Guest, all you can do
* is break the Launcher out of running the Guest. */
if (current != cpu->tsk && req != LHREQ_BREAK)
return -EPERM;
}

switch (req) {
case LHREQ_INITIALIZE:
Expand Down

0 comments on commit f73d1e6

Please sign in to comment.