Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F170909161
D59413.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D59413.diff
View Options
diff --git a/share/man/man9/uio.9 b/share/man/man9/uio.9
--- a/share/man/man9/uio.9
+++ b/share/man/man9/uio.9
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 7, 2026
+.Dd September 4, 2026
.Dt UIO 9
.Os
.Sh NAME
@@ -49,13 +49,13 @@
.Ed
.Pp
.Ft int
-.Fn uiomove "void *buf" "int howmuch" "struct uio *uiop"
+.Fn uiomove "void *buf" "size_t len" "struct uio *uiop"
.Ft int
-.Fn uiomove_frombuf "void *buf" "int howmuch" "struct uio *uiop"
+.Fn uiomove_frombuf "void *buf" "size_t len" "struct uio *uiop"
.Ft int
-.Fn uiomove_fromphys "vm_page_t ma[]" "vm_offset_t offset" "int howmuch" "struct uio *uiop"
+.Fn uiomove_fromphys "vm_page_t ma[]" "vm_offset_t offset" "size_t len" "struct uio *uiop"
.Ft int
-.Fn uiomove_nofault "void *buf" "int howmuch" "struct uio *uiop"
+.Fn uiomove_nofault "void *buf" "size_t len" "struct uio *uiop"
.Sh DESCRIPTION
The functions
.Fn uiomove ,
diff --git a/sys/amd64/amd64/uio_machdep.c b/sys/amd64/amd64/uio_machdep.c
--- a/sys/amd64/amd64/uio_machdep.c
+++ b/sys/amd64/amd64/uio_machdep.c
@@ -55,7 +55,8 @@
* avoid the creation and destruction of ephemeral mappings.
*/
int
-uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
+uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, size_t len,
+ struct uio *uio)
{
struct iovec *iov;
void *cp, *vaddr;
@@ -74,7 +75,9 @@
save = curthread_pflags_set(TDP_DEADLKTREAT);
mapped = false;
- while (n > 0 && uio->uio_resid) {
+ if (len > uio->uio_resid)
+ len = uio->uio_resid;
+ while (len > 0 && uio->uio_resid != 0) {
KASSERT(uio->uio_iovcnt > 0,
("%s: uio %p iovcnt underflow", __func__, uio));
@@ -85,8 +88,8 @@
uio->uio_iovcnt--;
continue;
}
- if (cnt > n)
- cnt = n;
+ if (cnt > len)
+ cnt = len;
page_offset = offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - page_offset);
if (uio->uio_segflg != UIO_NOCOPY) {
@@ -107,7 +110,7 @@
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
offset += cnt;
- n -= cnt;
+ len -= cnt;
}
curthread_pflags_restore(save);
return (error);
diff --git a/sys/arm/arm/uio_machdep.c b/sys/arm/arm/uio_machdep.c
--- a/sys/arm/arm/uio_machdep.c
+++ b/sys/arm/arm/uio_machdep.c
@@ -54,7 +54,8 @@
* avoid the creation and destruction of ephemeral mappings.
*/
int
-uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
+uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, size_t len,
+ struct uio *uio)
{
struct iovec *iov;
void *cp;
@@ -72,7 +73,9 @@
("%s: uio %p resid underflow", __func__, uio));
save = curthread_pflags_set(TDP_DEADLKTREAT);
- while (n > 0 && uio->uio_resid) {
+ if (len > uio->uio_resid)
+ len = uio->uio_resid;
+ while (len > 0 && uio->uio_resid != 0) {
KASSERT(uio->uio_iovcnt > 0,
("%s: uio %p iovcnt underflow", __func__, uio));
@@ -83,8 +86,8 @@
uio->uio_iovcnt--;
continue;
}
- if (cnt > n)
- cnt = n;
+ if (cnt > len)
+ cnt = len;
page_offset = offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - page_offset);
sf = sf_buf_alloc(ma[offset >> PAGE_SHIFT], 0);
@@ -98,7 +101,7 @@
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
offset += cnt;
- n -= cnt;
+ len -= cnt;
}
curthread_pflags_restore(save);
return (error);
diff --git a/sys/arm64/arm64/uio_machdep.c b/sys/arm64/arm64/uio_machdep.c
--- a/sys/arm64/arm64/uio_machdep.c
+++ b/sys/arm64/arm64/uio_machdep.c
@@ -51,7 +51,8 @@
* avoid the creation and destruction of ephemeral mappings.
*/
int
-uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
+uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, size_t len,
+ struct uio *uio)
{
struct iovec *iov;
void *cp, *vaddr;
@@ -70,7 +71,9 @@
save = curthread_pflags_set(TDP_DEADLKTREAT);
mapped = false;
- while (n > 0 && uio->uio_resid) {
+ if (len > uio->uio_resid)
+ len = uio->uio_resid;
+ while (len > 0 && uio->uio_resid != 0) {
KASSERT(uio->uio_iovcnt > 0,
("%s: uio %p iovcnt underflow", __func__, uio));
@@ -81,8 +84,8 @@
uio->uio_iovcnt--;
continue;
}
- if (cnt > n)
- cnt = n;
+ if (cnt > len)
+ cnt = len;
page_offset = offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - page_offset);
if (uio->uio_segflg != UIO_NOCOPY) {
@@ -103,7 +106,7 @@
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
offset += cnt;
- n -= cnt;
+ len -= cnt;
}
curthread_pflags_restore(save);
return (error);
diff --git a/sys/i386/i386/uio_machdep.c b/sys/i386/i386/uio_machdep.c
--- a/sys/i386/i386/uio_machdep.c
+++ b/sys/i386/i386/uio_machdep.c
@@ -53,7 +53,8 @@
* the creation and destruction of ephemeral mappings.
*/
int
-uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
+uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, size_t len,
+ struct uio *uio)
{
struct sf_buf *sf;
struct iovec *iov;
@@ -71,7 +72,9 @@
("%s: uio %p resid underflow", __func__, uio));
save = curthread_pflags_set(TDP_DEADLKTREAT);
- while (n > 0 && uio->uio_resid) {
+ if (len > uio->uio_resid)
+ len = uio->uio_resid;
+ while (len > 0 && uio->uio_resid != 0) {
KASSERT(uio->uio_iovcnt > 0,
("%s: uio %p iovcnt underflow", __func__, uio));
@@ -82,8 +85,8 @@
uio->uio_iovcnt--;
continue;
}
- if (cnt > n)
- cnt = n;
+ if (cnt > len)
+ cnt = len;
page_offset = offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - page_offset);
sched_pin();
@@ -99,7 +102,7 @@
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
offset += cnt;
- n -= cnt;
+ len -= cnt;
}
curthread_pflags_restore(save);
return (error);
diff --git a/sys/kern/subr_uio.c b/sys/kern/subr_uio.c
--- a/sys/kern/subr_uio.c
+++ b/sys/kern/subr_uio.c
@@ -64,7 +64,7 @@
SYSCTL_INT(_kern, KERN_IOV_MAX, iov_max, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, UIO_MAXIOV,
"Maximum number of elements in an I/O vector; sysconf(_SC_IOV_MAX)");
-static int uiomove_faultflag(void *cp, int n, struct uio *uio, int nofault);
+static int uiomove_faultflag(void *cp, size_t len, struct uio *uio, bool nofault);
int
copyin_nofault(const void *udaddr, void *kaddr, size_t len)
@@ -211,17 +211,15 @@
}
int
-uiomove(void *cp, int n, struct uio *uio)
+uiomove(void *cp, size_t len, struct uio *uio)
{
-
- return (uiomove_faultflag(cp, n, uio, 0));
+ return (uiomove_faultflag(cp, len, uio, false));
}
int
-uiomove_nofault(void *cp, int n, struct uio *uio)
+uiomove_nofault(void *cp, size_t len, struct uio *uio)
{
-
- return (uiomove_faultflag(cp, n, uio, 1));
+ return (uiomove_faultflag(cp, len, uio, true));
}
int
@@ -259,7 +257,7 @@
}
static int
-uiomove_faultflag(void *cp, int n, struct uio *uio, int nofault)
+uiomove_faultflag(void *cp, size_t len, struct uio *uio, bool nofault)
{
struct iovec *iov;
size_t cnt;
@@ -287,11 +285,11 @@
}
save = curthread_pflags_set(newflags);
} else {
- KASSERT(nofault == 0, ("uiomove: nofault"));
+ KASSERT(!nofault, ("uiomove: nofault"));
save = ~0;
}
- while (n > 0 && uio->uio_resid) {
+ while (len > 0 && uio->uio_resid != 0) {
KASSERT(uio->uio_iovcnt > 0,
("%s: uio %p iovcnt underflow", __func__, uio));
@@ -302,8 +300,8 @@
uio->uio_iovcnt--;
continue;
}
- if (cnt > n)
- cnt = n;
+ if (cnt > len)
+ cnt = len;
error = uiomove_step(cp, iov->iov_base, cnt, uio);
if (error != 0)
@@ -313,7 +311,7 @@
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
cp = (char *)cp + cnt;
- n -= cnt;
+ len -= cnt;
}
out:
curthread_pflags_restore(save);
@@ -359,14 +357,14 @@
* assertion failure instead.
*/
int
-uiomove_frombuf(void *buf, int buflen, struct uio *uio)
+uiomove_frombuf(void *buf, size_t buflen, struct uio *uio)
{
size_t offset, n;
if (uio->uio_offset < 0 || uio->uio_resid < 0 ||
(offset = uio->uio_offset) != uio->uio_offset)
return (EINVAL);
- if (buflen <= 0 || offset >= buflen)
+ if (buflen == 0 || offset >= buflen)
return (0);
if ((n = buflen - offset) > IOSIZE_MAX)
return (EINVAL);
diff --git a/sys/powerpc/powerpc/uio_machdep.c b/sys/powerpc/powerpc/uio_machdep.c
--- a/sys/powerpc/powerpc/uio_machdep.c
+++ b/sys/powerpc/powerpc/uio_machdep.c
@@ -56,7 +56,8 @@
* avoid the creation and destruction of ephemeral mappings.
*/
int
-uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
+uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, size_t len,
+ struct uio *uio)
{
struct iovec *iov;
void *cp;
@@ -75,7 +76,9 @@
("%s: uio %p resid underflow", __func__, uio));
save = curthread_pflags_set(TDP_DEADLKTREAT);
- while (n > 0 && uio->uio_resid) {
+ if (len > uio->uio_resid)
+ len = uio->uio_resid;
+ while (len > 0 && uio->uio_resid != 0) {
KASSERT(uio->uio_iovcnt > 0,
("%s: uio %p iovcnt underflow", __func__, uio));
@@ -86,8 +89,8 @@
uio->uio_iovcnt--;
continue;
}
- if (cnt > n)
- cnt = n;
+ if (cnt > len)
+ cnt = len;
page_offset = offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - page_offset);
@@ -104,7 +107,7 @@
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
offset += cnt;
- n -= cnt;
+ len -= cnt;
}
curthread_pflags_restore(save);
return (error);
diff --git a/sys/riscv/riscv/uio_machdep.c b/sys/riscv/riscv/uio_machdep.c
--- a/sys/riscv/riscv/uio_machdep.c
+++ b/sys/riscv/riscv/uio_machdep.c
@@ -51,7 +51,8 @@
* avoid the creation and destruction of ephemeral mappings.
*/
int
-uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
+uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, size_t len,
+ struct uio *uio)
{
struct iovec *iov;
void *cp, *vaddr;
@@ -70,7 +71,9 @@
save = curthread_pflags_set(TDP_DEADLKTREAT);
mapped = false;
- while (n > 0 && uio->uio_resid) {
+ if (len > uio->uio_resid)
+ len = uio->uio_resid;
+ while (len > 0 && uio->uio_resid != 0) {
KASSERT(uio->uio_iovcnt > 0,
("%s: uio %p iovcnt underflow", __func__, uio));
@@ -81,8 +84,8 @@
uio->uio_iovcnt--;
continue;
}
- if (cnt > n)
- cnt = n;
+ if (cnt > len)
+ cnt = len;
page_offset = offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - page_offset);
if (uio->uio_segflg != UIO_NOCOPY) {
@@ -103,7 +106,7 @@
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
offset += cnt;
- n -= cnt;
+ len -= cnt;
}
curthread_pflags_restore(save);
return (error);
diff --git a/sys/sys/param.h b/sys/sys/param.h
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -74,7 +74,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1600022
+#define __FreeBSD_version 1600023
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff --git a/sys/sys/uio.h b/sys/sys/uio.h
--- a/sys/sys/uio.h
+++ b/sys/sys/uio.h
@@ -92,13 +92,13 @@
int physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst,
off_t offset, size_t len);
void uioadvance(struct uio *, size_t);
-int uiomove(void *cp, int n, struct uio *uio);
-int uiomove_frombuf(void *buf, int buflen, struct uio *uio);
-int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n,
+int uiomove(void *cp, size_t len, struct uio *uio);
+int uiomove_frombuf(void *buf, size_t buflen, struct uio *uio);
+int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, size_t len,
struct uio *uio);
-int uiomove_nofault(void *cp, int n, struct uio *uio);
+int uiomove_nofault(void *cp, size_t len, struct uio *uio);
int uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio);
-int uiomove_step(void *cp, void *base, size_t cnt, struct uio *uio);
+int uiomove_step(void *cp, void *base, size_t len, struct uio *uio);
#else /* !_KERNEL */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Sep 8, 12:24 PM (39 m, 48 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38422168
Default Alt Text
D59413.diff (11 KB)
Attached To
Mode
D59413: uiomove: Use size_t for the length argument
Attached
Detach File
Event Timeline
Log In to Comment