usbip: prevent leaking socket pointer address in messages
authorShuah Khan <shuahkh@osg.samsung.com>
Fri, 15 Dec 2017 17:50:09 +0000 (10:50 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 3 Mar 2018 15:50:50 +0000 (15:50 +0000)
commit 90120d15f4c397272aaf41077960a157fc4212bf upstream.

usbip driver is leaking socket pointer address in messages. Remove
the messages that aren't useful and print sockfd in the ones that
are useful for debugging.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust filenames, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/staging/usbip/stub_dev.c
drivers/staging/usbip/usbip_common.c
drivers/staging/usbip/vhci_hcd.c

index 55c0b51..d98821a 100644 (file)
@@ -186,8 +186,7 @@ static void stub_shutdown_connection(struct usbip_device *ud)
         * step 1?
         */
        if (ud->tcp_socket) {
-               dev_dbg(&sdev->udev->dev, "shutdown tcp_socket %p\n",
-                       ud->tcp_socket);
+               dev_dbg(&sdev->udev->dev, "shutdown sockfd %d\n", ud->sockfd);
                kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
        }
 
index e5cbc34..783052c 100644 (file)
@@ -346,13 +346,10 @@ int usbip_recv(struct socket *sock, void *buf, int size)
        char *bp = buf;
        int osize = size;
 
-       usbip_dbg_xmit("enter\n");
-
-       if (!sock || !buf || !size) {
-               pr_err("invalid arg, sock %p buff %p size %d\n", sock, buf,
-                      size);
+       if (!sock || !buf || !size)
                return -EINVAL;
-       }
+
+       usbip_dbg_xmit("enter\n");
 
        do {
                sock->sk->sk_allocation = GFP_NOIO;
@@ -366,11 +363,8 @@ int usbip_recv(struct socket *sock, void *buf, int size)
                msg.msg_flags      = MSG_NOSIGNAL;
 
                result = kernel_recvmsg(sock, &msg, &iov, 1, size, MSG_WAITALL);
-               if (result <= 0) {
-                       pr_debug("receive sock %p buf %p size %u ret %d total %d\n",
-                                sock, buf, size, result, total);
+               if (result <= 0)
                        goto err;
-               }
 
                size -= result;
                buf += result;
index c756250..40172b9 100644 (file)
@@ -811,7 +811,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
 
        /* need this? see stub_dev.c */
        if (ud->tcp_socket) {
-               pr_debug("shutdown tcp_socket %p\n", ud->tcp_socket);
+               pr_debug("shutdown tcp_socket %d\n", ud->sockfd);
                kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
        }