io_uring: ensure open/openat2 name is cleaned on cancelation
Jens Axboe
maintainerPATCH 1/1 io_uring: ensure open/openat2 name is cleaned on cancelation
io_uring: ensure open/openat2 name is cleaned on cancelation
If we cancel these requests, we'll leak the memory associated with the filename. Add them to the table of ops that need cleaning, if REQ_F_NEED_CLEANUP is set.
--
fs/io_uring.c +5 -0
@@ -5671,6 +5671,11 @@ static void __io_clean_op(struct io_kiocb *req)io_put_file (req, req->splice.file_in, (req->splice.flags &SPLICE_F_FD_IN_FIXED ));break ; +case IORING_OP_OPENAT : +case IORING_OP_OPENAT2 : +if (req->open.filename) +putname (req->open.filename); +break ; } req->flags &= ~REQ_F_NEED_CLEANUP ; }
Signature · 1 line
Jens Axboe
Quoted 6 lines · Jens Axboe
io_uring: ensure open/openat2 name is cleaned on cancelationIf we cancel these requests, we'll leak the memory associated with the filename. Add them to the table of ops that need cleaning, if
REQ_F_NEED_CLEANUPis set.
IIUC we inadvertently removed 'putname(req->open.filename)' from the cleanup function in commit e62753e4e292 ("io_uring: call statx directly").
Should we add the Fixes tag?
Fixes: e62753e4e292 ("io_uring: call statx directly")I'm not sure since the code is changed a bit.
Anyway the patch LGTM:
Thanks,
Stefano
Quoted 25 lines
Cc [email protected] # v5.6+Signed-off-by Jens Axboe <[email protected]>--
fs/io_uring.c +5
-0@@ -5671,6 +5671,11 @@ static void __io_clean_op(struct io_kiocb *req)io_put_file (req, req->splice.file_in, (req->splice.flags &SPLICE_F_FD_IN_FIXED ));break ; +case IORING_OP_OPENAT : +case IORING_OP_OPENAT2 : +if (req->open.filename) +putname (req->open.filename); +break ; } req->flags &= ~REQ_F_NEED_CLEANUP ; }Signature · 2 lines
-- Jens Axboe
Jens Axboe
maintainerQuoted 8 lines · Stefano Garzarella
Quoted 6 lines · Jens Axboe
io_uring: ensure open/openat2 name is cleaned on cancelationIf we cancel these requests, we'll leak the memory associated with the filename. Add them to the table of ops that need cleaning, if
REQ_F_NEED_CLEANUPis set.
Quoted 6 lines
IIUC we inadvertently removed '
putname(req->open.filename)' from the cleanup function in commite62753e4e292("io_uring: call statx directly").Should we add the Fixes tag?
Fixes: e62753e4e292 ("io_uring: call statx directly")
You are right, I got a bit tricked by it since that commit removed the putname(), and then later on we got rid of the (now) empty openat/openat2 entries.
I'll add the fixes, which means it's 5.8 only.
Quoted 1 line
Reviewed-by Stefano Garzarella <[email protected]>
Added, thanks for reviewing!
Signature · 1 line
Jens Axboe