diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-03-21 19:34:53 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:27:11 -0400 |
commit | 32a56afa23e157b444b6c2b943322ea0d119517b (patch) | |
tree | ffcc151eba2b440f2a200f9e2e545f0e31570e72 | |
parent | 345995fa48c599210fd339a768eb68dead430b79 (diff) |
aio_setup_vectored_rw(): switch to {compat_,}import_iovec()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/aio.c | 28 |
1 files changed, 9 insertions, 19 deletions
@@ -1357,23 +1357,14 @@ static int aio_setup_vectored_rw(int rw, char __user *buf, size_t len, | |||
1357 | bool compat, | 1357 | bool compat, |
1358 | struct iov_iter *iter) | 1358 | struct iov_iter *iter) |
1359 | { | 1359 | { |
1360 | ssize_t ret; | ||
1361 | |||
1362 | #ifdef CONFIG_COMPAT | 1360 | #ifdef CONFIG_COMPAT |
1363 | if (compat) | 1361 | if (compat) |
1364 | ret = compat_rw_copy_check_uvector(rw, | 1362 | return compat_import_iovec(rw, |
1365 | (struct compat_iovec __user *)buf, | 1363 | (struct compat_iovec __user *)buf, |
1366 | len, UIO_FASTIOV, *iovec, iovec); | 1364 | len, UIO_FASTIOV, iovec, iter); |
1367 | else | ||
1368 | #endif | 1365 | #endif |
1369 | ret = rw_copy_check_uvector(rw, | 1366 | return import_iovec(rw, (struct iovec __user *)buf, |
1370 | (struct iovec __user *)buf, | 1367 | len, UIO_FASTIOV, iovec, iter); |
1371 | len, UIO_FASTIOV, *iovec, iovec); | ||
1372 | if (ret < 0) | ||
1373 | return ret; | ||
1374 | |||
1375 | iov_iter_init(iter, rw, *iovec, len, ret); | ||
1376 | return 0; | ||
1377 | } | 1368 | } |
1378 | 1369 | ||
1379 | /* | 1370 | /* |
@@ -1418,14 +1409,15 @@ rw_common: | |||
1418 | if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) | 1409 | if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) |
1419 | ret = aio_setup_vectored_rw(rw, buf, len, | 1410 | ret = aio_setup_vectored_rw(rw, buf, len, |
1420 | &iovec, compat, &iter); | 1411 | &iovec, compat, &iter); |
1421 | else | 1412 | else { |
1422 | ret = import_single_range(rw, buf, len, iovec, &iter); | 1413 | ret = import_single_range(rw, buf, len, iovec, &iter); |
1414 | iovec = NULL; | ||
1415 | } | ||
1423 | if (!ret) | 1416 | if (!ret) |
1424 | ret = rw_verify_area(rw, file, &req->ki_pos, | 1417 | ret = rw_verify_area(rw, file, &req->ki_pos, |
1425 | iov_iter_count(&iter)); | 1418 | iov_iter_count(&iter)); |
1426 | if (ret < 0) { | 1419 | if (ret < 0) { |
1427 | if (iovec != inline_vecs) | 1420 | kfree(iovec); |
1428 | kfree(iovec); | ||
1429 | return ret; | 1421 | return ret; |
1430 | } | 1422 | } |
1431 | 1423 | ||
@@ -1449,6 +1441,7 @@ rw_common: | |||
1449 | 1441 | ||
1450 | if (rw == WRITE) | 1442 | if (rw == WRITE) |
1451 | file_end_write(file); | 1443 | file_end_write(file); |
1444 | kfree(iovec); | ||
1452 | break; | 1445 | break; |
1453 | 1446 | ||
1454 | case IOCB_CMD_FDSYNC: | 1447 | case IOCB_CMD_FDSYNC: |
@@ -1470,9 +1463,6 @@ rw_common: | |||
1470 | return -EINVAL; | 1463 | return -EINVAL; |
1471 | } | 1464 | } |
1472 | 1465 | ||
1473 | if (iovec != inline_vecs) | ||
1474 | kfree(iovec); | ||
1475 | |||
1476 | if (ret != -EIOCBQUEUED) { | 1466 | if (ret != -EIOCBQUEUED) { |
1477 | /* | 1467 | /* |
1478 | * There's no easy way to restart the syscall since other AIO's | 1468 | * There's no easy way to restart the syscall since other AIO's |