Skip to contentSkip to conversation

io_uring/net: ensure compat import handlers clear free_iov

PATCH In review Jens Axboe 2 participants 3 messages Dec 19, 2022 – Dec 20, 2022 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH v2 1/1 io_uring/net: ensure compat import handlers clear free_iov

If we're not allocating the vectors because the count is below UIO_FASTIOV, we still do need to properly clear ->free_iov to prevent an erronous free of on-stack data.

Fixes 4c17a496a7a0 ("io_uring/net: fix cleanup double free free_iov init")

---

v2: let's play it a bit safer and just always clear at the top rather
in the individual cases.

io_uring/net.c +1 -0
index 5229976cb582..f76b688f476e 100644
@@ -494,6 +494,7 @@ static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req,
 	if (req->flags & REQ_F_BUFFER_SELECT) {
 		compat_ssize_t clen;
 
+		iomsg->free_iov = NULL;
 		if (msg.msg_iovlen == 0) {
 			sr->len = 0;
 		} else if (msg.msg_iovlen > 1) {
Signature · 1 line
Jens Axboe
Tested-by on v2 1/1
#1 lore raw
Quoted 8 lines · Jens Axboe

If we're not allocating the vectors because the count is below UIO_FASTIOV, we still do need to properly clear ->free_iov to prevent an erronous free of on-stack data.

Fixes 4c17a496a7a0 ("io_uring/net: fix cleanup double free free_iov init")
Quoted 11 lines

---

v2: let's play it a bit safer and just always clear at the top rather
in the individual cases.

io_uring/net.c +0 -0
index 5229976cb582..f76b688f476e 100644

io_uring/net.c static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req, · line 500

Quoted 7 lines
io_uring/net.c +1 -0
@@ -494,6 +494,7 @@ static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req,
  	if (req->flags & REQ_F_BUFFER_SELECT) {
  		compat_ssize_t clen;
 
+		iomsg->free_iov = NULL;
  		if (msg.msg_iovlen == 0) {
  			sr->len = 0;
  		} else if (msg.msg_iovlen > 1) {

thanks,

Signature · 2 lines
js
suse labs
author maintainer
#2 lore raw
Quoted 11 lines · Jiri Slaby
Quoted 8 lines · Jens Axboe

If we're not allocating the vectors because the count is below UIO_FASTIOV, we still do need to properly clear ->free_iov to prevent an erronous free of on-stack data.

Fixes 4c17a496a7a0 ("io_uring/net: fix cleanup double free free_iov init")

Thanks for testing (and reporting).

Signature · 1 line
Jens Axboe