kernel/fs: Add missing IS_USER_ADDRESS check in user_vector_io.

This reinstates commit 2b5ebfcfd5.

According to the POSIX specification, a NULL iov_base means
"do nothing." So we should treat that as such properly,
and not consider it an invalid address.

Fixes #15356.
This commit is contained in:
Augustin Cavalier 2019-10-19 12:42:32 -04:00
parent 200cb331ef
commit 91cc452e90
1 changed files with 9 additions and 0 deletions

View File

@ -822,6 +822,15 @@ common_user_vector_io(int fd, off_t pos, const iovec* userVecs, size_t count,
ssize_t bytesTransferred = 0;
for (uint32 i = 0; i < count; i++) {
if (vecs[i].iov_base == NULL)
continue;
if (!IS_USER_ADDRESS(vecs[i].iov_base)) {
status = B_BAD_ADDRESS;
if (bytesTransferred == 0)
return status;
break;
}
size_t length = vecs[i].iov_len;
if (write) {
status = descriptor->ops->fd_write(descriptor, pos,