Message ID | fa9c9a3ee7355f932d4f40322602aae5fb293f97.1467358615.git.osandov@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 07/01/2016 01:39 AM, Omar Sandoval wrote: > From: Omar Sandoval <osandov@fb.com> > > get_task_ioprio() accesses the task->io_context without holding the task > lock and thus can race with exit_io_context(), leading to a > use-after-free. The reproducer below hits this within a few seconds on > my 4-core QEMU VM: Thanks Omar, applied for this series.
diff --git a/block/ioprio.c b/block/ioprio.c index cc7800e9eb44..01b8116298a1 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -150,8 +150,10 @@ static int get_task_ioprio(struct task_struct *p) if (ret) goto out; ret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM); + task_lock(p); if (p->io_context) ret = p->io_context->ioprio; + task_unlock(p); out: return ret; }