Skip to contentSkip to conversation

wireguard fixes for 5.7-rc4

PATCH In review Jason A. Donenfeld 2 participants 5 messages Apr 29, 2020

Subsystems (3)
lore
Share & tools
lore

Jason A. Donenfeld

author maintainer
#0 lore raw

cover wireguard fixes for 5.7-rc4

Hi Dave,

This series contains two fixes and a cleanup for wireguard:

1) Removal of a spurious newline, from Sultan Alsawaf.

2) Fix for a memory leak in an error path, in which memory allocated prior to the error wasn't freed, reported by Sultan Alsawaf.

3) Fix to ECN support to use RFC6040 properly like all the other tunnel drivers, from Toke Høiland-Jørgensen.

Thanks,
Jason

Jason A. Donenfeld (1):
wireguard: queueing: cleanup ptr_ring in error path of
packet_queue_init

Sultan Alsawaf (1):
wireguard: send: remove errant newline from packet_encrypt_worker

Toke Høiland-Jørgensen (1):
wireguard: receive: use tunnel helpers for decapsulating ECN markings

 drivers/net/wireguard/queueing.c | 4 +++-
 drivers/net/wireguard/receive.c  | 6 ++----
 drivers/net/wireguard/send.c     | 1 -
 3 files changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.26.2
author maintainer
#1 lore raw

PATCH 1/3 wireguard: send: remove errant newline from packet_encrypt_worker

From: Sultan Alsawaf <[email protected]>

This commit removes a useless newline at the end of a scope, which doesn't add anything in the way of organization or readability.

---
 drivers/net/wireguard/send.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/wireguard/send.c +0 -1
index 7348c10cbae3..3e030d614df5 100644
@@ -304,7 +304,6 @@ void wg_packet_encrypt_worker(struct work_struct *work)
 		}
 		wg_queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first,
 					  state);
-
 	}
 }
 
Signature · 1 line
2.26.2
author maintainer
#2 lore raw

PATCH 2/3 wireguard: queueing: cleanup ptr_ring in error path of packet_queue_init

In reply to Jason A. Donenfeld

Prior, if the alloc_percpu of packet_percpu_multicore_worker_alloc failed, the previously allocated ptr_ring wouldn't be freed. This commit adds the missing call to ptr_ring_cleanup in the error case.

Fixes e7096c131e51 ("net: WireGuard secure network tunnel")
---
 drivers/net/wireguard/queueing.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireguard/queueing.c +3 -1
index 5c964fcb994e..71b8e80b58e1 100644
@@ -35,8 +35,10 @@ int wg_packet_queue_init(struct crypt_queue *queue, work_func_t function,
 		if (multicore) {
 			queue->worker = wg_packet_percpu_multicore_worker_alloc(
 				function, queue);
-			if (!queue->worker)
+			if (!queue->worker) {
+				ptr_ring_cleanup(&queue->ring, NULL);
 				return -ENOMEM;
+			}
 		} else {
 			INIT_WORK(&queue->work, function);
 		}
Signature · 1 line
2.26.2
author maintainer
#3 lore raw

PATCH 3/3 wireguard: receive: use tunnel helpers for decapsulating ECN markings

In reply to Jason A. Donenfeld

From: Toke Høiland-Jørgensen <[email protected]>

WireGuard currently only propagates ECN markings on tunnel decap according to the old RFC3168 specification. However, the spec has since been updated in RFC6040 to recommend slightly different decapsulation semantics. This was implemented in the kernel as a set of common helpers for ECN decapsulation, so let's just switch over WireGuard to using those, so it can benefit from this enhancement and any future tweaks. We do not drop packets with invalid ECN marking combinations, because WireGuard is frequently used to work around broken ISPs, which could be doing that.

Fixes e7096c131e51 ("net: WireGuard secure network tunnel")
Cc Dave Taht <[email protected]>
Cc Rodney W. Grimes <[email protected]>
---
 drivers/net/wireguard/receive.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireguard/receive.c +2 -4
index da3b782ab7d3..267f202f1931 100644
@@ -393,13 +393,11 @@ static void wg_packet_consume_data_done(struct wg_peer *peer,
 		len = ntohs(ip_hdr(skb)->tot_len);
 		if (unlikely(len < sizeof(struct iphdr)))
 			goto dishonest_packet_size;
-		if (INET_ECN_is_ce(PACKET_CB(skb)->ds))
-			IP_ECN_set_ce(ip_hdr(skb));
+		INET_ECN_decapsulate(skb, PACKET_CB(skb)->ds, ip_hdr(skb)->tos);
 	} else if (skb->protocol == htons(ETH_P_IPV6)) {
 		len = ntohs(ipv6_hdr(skb)->payload_len) +
 		      sizeof(struct ipv6hdr);
-		if (INET_ECN_is_ce(PACKET_CB(skb)->ds))
-			IP6_ECN_set_ce(skb, ipv6_hdr(skb));
+		INET_ECN_decapsulate(skb, PACKET_CB(skb)->ds, ipv6_get_dsfield(ipv6_hdr(skb)));
 	} else {
 		goto dishonest_packet_type;
 	}
Signature · 1 line
2.26.2
maintainer
#4 lore raw
In reply to Jason A. Donenfeld

From: "Jason A. Donenfeld" <[email protected]>
Date: Wed, 29 Apr 2020 14:59:19 -0600

Quoted 11 lines

Hi Dave,

This series contains two fixes and a cleanup for wireguard:

1) Removal of a spurious newline, from Sultan Alsawaf.

2) Fix for a memory leak in an error path, in which memory allocated prior to the error wasn't freed, reported by Sultan Alsawaf.

3) Fix to ECN support to use RFC6040 properly like all the other tunnel drivers, from Toke Høiland-Jørgensen.

Series applied, and patches #2 and #3 queued up for -stable.