lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080426095923.GA22836@uranus.ravnborg.org>
Date:	Sat, 26 Apr 2008 11:59:23 +0200
From:	Sam Ravnborg <sam@...nborg.org>
To:	David Miller <davem@...emloft.net>
Cc:	oliver@...tkopp.net, wg@...ndegger.com,
	urs.thuermann@...kswagen.de, netdev@...r.kernel.org,
	socketcan-core@...ts.berlios.de, oliver.hartkopp@...kswagen.de,
	xemul@...nvz.org
Subject: [PATCH][CAN]: Fix copy_from_user() results interpretation

Both copy_to_ and _from_user return the number of bytes, that failed to
reach their destination, not the 0/-EXXX values.

Based on patch from Pavel Emelyanov <xemul@...nvz.org>

Signed-off-by: Sam Ravnborg <sam@...nborg.org>
Acked-by: Oliver Hartkopp <oliver.hartkopp@...kswagen.de>
Cc: Pavel Emelyanov <xemul@...nvz.org>
Cc: Wolfgang Grandegger <wg@...ndegger.com>
---

Hi David.

> Right, I also have no problem with Sam's patch at all and plan to
> apply it.
OK - here is a proper patch.
Actual patch is the same - I just added a proper changelog.

	Sam

diff --git a/net/can/raw.c b/net/can/raw.c
index 201cbfc..69877b8 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -435,15 +435,13 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 			if (!filter)
 				return -ENOMEM;
 
-			err = copy_from_user(filter, optval, optlen);
-			if (err) {
+			if (copy_from_user(filter, optval, optlen)) {
 				kfree(filter);
-				return err;
+				return -EFAULT;
 			}
 		} else if (count == 1) {
-			err = copy_from_user(&sfilter, optval, optlen);
-			if (err)
-				return err;
+			if (copy_from_user(&sfilter, optval, optlen))
+				return -EFAULT;
 		}
 
 		lock_sock(sk);
@@ -493,9 +491,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 		if (optlen != sizeof(err_mask))
 			return -EINVAL;
 
-		err = copy_from_user(&err_mask, optval, optlen);
-		if (err)
-			return err;
+		if (copy_from_user(&err_mask, optval, optlen))
+			return -EFAULT;
 
 		err_mask &= CAN_ERR_MASK;
 
@@ -531,7 +528,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 		if (optlen != sizeof(ro->loopback))
 			return -EINVAL;
 
-		err = copy_from_user(&ro->loopback, optval, optlen);
+		if (copy_from_user(&ro->loopback, optval, optlen))
+			return -EFAULT;
 
 		break;
 
@@ -539,7 +537,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 		if (optlen != sizeof(ro->recv_own_msgs))
 			return -EINVAL;
 
-		err = copy_from_user(&ro->recv_own_msgs, optval, optlen);
+		if (copy_from_user(&ro->recv_own_msgs, optval, optlen))
+			return -EFAULT;
 
 		break;
 
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 277cfe0..4a7327b 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -105,7 +105,7 @@ endif
 
 # Do section mismatch analysis for each module/built-in.o
 ifdef CONFIG_DEBUG_SECTION_MISMATCH
-  cmd_secanalysis = ; scripts/mod/modpost $@
+  #cmd_secanalysis = ; scripts/mod/modpost $@
 endif
 
 # Compile C sources (.c)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ