Skip to content

Commit 7424ce6

Browse files
author
Al Viro
committed
[atm] switch vcc_sendmsg() to copy_from_iter()
... and make it handle multi-segment iovecs - deals with that "fix this later" issue for free. A bit of shame, really - it had been there since 2.3.15pre3 when the whole thing went into the tree, practically a historical artefact by now... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 0f7db23 commit 7424ce6

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

‎net/atm/common.c‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -570,15 +570,16 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
570570
}
571571

572572
int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
573-
size_t total_len)
573+
size_t size)
574574
{
575575
struct sock *sk = sock->sk;
576576
DEFINE_WAIT(wait);
577577
struct atm_vcc *vcc;
578578
struct sk_buff *skb;
579579
int eff, error;
580-
const void __user *buff;
581-
int size;
580+
struct iov_iter from;
581+
582+
iov_iter_init(&from, WRITE, m->msg_iov, m->msg_iovlen, size);
582583

583584
lock_sock(sk);
584585
if (sock->state != SS_CONNECTED) {
@@ -589,12 +590,6 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
589590
error = -EISCONN;
590591
goto out;
591592
}
592-
if (m->msg_iovlen != 1) {
593-
error = -ENOSYS; /* fix this later @@@ */
594-
goto out;
595-
}
596-
buff = m->msg_iov->iov_base;
597-
size = m->msg_iov->iov_len;
598593
vcc = ATM_SD(sock);
599594
if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
600595
test_bit(ATM_VF_CLOSE, &vcc->flags) ||
@@ -607,7 +602,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
607602
error = 0;
608603
goto out;
609604
}
610-
if (size < 0 || size > vcc->qos.txtp.max_sdu) {
605+
if (size > vcc->qos.txtp.max_sdu) {
611606
error = -EMSGSIZE;
612607
goto out;
613608
}
@@ -639,7 +634,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
639634
goto out;
640635
skb->dev = NULL; /* for paths shared with net_device interfaces */
641636
ATM_SKB(skb)->atm_options = vcc->atm_options;
642-
if (copy_from_user(skb_put(skb, size), buff, size)) {
637+
if (copy_from_iter(skb_put(skb, size), size, &from) != size) {
643638
kfree_skb(skb);
644639
error = -EFAULT;
645640
goto out;

0 commit comments

Comments
 (0)