NetBSD Problem Report #58521

From www@netbsd.org  Mon Jul 29 19:31:06 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 356681A923C
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 29 Jul 2024 19:31:06 +0000 (UTC)
Message-Id: <20240729193105.5BE061A923E@mollari.NetBSD.org>
Date: Mon, 29 Jul 2024 19:31:05 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: experimental wg(4) may drop packet after minutes of quiet
X-Send-Pr-Version: www-1.0

>Number:         58521
>Category:       kern
>Synopsis:       experimental wg(4) may drop packet after minutes of quiet
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 29 19:35:00 +0000 2024
>Closed-Date:    Wed Oct 09 14:40:05 +0000 2024
>Last-Modified:  Wed Oct 09 14:40:05 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10
>Organization:
e NetWG Foundation
>Environment:
>Description:
3min after establishing a session, wg(4) is forbidden to transmit any new data with that session.

But if neither peer has transmitted anything in the last minute, neither peer has had a reason to rekey.

In that case, we might trigger the session limits and attempt to reinitiate the session:

   3712 		if (__predict_false(wg_session_hit_limits(wgs))) {
   3713 			WG_TRACE("stable session hit limits");
   3714 			wg_schedule_peer_task(wgp, WGP_TASK_SEND_INIT_MESSAGE);
https://nxr.netbsd.org/xref/src/sys/net/if_wg.c?r=1.122#3712

And when we do that, we drop the packet, even if a new session gets established within a few dozen milliseconds.

Note that this only happens for sessions that have already been established for a few minutes.  For new sessions, we don't drop the first packet -- we queue it up to be sent as soon as the session is established.
>How-To-Repeat:
1. code inspection
2. transmit for 2min - epsilon, then stop all traffic for 1min + 2epsilon, then try to transmit a packet (before the session destruction timer triggers)
>Fix:
Queue the packet in wgp_pending in this case too.

>Release-Note:

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58521 CVS commit: src/sys/net
Date: Mon, 29 Jul 2024 19:46:25 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Mon Jul 29 19:46:25 UTC 2024

 Modified Files:
 	src/sys/net: if_wg.c

 Log Message:
 wg(4): Queue packet for post-handshake retransmit if limits are hit.

 PR kern/58521: experimental wg(4) may drop packet after minutes of quiet


 To generate a diff of this commit:
 cvs rdiff -u -r1.126 -r1.127 src/sys/net/if_wg.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Mon, 29 Jul 2024 20:17:41 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-10


State-Changed-From-To: needs-pullups->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Wed, 09 Oct 2024 14:40:05 +0000
State-Changed-Why:
fixed in HEAD, pulled up to 10
pullup-10 #934 https://releng.netbsd.org/cgi-bin/req-10.cgi?show=934


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.