mirror of
https://github.com/torvalds/linux.git
synced 2024-09-22 07:53:05 +00:00
goldfish: locking bugs in goldfish_pipe_read_write()
We recently messed up the error handling here. We can return with the
pipe->lock held or sometimes we unlock twice by mistake.
Fixes: 2f3be88237
('goldfish_pipe: Pin pages to memory while copying and other cleanups')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d40a094644
commit
5fae054c2b
|
@ -313,7 +313,7 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
|
||||||
!is_write, 0, &page, NULL);
|
!is_write, 0, &page, NULL);
|
||||||
up_read(¤t->mm->mmap_sem);
|
up_read(¤t->mm->mmap_sem);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
break;
|
||||||
|
|
||||||
if (dev->version) {
|
if (dev->version) {
|
||||||
/* Device version 1 or newer (qemu-android) expects the
|
/* Device version 1 or newer (qemu-android) expects the
|
||||||
|
@ -400,22 +400,16 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
|
||||||
while (test_bit(wakeBit, &pipe->flags)) {
|
while (test_bit(wakeBit, &pipe->flags)) {
|
||||||
if (wait_event_interruptible(
|
if (wait_event_interruptible(
|
||||||
pipe->wake_queue,
|
pipe->wake_queue,
|
||||||
!test_bit(wakeBit, &pipe->flags))) {
|
!test_bit(wakeBit, &pipe->flags)))
|
||||||
ret = -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags)) {
|
if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
|
||||||
ret = -EIO;
|
return -EIO;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to re-acquire the lock */
|
/* Try to re-acquire the lock */
|
||||||
if (mutex_lock_interruptible(&pipe->lock)) {
|
if (mutex_lock_interruptible(&pipe->lock))
|
||||||
ret = -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mutex_unlock(&pipe->lock);
|
mutex_unlock(&pipe->lock);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user