aio: fix potential leak in aio_run_iocb().
PATCH 1/1 aio: fix potential leak in aio_run_iocb().
iovec should be reclaimed whenever caller of rw_copy_check_uvector() returns, but it doesn't hold when failure happens right after aio_setup_vectored_rw().
Fix that in a such way to avoid hairy goto.
--- fs/aio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/aio.c +2 -4
@@ -1299,10 +1299,8 @@ rw_common: &iovec, compat) :aio_setup_single_vector (req, rw, buf, &nr_segs, iovec); -if (ret) -return ret; - - ret =rw_verify_area (rw, file, &req->ki_pos, req->ki_nbytes); +if (!ret) + ret =rw_verify_area (rw, file, &req->ki_pos, req->ki_nbytes);if (ret <0 ) {if (iovec != &inline_vec)kfree (iovec);
Signature · 7 lines
1.9.2 -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"[email protected]">[email protected]</a>
Quoted 3 lines · Leon Yu
iovec should be reclaimed whenever caller of
rw_copy_check_uvector()returns, but it doesn't hold when failure happens right afteraio_setup_vectored_rw().
There is a proposal (wich a patch) to modify semantics of rw_copy_check_uvector so that it frees stuff on error, taking care of this case as well:
https://lkml.org/lkml/2014/4/25/778
Signature · 7 lines
Mateusz Guzik -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"[email protected]">[email protected]</a>
Benjamin LaHaise
maintainerQuoted 4 lines · Leon Yu
iovec should be reclaimed whenever caller of
rw_copy_check_uvector()returns, but it doesn't hold when failure happens right afteraio_setup_vectored_rw().Fix that in a such way to avoid hairy goto.
Good catch -- applied.
-ben
Quoted 24 lines
Signed-off-by Leon Yu <[email protected]>--- fs/aio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/aio.c +2
-4@@ -1299,10 +1299,8 @@ rw_common: &iovec, compat) :aio_setup_single_vector (req, rw, buf, &nr_segs, iovec); -if (ret) -return ret; - - ret =rw_verify_area (rw, file, &req->ki_pos, req->ki_nbytes); +if (!ret) + ret =rw_verify_area (rw, file, &req->ki_pos, req->ki_nbytes);if (ret <0 ) {if (iovec != &inline_vec)kfree (iovec);Signature · 1 line
1.9.2
Signature · 7 lines
"Thought is the essence of where you are now." -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"[email protected]">[email protected]</a>
Quoted 8 lines · Leon Yu
Date: Thu, 1 May 2014 03:31:28 +0000
From: Leon Yu <[email protected]>
To: Benjamin LaHaise <[email protected]>,
Alexander Viro <[email protected]>
Cc: [email protected], [email protected],
[email protected], Leon Yu <[email protected]>
Subject: [PATCH] aio: fix potential leak inaio_run_iocb().
Quoted 4 lines
iovec should be reclaimed whenever caller of
rw_copy_check_uvector()returns, but it doesn't hold when failure happens right afteraio_setup_vectored_rw().Fix that in a such way to avoid hairy goto.
Hi,
this does not seem right, see bellow
Quoted 11 lines
Signed-off-by Leon Yu <[email protected]>--- fs/aio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/aio.c +0
-0
fs/aio.c rw_common: · line 1305
Quoted 7 lines
fs/aio.c +0
-4@@ -1299,10 +1299,8 @@ rw_common: &iovec, compat) :aio_setup_single_vector (req, rw, buf, &nr_segs, iovec); -if (ret) -return ret; - - ret =rw_verify_area (rw, file, &req->ki_pos, req->ki_nbytes);
here ret could be possibly set to a positive number.
fs/aio.c rw_common: · line 1304
Quoted 3 lines
fs/aio.c +2
-0+if (!ret) + ret =rw_verify_area (rw, file, &req->ki_pos, req->ki_nbytes);if (ret <0 ) {
but here we're checking for negative and bail out. However this changes the way it worked before this patch and the iovec would not be reclaimed anyway as you mentioned in the commit description.
Thanks!
-Lukas
fs/aio.c rw_common: · line 1306
Quoted 2 lines
fs/aio.c +0
-0if (iovec != &inline_vec)kfree (iovec);
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>