diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-11-01 22:09:04 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-05 14:33:36 -0500 |
commit | cbbd26b8b1a6af9c02e2b6523e12bd50cc765059 (patch) | |
tree | 6d1b258c99e83f320cf3611bdc927121df7e9b03 /net | |
parent | e5517c2a5a49ed5e99047008629f1cd60246ea0e (diff) |
[iov_iter] new primitives - copy_from_iter_full() and friends
copy_from_iter_full(), copy_from_iter_full_nocache() and
csum_and_copy_from_iter_full() - counterparts of copy_from_iter()
et.al., advancing iterator only in case of successful full copy
and returning whether it had been successful or not.
Convert some obvious users. *NOTE* - do not blindly assume that
something is a good candidate for those unless you are sure that
not advancing iov_iter in failure case is the right thing in
this case. Anything that does short read/short write kind of
stuff (or is in a loop, etc.) is unlikely to be a good one.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net')
-rw-r--r-- | net/atm/common.c | 2 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 6 | ||||
-rw-r--r-- | net/packet/af_packet.c | 5 | ||||
-rw-r--r-- | net/tipc/msg.c | 4 |
4 files changed, 7 insertions, 10 deletions
diff --git a/net/atm/common.c b/net/atm/common.c index 6dc12305799e..a3ca922d307b 100644 --- a/net/atm/common.c +++ b/net/atm/common.c | |||
@@ -630,7 +630,7 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size) | |||
630 | goto out; | 630 | goto out; |
631 | skb->dev = NULL; /* for paths shared with net_device interfaces */ | 631 | skb->dev = NULL; /* for paths shared with net_device interfaces */ |
632 | ATM_SKB(skb)->atm_options = vcc->atm_options; | 632 | ATM_SKB(skb)->atm_options = vcc->atm_options; |
633 | if (copy_from_iter(skb_put(skb, size), size, &m->msg_iter) != size) { | 633 | if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) { |
634 | kfree_skb(skb); | 634 | kfree_skb(skb); |
635 | error = -EFAULT; | 635 | error = -EFAULT; |
636 | goto out; | 636 | goto out; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 577f1c01454a..ce0b5dd01953 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -2127,7 +2127,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, | |||
2127 | struct sk_buff **frag; | 2127 | struct sk_buff **frag; |
2128 | int sent = 0; | 2128 | int sent = 0; |
2129 | 2129 | ||
2130 | if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count) | 2130 | if (!copy_from_iter_full(skb_put(skb, count), count, &msg->msg_iter)) |
2131 | return -EFAULT; | 2131 | return -EFAULT; |
2132 | 2132 | ||
2133 | sent += count; | 2133 | sent += count; |
@@ -2147,8 +2147,8 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, | |||
2147 | 2147 | ||
2148 | *frag = tmp; | 2148 | *frag = tmp; |
2149 | 2149 | ||
2150 | if (copy_from_iter(skb_put(*frag, count), count, | 2150 | if (!copy_from_iter_full(skb_put(*frag, count), count, |
2151 | &msg->msg_iter) != count) | 2151 | &msg->msg_iter)) |
2152 | return -EFAULT; | 2152 | return -EFAULT; |
2153 | 2153 | ||
2154 | sent += count; | 2154 | sent += count; |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d2238b204691..588ec202d5ba 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -2432,14 +2432,11 @@ static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len) | |||
2432 | static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len, | 2432 | static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len, |
2433 | struct virtio_net_hdr *vnet_hdr) | 2433 | struct virtio_net_hdr *vnet_hdr) |
2434 | { | 2434 | { |
2435 | int n; | ||
2436 | |||
2437 | if (*len < sizeof(*vnet_hdr)) | 2435 | if (*len < sizeof(*vnet_hdr)) |
2438 | return -EINVAL; | 2436 | return -EINVAL; |
2439 | *len -= sizeof(*vnet_hdr); | 2437 | *len -= sizeof(*vnet_hdr); |
2440 | 2438 | ||
2441 | n = copy_from_iter(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter); | 2439 | if (!copy_from_iter_full(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter)) |
2442 | if (n != sizeof(*vnet_hdr)) | ||
2443 | return -EFAULT; | 2440 | return -EFAULT; |
2444 | 2441 | ||
2445 | return __packet_snd_vnet_parse(vnet_hdr, *len); | 2442 | return __packet_snd_vnet_parse(vnet_hdr, *len); |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 17201aa8423d..a22be502f1bd 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -268,7 +268,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, | |||
268 | __skb_queue_tail(list, skb); | 268 | __skb_queue_tail(list, skb); |
269 | skb_copy_to_linear_data(skb, mhdr, mhsz); | 269 | skb_copy_to_linear_data(skb, mhdr, mhsz); |
270 | pktpos = skb->data + mhsz; | 270 | pktpos = skb->data + mhsz; |
271 | if (copy_from_iter(pktpos, dsz, &m->msg_iter) == dsz) | 271 | if (copy_from_iter_full(pktpos, dsz, &m->msg_iter)) |
272 | return dsz; | 272 | return dsz; |
273 | rc = -EFAULT; | 273 | rc = -EFAULT; |
274 | goto error; | 274 | goto error; |
@@ -299,7 +299,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, | |||
299 | if (drem < pktrem) | 299 | if (drem < pktrem) |
300 | pktrem = drem; | 300 | pktrem = drem; |
301 | 301 | ||
302 | if (copy_from_iter(pktpos, pktrem, &m->msg_iter) != pktrem) { | 302 | if (!copy_from_iter_full(pktpos, pktrem, &m->msg_iter)) { |
303 | rc = -EFAULT; | 303 | rc = -EFAULT; |
304 | goto error; | 304 | goto error; |
305 | } | 305 | } |