git: c987ff4d7bd2 - main - linux(4): Replace linux32_copyinuio by freebsd32_copyinuio

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Sun, 20 Aug 2023 07:37:54 UTC
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=c987ff4d7bd25e9186ffca84c7e873fd7382a1c7

commit c987ff4d7bd25e9186ffca84c7e873fd7382a1c7
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-08-20 07:36:32 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-08-20 07:36:32 +0000

    linux(4): Replace linux32_copyinuio by freebsd32_copyinuio
    
    MFC after:              1 month
---
 sys/amd64/linux32/linux.h           |  2 --
 sys/amd64/linux32/linux32_machdep.c | 43 +------------------------------------
 sys/compat/linux/linux_file.c       |  4 ++--
 3 files changed, 3 insertions(+), 46 deletions(-)

diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h
index 1feac8788292..382d010f9ed8 100644
--- a/sys/amd64/linux32/linux.h
+++ b/sys/amd64/linux32/linux.h
@@ -398,8 +398,6 @@ struct l_iovec32 {
 
 int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt,
 			    struct iovec **iovp, int error);
-int linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt,
-			    struct uio **uiop);
 int linux_copyout_rusage(struct rusage *ru, void *uaddr);
 #endif /* _KERNEL */
 
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index ac8234503bdd..e0364f1e00d1 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -113,47 +113,6 @@ linux_copyout_rusage(struct rusage *ru, void *uaddr)
 
 CTASSERT(sizeof(struct l_iovec32) == 8);
 
-int
-linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, struct uio **uiop)
-{
-	struct l_iovec32 iov32;
-	struct iovec *iov;
-	struct uio *uio;
-	uint32_t iovlen;
-	int error, i;
-
-	*uiop = NULL;
-	if (iovcnt > UIO_MAXIOV)
-		return (EINVAL);
-	iovlen = iovcnt * sizeof(struct iovec);
-	uio = malloc(iovlen + sizeof(*uio), M_IOV, M_WAITOK);
-	iov = (struct iovec *)(uio + 1);
-	for (i = 0; i < iovcnt; i++) {
-		error = copyin(&iovp[i], &iov32, sizeof(struct l_iovec32));
-		if (error) {
-			free(uio, M_IOV);
-			return (error);
-		}
-		iov[i].iov_base = PTRIN(iov32.iov_base);
-		iov[i].iov_len = iov32.iov_len;
-	}
-	uio->uio_iov = iov;
-	uio->uio_iovcnt = iovcnt;
-	uio->uio_segflg = UIO_USERSPACE;
-	uio->uio_offset = -1;
-	uio->uio_resid = 0;
-	for (i = 0; i < iovcnt; i++) {
-		if (iov->iov_len > INT_MAX - uio->uio_resid) {
-			free(uio, M_IOV);
-			return (EINVAL);
-		}
-		uio->uio_resid += iov->iov_len;
-		iov++;
-	}
-	*uiop = uio;
-	return (0);
-}
-
 int
 linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, struct iovec **iovp,
     int error)
@@ -188,7 +147,7 @@ linux_readv(struct thread *td, struct linux_readv_args *uap)
 	struct uio *auio;
 	int error;
 
-	error = linux32_copyinuio(uap->iovp, uap->iovcnt, &auio);
+	error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
 	if (error)
 		return (error);
 	error = kern_readv(td, uap->fd, auio);
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index c3b69e54d257..6eab8980a5c5 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -1031,7 +1031,7 @@ linux_preadv(struct thread *td, struct linux_preadv_args *uap)
 	if (offset < 0)
 		return (EINVAL);
 #ifdef COMPAT_LINUX32
-	error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
+	error = freebsd32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
 #else
 	error = copyinuio(uap->vec, uap->vlen, &auio);
 #endif
@@ -1058,7 +1058,7 @@ linux_pwritev(struct thread *td, struct linux_pwritev_args *uap)
 	if (offset < 0)
 		return (EINVAL);
 #ifdef COMPAT_LINUX32
-	error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
+	error = freebsd32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
 #else
 	error = copyinuio(uap->vec, uap->vlen, &auio);
 #endif