Skip to content

Commit 1354d7a

Browse files
author
Ming Lei
committed
lib/iov_iter: fix import_iovec_ubuf iovec management
JIRA: https://issues.redhat.com/browse/RHEL-87739 commit f4b7826 Author: Pavel Begunkov <asml.silence@gmail.com> Date: Fri Jan 31 14:13:15 2025 +0000 lib/iov_iter: fix import_iovec_ubuf iovec management import_iovec() says that it should always be fine to kfree the iovec returned in @iovp regardless of the error code. __import_iovec_ubuf() never reallocates it and thus should clear the pointer even in cases when copy_iovec_*() fail. Link: https://lkml.kernel.org/r/378ae26923ffc20fd5e41b4360d673bf47b1775b.1738332461.git.asml.silence@gmail.com Fixes: 3b2deb0 ("iov_iter: import single vector iovecs as ITER_UBUF") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Jens Axboe <axboe@kernel.dk> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <brauner@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent f77b236 commit 1354d7a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/iov_iter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,8 @@ static ssize_t __import_iovec_ubuf(int type, const struct iovec __user *uvec,
18391839
struct iovec *iov = *iovp;
18401840
ssize_t ret;
18411841

1842+
*iovp = NULL;
1843+
18421844
if (compat)
18431845
ret = copy_compat_iovec_from_user(iov, uvec, 1);
18441846
else
@@ -1849,7 +1851,6 @@ static ssize_t __import_iovec_ubuf(int type, const struct iovec __user *uvec,
18491851
ret = import_ubuf(type, iov->iov_base, iov->iov_len, i);
18501852
if (unlikely(ret))
18511853
return ret;
1852-
*iovp = NULL;
18531854
return i->count;
18541855
}
18551856

0 commit comments

Comments
 (0)