LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] lguest: make sure cpu is initialized before accessing it
@ 2008-02-09 15:53 Eugene Teo
[not found] ` <200803041015.48290.rusty@rustcorp.com.au>
0 siblings, 1 reply; 2+ messages in thread
From: Eugene Teo @ 2008-02-09 15:53 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel, lguest
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>
---
drivers/lguest/lguest_user.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 85d42d3..9cbb285 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -241,15 +241,15 @@ 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, all you can do is read() why it died. */
+ if (lg && 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, you can only break */
+ if (lg && current != cpu->tsk && req != LHREQ_BREAK)
+ return -EPERM;
+ }
switch (req) {
case LHREQ_INITIALIZE:
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lguest: make sure cpu is initialized before accessing it
[not found] ` <200803041015.48290.rusty@rustcorp.com.au>
@ 2008-03-04 0:19 ` Rusty Russell
0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2008-03-04 0:19 UTC (permalink / raw)
To: Eugene Teo; +Cc: linux-kernel, lguest
On Tuesday 04 March 2008 10:15:47 Rusty Russell wrote:
> On Sunday 10 February 2008 02:53:17 Eugene Teo wrote:
> > 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>
Thanks Eugene, I've applied this with some wrapping of the comments and
removal of the now-redundant lg != NULL tests:
> > + /* Once the Guest is dead, all you can do is read() why it died. */
> > + if (lg && 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, you can only break */
> > + if (lg && current != cpu->tsk && req != LHREQ_BREAK)
> > + return -EPERM;
> > + }
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-04 0:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-09 15:53 [PATCH] lguest: make sure cpu is initialized before accessing it Eugene Teo
[not found] ` <200803041015.48290.rusty@rustcorp.com.au>
2008-03-04 0:19 ` Rusty Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).