Skip to content

Commit

Permalink
Merge tag 'pull-iov_iter' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/viro/vfs

Pull iov_iter updates from Al Viro:
 "iov_iter work; most of that is about getting rid of direction
  misannotations and (hopefully) preventing more of the same for the
  future"

* tag 'pull-iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  use less confusing names for iov_iter direction initializers
  iov_iter: saner checks for attempt to copy to/from iterator
  [xen] fix "direction" argument of iov_iter_kvec()
  [vhost] fix 'direction' argument of iov_iter_{init,bvec}()
  [target] fix iov_iter_bvec() "direction" argument
  [s390] memcpy_real(): WRITE is "data source", not destination...
  [s390] zcore: WRITE is "data source", not destination...
  [infiniband] READ is "data destination", not source...
  [fsi] WRITE is "data source", not destination...
  [s390] copy_oldmem_kernel() - WRITE is "data source", not destination
  csum_and_copy_to_iter(): handle ITER_DISCARD
  get rid of unlikely() on page_copy_sane() calls
  • Loading branch information
torvalds committed Dec 13, 2022
2 parents 268369b + de4eda9 commit 75f4d9a
Show file tree
Hide file tree
Showing 88 changed files with 224 additions and 214 deletions.
2 changes: 1 addition & 1 deletion arch/s390/kernel/crash_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int copy_oldmem_kernel(void *dst, unsigned long src, size_t count)

kvec.iov_base = dst;
kvec.iov_len = count;
iov_iter_kvec(&iter, WRITE, &kvec, 1, count);
iov_iter_kvec(&iter, ITER_DEST, &kvec, 1, count);
if (copy_oldmem_iter(&iter, src, count) < count)
return -EFAULT;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/mm/maccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int memcpy_real(void *dest, unsigned long src, size_t count)

kvec.iov_base = dest;
kvec.iov_len = count;
iov_iter_kvec(&iter, WRITE, &kvec, 1, count);
iov_iter_kvec(&iter, ITER_DEST, &kvec, 1, count);
if (memcpy_real_iter(&iter, src, count) < count)
return -EFAULT;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/microcode/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,

kvec.iov_base = (void *)firmware->data;
kvec.iov_len = firmware->size;
iov_iter_kvec(&iter, WRITE, &kvec, 1, firmware->size);
iov_iter_kvec(&iter, ITER_SOURCE, &kvec, 1, firmware->size);
ret = generic_load_microcode(cpu, &iter);

release_firmware(firmware);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/crash_dump_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
struct kvec kvec = { .iov_base = buf, .iov_len = count };
struct iov_iter iter;

iov_iter_kvec(&iter, READ, &kvec, 1, count);
iov_iter_kvec(&iter, ITER_DEST, &kvec, 1, count);

return read_from_oldmem(&iter, count, ppos,
cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT));
Expand Down
4 changes: 2 additions & 2 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ static int build_cipher_test_sglists(struct cipher_test_sglists *tsgls,
struct iov_iter input;
int err;

iov_iter_kvec(&input, WRITE, inputs, nr_inputs, src_total_len);
iov_iter_kvec(&input, ITER_SOURCE, inputs, nr_inputs, src_total_len);
err = build_test_sglist(&tsgls->src, cfg->src_divs, alignmask,
cfg->inplace_mode != OUT_OF_PLACE ?
max(dst_total_len, src_total_len) :
Expand Down Expand Up @@ -1180,7 +1180,7 @@ static int build_hash_sglist(struct test_sglist *tsgl,

kv.iov_base = (void *)vec->plaintext;
kv.iov_len = vec->psize;
iov_iter_kvec(&input, WRITE, &kv, 1, vec->psize);
iov_iter_kvec(&input, ITER_SOURCE, &kv, 1, vec->psize);
return build_test_sglist(tsgl, cfg->src_divs, alignmask, vec->psize,
&input, divs);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/pfr_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static ssize_t pfru_write(struct file *file, const char __user *buf,

iov.iov_base = (void __user *)buf;
iov.iov_len = len;
iov_iter_init(&iter, WRITE, &iov, 1, len);
iov_iter_init(&iter, ITER_SOURCE, &iov, 1, len);

/* map the communication buffer */
phy_addr = (phys_addr_t)((buf_info.addr_hi << 32) | buf_info.addr_lo);
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ int drbd_send(struct drbd_connection *connection, struct socket *sock,

/* THINK if (signal_pending) return ... ? */

iov_iter_kvec(&msg.msg_iter, WRITE, &iov, 1, size);
iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iov, 1, size);

if (sock == connection->data.socket) {
rcu_read_lock();
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flag
struct msghdr msg = {
.msg_flags = (flags ? flags : MSG_WAITALL | MSG_NOSIGNAL)
};
iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, size);
iov_iter_kvec(&msg.msg_iter, ITER_DEST, &iov, 1, size);
return sock_recvmsg(sock, &msg, msg.msg_flags);
}

Expand Down
12 changes: 6 additions & 6 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
struct iov_iter i;
ssize_t bw;

iov_iter_bvec(&i, WRITE, bvec, 1, bvec->bv_len);
iov_iter_bvec(&i, ITER_SOURCE, bvec, 1, bvec->bv_len);

file_start_write(file);
bw = vfs_iter_write(file, &i, ppos, 0);
Expand Down Expand Up @@ -286,7 +286,7 @@ static int lo_read_simple(struct loop_device *lo, struct request *rq,
ssize_t len;

rq_for_each_segment(bvec, rq, iter) {
iov_iter_bvec(&i, READ, &bvec, 1, bvec.bv_len);
iov_iter_bvec(&i, ITER_DEST, &bvec, 1, bvec.bv_len);
len = vfs_iter_read(lo->lo_backing_file, &i, &pos, 0);
if (len < 0)
return len;
Expand Down Expand Up @@ -392,7 +392,7 @@ static void lo_rw_aio_complete(struct kiocb *iocb, long ret)
}

static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
loff_t pos, bool rw)
loff_t pos, int rw)
{
struct iov_iter iter;
struct req_iterator rq_iter;
Expand Down Expand Up @@ -448,7 +448,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
cmd->iocb.ki_flags = IOCB_DIRECT;
cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);

if (rw == WRITE)
if (rw == ITER_SOURCE)
ret = call_write_iter(file, &cmd->iocb, &iter);
else
ret = call_read_iter(file, &cmd->iocb, &iter);
Expand Down Expand Up @@ -490,12 +490,12 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE);
case REQ_OP_WRITE:
if (cmd->use_aio)
return lo_rw_aio(lo, cmd, pos, WRITE);
return lo_rw_aio(lo, cmd, pos, ITER_SOURCE);
else
return lo_write_simple(lo, rq, pos);
case REQ_OP_READ:
if (cmd->use_aio)
return lo_rw_aio(lo, cmd, pos, READ);
return lo_rw_aio(lo, cmd, pos, ITER_DEST);
else
return lo_read_simple(lo, rq, pos);
default:
Expand Down
10 changes: 5 additions & 5 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
u32 nbd_cmd_flags = 0;
int sent = nsock->sent, skip = 0;

iov_iter_kvec(&from, WRITE, &iov, 1, sizeof(request));
iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request));

type = req_to_nbd_cmd_type(req);
if (type == U32_MAX)
Expand Down Expand Up @@ -649,7 +649,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)

dev_dbg(nbd_to_dev(nbd), "request %p: sending %d bytes data\n",
req, bvec.bv_len);
iov_iter_bvec(&from, WRITE, &bvec, 1, bvec.bv_len);
iov_iter_bvec(&from, ITER_SOURCE, &bvec, 1, bvec.bv_len);
if (skip) {
if (skip >= iov_iter_count(&from)) {
skip -= iov_iter_count(&from);
Expand Down Expand Up @@ -701,7 +701,7 @@ static int nbd_read_reply(struct nbd_device *nbd, int index,
int result;

reply->magic = 0;
iov_iter_kvec(&to, READ, &iov, 1, sizeof(*reply));
iov_iter_kvec(&to, ITER_DEST, &iov, 1, sizeof(*reply));
result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL);
if (result < 0) {
if (!nbd_disconnected(nbd->config))
Expand Down Expand Up @@ -790,7 +790,7 @@ static struct nbd_cmd *nbd_handle_reply(struct nbd_device *nbd, int index,
struct iov_iter to;

rq_for_each_segment(bvec, req, iter) {
iov_iter_bvec(&to, READ, &bvec, 1, bvec.bv_len);
iov_iter_bvec(&to, ITER_DEST, &bvec, 1, bvec.bv_len);
result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL);
if (result < 0) {
dev_err(disk_to_dev(nbd->disk), "Receive data failed (result %d)\n",
Expand Down Expand Up @@ -1267,7 +1267,7 @@ static void send_disconnects(struct nbd_device *nbd)
for (i = 0; i < config->num_connections; i++) {
struct nbd_sock *nsock = config->socks[i];

iov_iter_kvec(&from, WRITE, &iov, 1, sizeof(request));
iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request));
mutex_lock(&nsock->tx_lock);
ret = sock_xmit(nbd, i, 1, &from, 0, NULL);
if (ret < 0)
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ SYSCALL_DEFINE3(getrandom, char __user *, ubuf, size_t, len, unsigned int, flags
return ret;
}

ret = import_single_range(READ, ubuf, len, &iov, &iter);
ret = import_single_range(ITER_DEST, ubuf, len, &iov, &iter);
if (unlikely(ret))
return ret;
return get_random_bytes_user(&iter);
Expand Down Expand Up @@ -1502,7 +1502,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
return -EINVAL;
if (get_user(len, p++))
return -EFAULT;
ret = import_single_range(WRITE, p, len, &iov, &iter);
ret = import_single_range(ITER_SOURCE, p, len, &iov, &iter);
if (unlikely(ret))
return ret;
ret = write_pool_user(&iter);
Expand Down
6 changes: 3 additions & 3 deletions drivers/fsi/fsi-sbefifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static void sbefifo_collect_async_ffdc(struct sbefifo *sbefifo)
}
ffdc_iov.iov_base = ffdc;
ffdc_iov.iov_len = SBEFIFO_MAX_FFDC_SIZE;
iov_iter_kvec(&ffdc_iter, WRITE, &ffdc_iov, 1, SBEFIFO_MAX_FFDC_SIZE);
iov_iter_kvec(&ffdc_iter, ITER_DEST, &ffdc_iov, 1, SBEFIFO_MAX_FFDC_SIZE);
cmd[0] = cpu_to_be32(2);
cmd[1] = cpu_to_be32(SBEFIFO_CMD_GET_SBE_FFDC);
rc = sbefifo_do_command(sbefifo, cmd, 2, &ffdc_iter);
Expand Down Expand Up @@ -756,7 +756,7 @@ int sbefifo_submit(struct device *dev, const __be32 *command, size_t cmd_len,
rbytes = (*resp_len) * sizeof(__be32);
resp_iov.iov_base = response;
resp_iov.iov_len = rbytes;
iov_iter_kvec(&resp_iter, WRITE, &resp_iov, 1, rbytes);
iov_iter_kvec(&resp_iter, ITER_DEST, &resp_iov, 1, rbytes);

/* Perform the command */
rc = mutex_lock_interruptible(&sbefifo->lock);
Expand Down Expand Up @@ -839,7 +839,7 @@ static ssize_t sbefifo_user_read(struct file *file, char __user *buf,
/* Prepare iov iterator */
resp_iov.iov_base = buf;
resp_iov.iov_len = len;
iov_iter_init(&resp_iter, WRITE, &resp_iov, 1, len);
iov_iter_init(&resp_iter, ITER_DEST, &resp_iov, 1, len);

/* Perform the command */
rc = mutex_lock_interruptible(&sbefifo->lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/ulp/rtrs/rtrs-clt.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ static void rtrs_clt_init_req(struct rtrs_clt_io_req *req,
refcount_set(&req->ref, 1);
req->mp_policy = clt_path->clt->mp_policy;

iov_iter_kvec(&iter, READ, vec, 1, usr_len);
iov_iter_kvec(&iter, ITER_SOURCE, vec, 1, usr_len);
len = _copy_from_iter(req->iu->buf, usr_len, &iter);
WARN_ON(len != usr_len);

Expand Down
2 changes: 1 addition & 1 deletion drivers/isdn/mISDN/l1oip_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ l1oip_socket_thread(void *data)
printk(KERN_DEBUG "%s: socket created and open\n",
__func__);
while (!signal_pending(current)) {
iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, recvbuf_size);
iov_iter_kvec(&msg.msg_iter, ITER_DEST, &iov, 1, recvbuf_size);
recvlen = sock_recvmsg(socket, &msg, 0);
if (recvlen > 0) {
l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
Expand Down
6 changes: 3 additions & 3 deletions drivers/misc/vmw_vmci/vmci_queue_pair.c
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,7 @@ ssize_t vmci_qpair_enqueue(struct vmci_qp *qpair,
if (!qpair || !buf)
return VMCI_ERROR_INVALID_ARGS;

iov_iter_kvec(&from, WRITE, &v, 1, buf_size);
iov_iter_kvec(&from, ITER_SOURCE, &v, 1, buf_size);

qp_lock(qpair);

Expand Down Expand Up @@ -3088,7 +3088,7 @@ ssize_t vmci_qpair_dequeue(struct vmci_qp *qpair,
if (!qpair || !buf)
return VMCI_ERROR_INVALID_ARGS;

iov_iter_kvec(&to, READ, &v, 1, buf_size);
iov_iter_kvec(&to, ITER_DEST, &v, 1, buf_size);

qp_lock(qpair);

Expand Down Expand Up @@ -3133,7 +3133,7 @@ ssize_t vmci_qpair_peek(struct vmci_qp *qpair,
if (!qpair || !buf)
return VMCI_ERROR_INVALID_ARGS;

iov_iter_kvec(&to, READ, &v, 1, buf_size);
iov_iter_kvec(&to, ITER_DEST, &v, 1, buf_size);

qp_lock(qpair);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ppp/ppp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
ret = -EFAULT;
iov.iov_base = buf;
iov.iov_len = count;
iov_iter_init(&to, READ, &iov, 1, count);
iov_iter_init(&to, ITER_DEST, &iov, 1, count);
if (skb_copy_datagram_iter(skb, 0, &to, skb->len))
goto outf;
ret = skb->len;
Expand Down
4 changes: 2 additions & 2 deletions drivers/nvme/host/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static inline void nvme_tcp_advance_req(struct nvme_tcp_request *req,
if (!iov_iter_count(&req->iter) &&
req->data_sent < req->data_len) {
req->curr_bio = req->curr_bio->bi_next;
nvme_tcp_init_iter(req, WRITE);
nvme_tcp_init_iter(req, ITER_SOURCE);
}
}

Expand Down Expand Up @@ -781,7 +781,7 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
nvme_tcp_init_recv_ctx(queue);
return -EIO;
}
nvme_tcp_init_iter(req, READ);
nvme_tcp_init_iter(req, ITER_DEST);
}

/* we can read only from what is left in this bio */
Expand Down
4 changes: 2 additions & 2 deletions drivers/nvme/target/io-cmd-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ static ssize_t nvmet_file_submit_bvec(struct nvmet_req *req, loff_t pos,
if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA))
ki_flags |= IOCB_DSYNC;
call_iter = req->ns->file->f_op->write_iter;
rw = WRITE;
rw = ITER_SOURCE;
} else {
call_iter = req->ns->file->f_op->read_iter;
rw = READ;
rw = ITER_DEST;
}

iov_iter_bvec(&iter, rw, req->f.bvec, nr_segs, count);
Expand Down
2 changes: 1 addition & 1 deletion drivers/nvme/target/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static void nvmet_tcp_build_pdu_iovec(struct nvmet_tcp_cmd *cmd)
sg_offset = 0;
}

iov_iter_bvec(&cmd->recv_msg.msg_iter, READ, cmd->iov,
iov_iter_bvec(&cmd->recv_msg.msg_iter, ITER_DEST, cmd->iov,
nr_pages, cmd->pdu_len);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/char/zcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static inline int memcpy_hsa_kernel(void *dst, unsigned long src, size_t count)

kvec.iov_base = dst;
kvec.iov_len = count;
iov_iter_kvec(&iter, WRITE, &kvec, 1, count);
iov_iter_kvec(&iter, ITER_DEST, &kvec, 1, count);
if (memcpy_hsa_iter(&iter, src, count) < count)
return -EIO;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,7 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
Sg_scatter_hold *rsv_schp = &sfp->reserve;
struct request_queue *q = sfp->parentdp->device->request_queue;
struct rq_map_data *md, map_data;
int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? WRITE : READ;
int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? ITER_SOURCE : ITER_DEST;
struct scsi_cmnd *scmd;

SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
Expand Down
4 changes: 2 additions & 2 deletions drivers/target/iscsi/iscsi_target_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ int rx_data(
return -1;

memset(&msg, 0, sizeof(struct msghdr));
iov_iter_kvec(&msg.msg_iter, READ, iov, iov_count, data);
iov_iter_kvec(&msg.msg_iter, ITER_DEST, iov, iov_count, data);

while (msg_data_left(&msg)) {
rx_loop = sock_recvmsg(conn->sock, &msg, MSG_WAITALL);
Expand Down Expand Up @@ -1261,7 +1261,7 @@ int tx_data(

memset(&msg, 0, sizeof(struct msghdr));

iov_iter_kvec(&msg.msg_iter, WRITE, iov, iov_count, data);
iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, iov, iov_count, data);

while (msg_data_left(&msg)) {
int tx_loop = sock_sendmsg(conn->sock, &msg);
Expand Down
4 changes: 2 additions & 2 deletions drivers/target/target_core_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static int fd_do_rw(struct se_cmd *cmd, struct file *fd,
len += sg->length;
}

iov_iter_bvec(&iter, READ, bvec, sgl_nents, len);
iov_iter_bvec(&iter, is_write, bvec, sgl_nents, len);
if (is_write)
ret = vfs_iter_write(fd, &iter, &pos, 0);
else
Expand Down Expand Up @@ -473,7 +473,7 @@ fd_execute_write_same(struct se_cmd *cmd)
len += se_dev->dev_attrib.block_size;
}

iov_iter_bvec(&iter, READ, bvec, nolb, len);
iov_iter_bvec(&iter, ITER_SOURCE, bvec, nolb, len);
ret = vfs_iter_write(fd_dev->fd_file, &iter, &pos, 0);

kfree(bvec);
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/usbip/usbip_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ int usbip_recv(struct socket *sock, void *buf, int size)
if (!sock || !buf || !size)
return -EINVAL;

iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, size);
iov_iter_kvec(&msg.msg_iter, ITER_DEST, &iov, 1, size);

usbip_dbg_xmit("enter\n");

Expand Down
Loading

0 comments on commit 75f4d9a

Please sign in to comment.