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: <1445602236-24130-3-git-send-email-clabbe.montjoie@gmail.com>
Date:	Fri, 23 Oct 2015 14:10:27 +0200
From:	LABBE Corentin <clabbe.montjoie@...il.com>
To:	acme@...stprotocols.net, davem@...emloft.net
Cc:	LABBE Corentin <clabbe.montjoie@...il.com>,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH 02/11] net: llc: fix a setting of error value to size_t

The variable copied is a size_t, so setting a negative value to it is
invalid.
The patch add an "err" variable for getting the error code.

Signed-off-by: LABBE Corentin <clabbe.montjoie@...il.com>
---
 net/llc/af_llc.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 8dab4e5..79b915d 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -719,9 +719,10 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 	unsigned long used;
 	int target;	/* Read at least this many bytes */
 	long timeo;
+	int err = 0;
 
 	lock_sock(sk);
-	copied = -ENOTCONN;
+	err = -ENOTCONN;
 	if (unlikely(sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN))
 		goto out;
 
@@ -745,9 +746,8 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 		 * and move it down to the bottom of the loop
 		 */
 		if (signal_pending(current)) {
-			if (copied)
-				break;
-			copied = timeo ? sock_intr_errno(timeo) : -EAGAIN;
+			if (!copied)
+				err = timeo ? sock_intr_errno(timeo) : -EAGAIN;
 			break;
 		}
 
@@ -775,7 +775,7 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 				break;
 
 			if (sk->sk_err) {
-				copied = sock_error(sk);
+				err = sock_error(sk);
 				break;
 			}
 			if (sk->sk_shutdown & RCV_SHUTDOWN)
@@ -787,13 +787,15 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 					 * This occurs when user tries to read
 					 * from never connected socket.
 					 */
-					copied = -ENOTCONN;
+					err = -ENOTCONN;
+					copied = 0;
 					break;
 				}
 				break;
 			}
 			if (!timeo) {
-				copied = -EAGAIN;
+				err = -EAGAIN;
+				copied = 0;
 				break;
 			}
 		}
@@ -823,7 +825,7 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 			if (rc) {
 				/* Exception. Bailout! */
 				if (!copied)
-					copied = -EFAULT;
+					err = -EFAULT;
 				break;
 			}
 		}
@@ -850,6 +852,8 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 
 out:
 	release_sock(sk);
+	if (err)
+		return err;
 	return copied;
 copy_uaddr:
 	if (uaddr != NULL && skb != NULL) {
-- 
2.4.10

--
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