Skip to contentSkip to conversation

VSOCK: signedness bug in virtio_transport_dgram_enqueue()

PATCH In review Dan Carpenter 2 participants 2 messages Dec 9, 2015 – Dec 10, 2015

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

PATCH 1/1 VSOCK: signedness bug in virtio_transport_dgram_enqueue()

"written" has to be signed for the error handling to work. trans->ops->send_pkt() returns an int so that's fine.

Fixes 80a19e338d45 ('VSOCK: Introduce virtio-vsock-common.ko')
net/vmw_vsock/virtio_transport_common.c +3 -2
index 28f790d..d9a2325 100644
@@ -815,7 +815,8 @@ virtio_transport_dgram_enqueue(struct vsock_sock *vsk,
 		.type = VIRTIO_VSOCK_TYPE_DGRAM,
 		.msg = msg,
 	};
-	size_t total_written = 0, pkt_off = 0, written;
+	size_t total_written = 0, pkt_off = 0;
+	int written;
 	u16 dgram_id;
 
 	/* The max size of a single dgram we support is 64KB */
@@ -845,7 +846,7 @@ virtio_transport_dgram_enqueue(struct vsock_sock *vsk,
 		}
 		total_written += written;
 		pkt_off += written;
-		pr_debug("%s:id=%d, dgram_len=%zu, off=%zu, total_written=%zu, written=%zu\n",
+		pr_debug("%s:id=%d, dgram_len=%zu, off=%zu, total_written=%zu, written=%d\n",
 			  __func__, dgram_id, dgram_len, pkt_off, total_written, written);
 	}
 
maintainer
#1 lore raw
Quoted 21 lines · Dan Carpenter

"written" has to be signed for the error handling to work. trans->ops->send_pkt() returns an int so that's fine.

Fixes 80a19e338d45 ('VSOCK: Introduce virtio-vsock-common.ko')
net/vmw_vsock/virtio_transport_common.c +2 -1
index 28f790d..d9a2325 100644
@@ -815,7 +815,8 @@ virtio_transport_dgram_enqueue(struct vsock_sock *vsk,
 		.type = VIRTIO_VSOCK_TYPE_DGRAM,
 		.msg = msg,
 	};
-	size_t total_written = 0, pkt_off = 0, written;
+	size_t total_written = 0, pkt_off = 0;
+	int written;
 	u16 dgram_id;
 
 	/* The max size of a single dgram we support is 64KB */

net/vmw_vsock/virtio_transport_common.c virtio_transport_dgram_enqueue(struct vsock_sock *vsk, · line 852

Quoted 8 lines
net/vmw_vsock/virtio_transport_common.c +1 -1
@@ -845,7 +846,7 @@ virtio_transport_dgram_enqueue(struct vsock_sock *vsk,
 		}
 		total_written += written;
 		pkt_off += written;
-		pr_debug("%s:id=%d, dgram_len=%zu, off=%zu, total_written=%zu, written=%zu\n",
+		pr_debug("%s:id=%d, dgram_len=%zu, off=%zu, total_written=%zu, written=%d\n",
 			  __func__, dgram_id, dgram_len, pkt_off, total_written, written);
 	}
 

Thanks!

The dgram functionality has been dropped in the latest patch revision but I'll keep your fix in mind if it's brought back.

Stefan