Skip to contentSkip to conversation

ax25 check error on memcpy_fromiovec

PATCH In review Chris Wright 5 participants 11 messages Dec 9, 2003 – Jan 23, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 ax25 check error on memcpy_fromiovec

Check the return value on memcpy_fromiovec().

===== net/ax25/af_ax25.c 1.33 vs edited =====

net/ax25/af_ax25.c +6 -1
@@ -1534,7 +1534,12 @@
 	SOCK_DEBUG(sk, "AX.25: Appending user data\n");
 
 	/* User data follows immediately after the AX.25 data */
-	memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
+	if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
+		err = -EFAULT;
+		kfree_skb(skb);
+		goto out;
+	}
+
 	skb->nh.raw = skb->data;
 
 	/* Add the PID if one is not supplied by the user in the skb */
#1 lore raw

PATCH 2/4 irda check error on memcpy_fromiovec

Check the return value on memcpy_fromiovec().

===== net/irda/af_irda.c 1.47 vs edited =====

net/irda/af_irda.c +15 -3
@@ -1307,7 +1307,11 @@
 	skb_reserve(skb, self->max_header_size + 16);
 
 	asmptr = skb->h.raw = skb_put(skb, len);
-	memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	err = memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	if (err) {
+		kfree_skb(skb);
+		return err;
+	}
 
 	/*
 	 * Just send the message to TinyTP, and let it deal with possible
@@ -1549,7 +1553,11 @@
 
 	IRDA_DEBUG(4, "%s(), appending user data\n", __FUNCTION__);
 	asmptr = skb->h.raw = skb_put(skb, len);
-	memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	err = memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	if (err) {
+		kfree_skb(skb);
+		return err;
+	}
 
 	/*
 	 * Just send the message to TinyTP, and let it deal with possible
@@ -1612,7 +1620,11 @@
 
 	IRDA_DEBUG(4, "%s(), appending user data\n", __FUNCTION__);
 	asmptr = skb->h.raw = skb_put(skb, len);
-	memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	err = memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	if (err) {
+		kfree_skb(skb);
+		return err;
+	}
 
 	err = irlmp_connless_data_request(self->lsap, skb);
 	if (err) {
#2 lore raw

PATCH 3/4 netrom check error on memcpy_fromiovec

Check the return value on memcpy_fromiovec().

===== net/netrom/af_netrom.c 1.40 vs edited =====

net/netrom/af_netrom.c +6 -1
@@ -1094,7 +1094,12 @@
 	SOCK_DEBUG(sk, "NET/ROM: Appending user data\n");
 
 	/* User data follows immediately after the NET/ROM transport header */
-	memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	if (memcpy_fromiovec(asmptr, msg->msg_iov, len)) {
+		kfree_skb(skb);
+		err = -EFAULT;
+		goto out;
+	}
+
 	SOCK_DEBUG(sk, "NET/ROM: Transmitting buffer\n");
 
 	if (sk->sk_state != TCP_ESTABLISHED) {
#3 lore raw

PATCH 4/4 rose check error on memcpy_fromiovec

Check the return value on memcpy_fromiovec().

===== net/rose/af_rose.c 1.33 vs edited =====

net/rose/af_rose.c +5 -1
@@ -1079,7 +1079,11 @@
 
 	asmptr = skb->h.raw = skb_put(skb, len);
 
-	memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	err = memcpy_fromiovec(asmptr, msg->msg_iov, len);
+	if (err) {
+		kfree_skb(skb);
+		return err;
+	}
 
 	/*
 	 *	If the Q BIT Include socket option is in force, the first
#4 lore raw
In reply to Chris Wright
Quoted 1 line · On Mon, 8 Dec 2003 20:23:02 -0800 Chris Wright <[email protected]> wrote:

Check the return value on memcpy_fromiovec().

I'm fine with all of these patches, but since these problems are not super-critical can you resend these for 2.6.1 perhaps?

#5 lore raw
Quoted 2 lines · * David S. Miller ([email protected]) wrote:

I'm fine with all of these patches, but since these problems are not super-critical can you resend these for 2.6.1 perhaps?

Sure, no problem.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#6 lore raw

PATCH 1/5 tun check error on memcpy_fromiovec

In reply to Chris Wright

hey chris,

after applying your 4 patches on top of linux-2.6.0
+ experimental net,
found 2 last unchecked memcpy_fromiovec in tun.c patch bellow fixes the second call,
the first is beyond me, please complete this patch :) compile tested

thx max

drivers/net/tun.c +4 -1
@@ -193,7 +193,10 @@
 	}
 
 	skb_reserve(skb, 2);
-	memcpy_fromiovec(skb_put(skb, len), iv, len);
+	if (memcpy_fromiovec(skb_put(skb, len), iv, len)) {
+		kfree_skb(skb);
+		return -EFAULT;
+	}
 
 	skb->dev = tun->dev;
 	switch (tun->flags & TUN_TYPE_MASK) {
#7 lore raw

Re: [PATCH 1/5] tun check error on memcpy_fromiovec

I'll take a look at merging this...

#8 lore raw

Re: [PATCH 1/5] tun check error on memcpy_fromiovec

In reply to maximilian attems
Quoted 8 lines · * maximilian attems ([email protected]) wrote:

hey chris,

after applying your 4 patches on top of linux-2.6.0
+ experimental net,
found 2 last unchecked memcpy_fromiovec in tun.c patch bellow fixes the second call,
the first is beyond me, please complete this patch :) compile tested

I specifically left those alone. They have a semi-bogus verify_area() call that is trying to insure the memcpy_fromiovec won't EFAULT. I'd prefer to remove them and simply do memcpy checking.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#9 lore raw

Re: [PATCH 1/5] tun check error on memcpy_fromiovec

Quoted 10 lines · Chris Wright
Quoted 8 lines · * maximilian attems ([email protected]) wrote:

hey chris,

after applying your 4 patches on top of linux-2.6.0
+ experimental net,
found 2 last unchecked memcpy_fromiovec in tun.c patch bellow fixes the second call,
the first is beyond me, please complete this patch :) compile tested

Quoted 3 lines

I specifically left those alone. They have a semi-bogus verify_area() call that is trying to insure the memcpy_fromiovec won't EFAULT. I'd prefer to remove them and simply do memcpy checking.

Folks,

Please don't add extra unneeded checks or fix stuff that does not need to be fixed. Verify area is not bogus. We need to know total length of the iovec so we might as well check it in the same loop and not bother with checking later.

Thanks
Max

#10 lore raw

Re: [PATCH 1/5] tun check error on memcpy_fromiovec

Quoted 9 lines · * Max Krasnyansky ([email protected]) wrote:
Quoted 3 lines · Chris Wright

I specifically left those alone. They have a semi-bogus verify_area() call that is trying to insure the memcpy_fromiovec won't EFAULT. I'd prefer to remove them and simply do memcpy checking.

Please don't add extra unneeded checks or fix stuff that does not need to be fixed. Verify area is not bogus. We need to know total length of the iovec so we might as well check it in the same loop and not bother with checking later.

Yes, I realize it's used to collect total length. But it does not protect from userspace controlled buffer whose contents can change. Continuing when a fault is possible means the skb->data could be zero'd. However, since this is intended to be 0700 root owned device, and the user could supply same such data directly, it's of fairly low priority to patch.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net