[PATCH] aio: remove unlocked task_list test and resulting race
authorZach Brown <zach.brown@oracle.com>
Fri, 30 Sep 2005 18:58:55 +0000 (11:58 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 30 Sep 2005 19:41:17 +0000 (12:41 -0700)
commit897f15fb587fd2772b9e7ff6ec0265057f3c3975
treed975ce5f131b8f42915cf264122cd265661651e0
parent998765e5588b197737d457e16f72832d8036190f
[PATCH] aio: remove unlocked task_list test and resulting race

Only one of the run or kick path is supposed to put an iocb on the run
list.  If both of them do it than one of them can end up referencing a
freed iocb.  The kick path could delete the task_list item from the wait
queue before getting the ctx_lock and putting the iocb on the run list.
The run path was testing the task_list item outside the lock so that it
could catch ki_retry methods that return -EIOCBRETRY *without* putting the
iocb on a wait queue and promising to call kick_iocb.  This unlocked check
could then race with the kick path to cause both to try and put the iocb on
the run list.

The patch stops the run path from testing task_list by requring that any
ki_retry that returns -EIOCBRETRY *must* guarantee that kick_iocb() will be
called in the future.  aio_p{read,write}, the only in-tree -EIOCBRETRY
users, are updated.

Signed-off-by: Zach Brown <zach.brown@oracle.com>
Signed-off-by: Benjamin LaHaise <bcrl@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/aio.c
include/linux/aio.h