Check notif_pending early in pop_user_ctx()
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 20 Apr 2016 22:03:14 +0000 (15:03 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 May 2016 21:11:15 +0000 (17:11 -0400)
commit7506964a4e71c237a18e8a16701e86cf2e97a154
treeed6e98ef5e87ec81c9eadc7a39b4a59e4f5f70f4
parente4a5c00e54b07fe8f5cd90856defa43905128029
Check notif_pending early in pop_user_ctx()

If notif_pending was set any time after being cleared (handle_events())
and before we fully popped the context, the pop would fail and we'd inch
our way down the uthread's stack.  If that happened every time (perhaps
due to a buggy 2LS, or a 2LS that receives regular events and does a
decent amount of processing during that window), then we'd eventually
run off the end of the stack in proc_pop_ctx.

The vulnerable window still exists, but it is shrunk down a lot.  You'd
have to get notif_pending set after the check *and* not before the
check.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/include/parlib/riscv/vcore.h
user/parlib/x86/vcore.c