Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread cinap_lenrek
i attached it in a previous mail... try again... -- cinap --- Begin Message --- > process1: > still in kernel: > memmove(buf, ...) > *fault* > trap() > fault386() > fault() => -1 >

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread Charles Forsyth
you can get similar effects by remapping things. i meant that it isn't likely to happen by accident, so am i bovvered? fault386 needs to be fixed mainly by or for people running a shared cpu server with hostile users (ie, students). for the rest of us it might be more useful to have the panic to pr

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread erik quanstrom
> it ensures mmuflushes in all other processes (sharing that segment) as well. > in fact, the crash you describe just emphasises that point: > the page reference no longer exists, hence the fault. > > the problem (which frankly doesn't bother me) is that fault386 > is being overly cautious in assu

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread Charles Forsyth
>but my testcase crashes a uniprocessor system, so here is no >waiting for mmuflushes on other processors going on. it ensures mmuflushes in all other processes (sharing that segment) as well. in fact, the crash you describe just emphasises that point: the page reference no longer exists, hence th

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread Devon H. O'Dell
2009/7/31 erik quanstrom : >> > could you be more specific.  what is your test program, >> > where is it crashing (if you know), and what is the panic >> > message, if any?  i must be dense, but i'm confused by >> > your process diagram. >> >> He posted it earlier in this thread >> >> --dho > > ple

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread erik quanstrom
> > could you be more specific.  what is your test program, > > where is it crashing (if you know), and what is the panic > > message, if any?  i must be dense, but i'm confused by > > your process diagram. > > He posted it earlier in this thread > > --dho please post a reference. i do not see

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread Devon H. O'Dell
2009/7/31 erik quanstrom : >> process1: >>       still in kernel: >>               memmove(buf, ...) >>               *fault* >>               trap() >>                       fault386() >>                               fault() => -1 >>                               if(!user){ >>                    

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread erik quanstrom
> process1: > still in kernel: > memmove(buf, ...) > *fault* > trap() > fault386() > fault() => -1 > if(!user){ > panic() >

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread cinap_lenrek
very interesting. thanks for the sum up. but my testcase crashes a uniprocessor system, so here is no waiting for mmuflushes on other processors going on. any other process that shares the segment and was suspended in the kernel may potentialy hold a pointer to that freed memory area of the segme

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread Richard Miller
> ... procflushseg finds all processes that share s, sets them all up > to flush their mmu states, and also sets any processor running such a process > to flush its state (that's picked up by a clock interrupt). > > procflushseg will not proceed until all processes and processors that > might need

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-31 Thread Charles Forsyth
this resulted in a little side discussion. to save someone else from having to break a strong oath about 9fans, i'll sum it up. the existing code handles this situation. when several processes share a segment, and any one of them decides to shrink the segment, all the processes must see the change

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread Charles Forsyth
just stop processes with s->ref > 1 from freeing parts of s with ibrk. it's not as if anything ever does in practice.

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread erik quanstrom
> I think you may be right, Elly. Multithreaded programs indeed have their > stack running outside the stack segment, so this could happen there. > splhi won't even do on a multiprocessor. One should probably lock down > the segment. > We've never seen this happen, of course — or rather, we haven

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread cinap_lenrek
... but you can still shrink segments for other processes :-) (this crashes the kernel) -- cinap --- Begin Message --- hm... what about the other stuff port/sysfile.c? they also just checks pointers with validaddr and then call into the device handler without locking anything / holding anything.

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread cinap_lenrek
ok, forget it... the segments are actualy reference counted. so a process would not be able to unmap a segment in another process. -- cinap --- Begin Message --- > On Thu, 30 Jul 2009, erik quanstrom wrote: > >> On Thu Jul 30 00:05:45 EDT 2009, el...@andrew.cmu.edu wrote: >>> My familiarity with

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread cinap_lenrek
hm... what about the other stuff port/sysfile.c? they also just checks pointers with validaddr and then call into the device handler without locking anything / holding anything. -- cinap --- Begin Message --- > On Thu, 30 Jul 2009, erik quanstrom wrote: > >> On Thu Jul 30 00:05:45 EDT 2009, el.

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread erik quanstrom
> > plan 9 threads are cooperatively scheduled. so > > the correct term is proc. but you are correct, > > another proc sharing memory with this one > > could be running. however, that proc would > > not have access to this proc's stack. (rfork > > doesn't allow shared stack.) and even if it >

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread Sape Mullender
> On Thu, 30 Jul 2009, erik quanstrom wrote: > >> On Thu Jul 30 00:05:45 EDT 2009, el...@andrew.cmu.edu wrote: >>> My familiarity with the kernel source code is superficial to say the >>> least, but it seems to me that this code (from /sys/src/9/pc/trap.c) >>> contains a race condition: >>> >>>

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread Elizabeth Jones
On Thu, 30 Jul 2009, erik quanstrom wrote: On Thu Jul 30 00:05:45 EDT 2009, el...@andrew.cmu.edu wrote: My familiarity with the kernel source code is superficial to say the least, but it seems to me that this code (from /sys/src/9/pc/trap.c) contains a race condition: 702 if(sp<(USTK

Re: [9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-30 Thread erik quanstrom
On Thu Jul 30 00:05:45 EDT 2009, el...@andrew.cmu.edu wrote: > My familiarity with the kernel source code is superficial to say the > least, but it seems to me that this code (from /sys/src/9/pc/trap.c) > contains a race condition: > > 702 if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sa

[9fans] Race condition in /sys/src/9/pc/trap.c?

2009-07-29 Thread Matthew J Jones
My familiarity with the kernel source code is superficial to say the least, but it seems to me that this code (from /sys/src/9/pc/trap.c) contains a race condition: 702 if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs)-BY2WD)) 703 validaddr(sp, sizeof(Sargs)+BY2WD, 0); 7