OS-7096: installctx needs kpreempt_disable protection


Issue Type:Bug
Priority:4 - Normal
Created at:2018-07-27T00:48:51.856Z
Updated at:2018-07-30T14:57:22.950Z


Created by:Former user
Reported by:Former user
Assigned to:Former user


Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2018-07-30T14:57:22.939Z)

Fix Versions

2018-08-02 XCannon (Release Date: 2018-08-02)


Prior to OS-7034, updates to the ctxop list associated with a kthread were simple: The new item would update its next pointer to the value of t_ctx, then it would update t_ctx so it pointed at the new value. If a preemption occurred any time before the t_ctx update, the new item would not be called for save or restore. If it occurred after the t_ctx update, both savectx and restorectx would act upon the new time.

With the change to a doubly-linked list for ctxops, it is no longer safe to do this without kpreempt_disable protection. There is a short window between the prev field of the head item is updated and when t_ctx itself is pointed to the new item that a preemption would result in the savectx operation being skipped for the new item but the restorectx operation executing on it.

A simple application of kpreempt_disable/kpreempt_enable should be all that's needed to protect that window from danger.


Comment by Former user
Created at 2018-07-27T13:45:08.522Z

I only caught this as I was reviewing ctxop-related code. The problematic behavior described is not something I've seen in the wild.

Comment by Former user
Created at 2018-07-27T17:08:17.381Z

I booted up bits with this change as a smoke test, but haven't done gone further than that.

Comment by Jira Bot
Created at 2018-07-30T14:56:10.847Z

illumos-joyent commit 84b3dff9b0680a7c2e5ce7f1066fedc9ef036560 (branch master, by Patrick Mooney)

OS-7096 installctx needs kpreempt_disable protection
Reviewed by: John Levon <john.levon@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>