From: Razvan Cojocaru <[email protected]>

A broadcast or multicast packet is queued once and shared by all
recipients. With compress, compress stub or compress lz4 the byte swap
framing rewrites the packet in place, so every recipient after the
first got it with its first byte replaced by 0xFB. In TAP mode this
broke ARP and DHCP broadcasts for all clients but one. In TUN mode the
client's kernel rejected the packet, logged as "write to TUN/TAP:
Invalid argument".

When the recipient uses the byte swap, copy a buffer that is still
queued for other recipients before handing it to encrypt_sign().

GitHub: closes OpenVPN/openvpn#461
Change-Id: I8d424804372707a23fdc6fe77163cffabf72ea00
Signed-off-by: Razvan Cojocaru <[email protected]>
Acked-by: Antonio Quartulli <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2377
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2377
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Antonio Quartulli <[email protected]>

        
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 900b5a3..a71a484 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -3757,6 +3757,20 @@
     {
         unsigned int pip_flags = PIPV4_PASSTOS | PIPV6_ICMP_NOHOST_SERVER;
 
+#ifdef USE_COMP
+        /* the compression byte swap changes the packet in place, so
+         * don't let it touch a buffer that other recipients still have
+         * queued */
+        const struct compress_context *comp = 
item.instance->context.c2.comp_context;
+        if (item.buffer->refcount > 1 && comp && (comp->flags & COMP_F_SWAP))
+        {
+            struct mbuf_buffer *mb = mbuf_alloc_buf(&item.buffer->buf);
+            mb->flags = item.buffer->flags;
+            mbuf_free_buf(item.buffer);
+            item.buffer = mb;
+        }
+#endif
+
         set_prefix(item.instance);
         item.instance->context.c2.buf = item.buffer->buf;
         if (item.buffer->flags


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to