9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] kproc() bug
@ 2011-05-12 15:45 erik quanstrom
  2011-05-12 18:22 ` Charles Forsyth
  0 siblings, 1 reply; 3+ messages in thread
From: erik quanstrom @ 2011-05-12 15:45 UTC (permalink / raw)
  To: 9fans

from the last few lines of kproc (port/proc.c:/^kproc)

		ready(p);
		/*
		 *  since the bss/data segments are now shareable,
		 *  any mmu info about this process is now stale
		 *  and has to be discarded.
		 */
		p->newtlb = 1;
		flushmmu();
	}

this looks obviously wrong to me.  you can't ready the proc
before messing with it's tlb bits.  it could (just for one example)
have exited and been cleaned up before p is dereferenced to
set newtlb = 1.

wouldn't this be much safer as

		/*
		 *  since the bss/data segments are now shareable,
		 *  any mmu info about this process is now stale
		 *  and has to be discarded.
		 */
		p->newtlb = 1;
		flushmmu();

		ready(p);
	}

since this looks too obvious, is there something that i'm missing?

- erik



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] kproc() bug
  2011-05-12 15:45 [9fans] kproc() bug erik quanstrom
@ 2011-05-12 18:22 ` Charles Forsyth
  2011-05-12 21:54   ` erik quanstrom
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Forsyth @ 2011-05-12 18:22 UTC (permalink / raw)
  To: 9fans

>it could (just for one example) have exited and been cleaned up
>before p is dereferenced to set newtlb = 1.

it wouldn't matter since processes aren't deallocated, and an extra newtlb
is at worst inefficient. the kproc doesn't, however, share memory with
the current proc, and i don't think it needs to do anything at all.
(even if memory were shared, a new process starts with an empty mmu state.)
the comment is copied from another site, where it does matter,
but only for up (and flushmmu sets up->newtlb), and indeed there isn't a p->newtlb mention there.
i don't think either statement is needed, but neither will they actually cause harm.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] kproc() bug
  2011-05-12 18:22 ` Charles Forsyth
@ 2011-05-12 21:54   ` erik quanstrom
  0 siblings, 0 replies; 3+ messages in thread
From: erik quanstrom @ 2011-05-12 21:54 UTC (permalink / raw)
  To: 9fans

On Thu May 12 14:22:16 EDT 2011, forsyth@terzarima.net wrote:
> is at worst inefficient. the kproc doesn't, however, share memory with
> the current proc, and i don't think it needs to do anything at all.
> (even if memory were shared, a new process starts with an empty mmu state.)
> the comment is copied from another site, where it does matter,
> but only for up (and flushmmu sets up->newtlb), and indeed there isn't a p->newtlb mention there.
> i don't think either statement is needed, but neither will they actually cause harm.

makes sense.  although i'm paranoid.  i just delete the comment and
both lines.  i'd rather not do random things to a random process, even
if i think i can convince myself that it is at worse inefficient.  :-)

- erik



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-12 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12 15:45 [9fans] kproc() bug erik quanstrom
2011-05-12 18:22 ` Charles Forsyth
2011-05-12 21:54   ` erik quanstrom

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).