Skip to content

Commit

Permalink
dm io: make sync_io uninterruptible
Browse files Browse the repository at this point in the history
If someone sends signal to a process performing synchronous dm-io call,
the kernel may crash.

The function sync_io attempts to exit with -EINTR if it has pending signal,
however the structure "io" is allocated on stack, so already submitted io
requests end up touching unallocated stack space and corrupting kernel memory.

sync_io sets its state to TASK_UNINTERRUPTIBLE, so the signal can't break out
of io_schedule() --- however, if the signal was pending before sync_io entered
while (1) loop, the corruption of kernel memory will happen.

There is no way to cancel in-progress IOs, so the best solution is to ignore
signals at this point.

Cc: [email protected]
Signed-off-by: Mikulas Patocka <[email protected]>
Signed-off-by: Alasdair G Kergon <[email protected]>
  • Loading branch information
Mikulas Patocka authored and kergon committed Apr 2, 2009
1 parent 95f8fac commit b64b6bf
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/md/dm-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,13 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
while (1) {
set_current_state(TASK_UNINTERRUPTIBLE);

if (!atomic_read(&io.count) || signal_pending(current))
if (!atomic_read(&io.count))
break;

io_schedule();
}
set_current_state(TASK_RUNNING);

if (atomic_read(&io.count))
return -EINTR;

if (error_bits)
*error_bits = io.error_bits;

Expand Down

0 comments on commit b64b6bf

Please sign in to comment.