Commit f73d1e6c authored by Eugene Teo's avatar Eugene Teo Committed by Rusty Russell

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: default avatarEugene Teo <eugeneteo@kernel.sg>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent cdeeeae0
...@@ -241,15 +241,16 @@ static ssize_t write(struct file *file, const char __user *in, ...@@ -241,15 +241,16 @@ static ssize_t write(struct file *file, const char __user *in,
cpu = &lg->cpus[cpu_id]; cpu = &lg->cpus[cpu_id];
if (!cpu) if (!cpu)
return -EINVAL; return -EINVAL;
}
/* Once the Guest is dead, all you can do is read() why it died. */ /* Once the Guest is dead, you can only read() why it died. */
if (lg && lg->dead) if (lg->dead)
return -ENOENT; return -ENOENT;
/* If you're not the task which owns the Guest, you can only break */ /* If you're not the task which owns the Guest, all you can do
if (lg && current != cpu->tsk && req != LHREQ_BREAK) * is break the Launcher out of running the Guest. */
return -EPERM; if (current != cpu->tsk && req != LHREQ_BREAK)
return -EPERM;
}
switch (req) { switch (req) {
case LHREQ_INITIALIZE: case LHREQ_INITIALIZE:
......
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