diff options
author | Eugene Teo <eugeneteo@kernel.sg> | 2008-02-09 18:53:17 +0300 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-03-11 01:35:56 +0300 |
commit | f73d1e6ca6985b43a1871467463cba632fbc624d (patch) | |
tree | 84b01e87f41bf960c58b6934142da31f6d1638eb /drivers/lguest/lguest_user.c | |
parent | cdeeeae056a429e729ae9e914fa8142ee45bee93 (diff) | |
download | linux-f73d1e6ca6985b43a1871467463cba632fbc624d.tar.xz |
lguest: make sure cpu is initialized before accessing it
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 <eugeneteo@kernel.sg>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/lguest_user.c')
-rw-r--r-- | drivers/lguest/lguest_user.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c index 85d42d3d01a9..2221485b0773 100644 --- a/drivers/lguest/lguest_user.c +++ b/drivers/lguest/lguest_user.c @@ -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: |