NetBSD Problem Report #60743

From www@netbsd.org  Fri Sep 18 21:00:59 2026
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 "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id DE2841A923B
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 18 Sep 2026 21:00:59 +0000 (UTC)
Message-Id: <20260918210058.839FC1A923C@mollari.NetBSD.org>
Date: Fri, 18 Sep 2026 21:00:58 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: l2tp(4): missing and broken access/sanity checks
X-Send-Pr-Version: www-1.0
X-From4GNATS: "campbell+netbsd@mumble.net via gnats" <gnats-admin@NetBSD.org>

>Number:         60743
>Category:       kern
>Synopsis:       l2tp(4): missing and broken access/sanity checks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          needs-pullups
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 18 21:05:00 +0000 2026
>Closed-Date:    
>Last-Modified:  Sat Sep 19 02:20:01 +0000 2026
>Originator:     Taylor R Campbell
>Release:        current, 11, 10, ...
>Organization:
The NetL2TP Foundsomebugs, Inc.
>Environment:
>Description:

	1. l2tp_ioctl is missing kauth checks for all
	   interface-specific privileged ioctl commands like
	   SIOCSL2TPSESSION.  Generic ioctls with have kauth checks in
	   doifioctl, but interface-specific ones are the interface's
	   responsibility:

   3498 	switch (cmd) {
   3499 	case SIOCALIFADDR:
...
   3525 	case SIOCSLINKSTR:
   3526 		if (l != NULL) {
   3527 			error = kauth_authorize_network(l->l_cred,
   3528 			    KAUTH_NETWORK_INTERFACE,
   3529 			    KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp,
   3530 			    KAUTH_ARG(cmd), NULL);
   3531 			if (error != 0)
   3532 				goto out;
   3533 		}
   3534 	}

	   https://nxr.NetBSD.org/xref/src/sys/net/if.c?r=1.538#3498

	2. Cookie length validation has && where it needs || to verify
	   that the cookie length is either 4 or 8:

   1284 	if (my_cookie_len != 4 && my_cookie_len != 8
   1285 	    && peer_cookie_len != 4 && peer_cookie_len != 8)
   1286 		return EINVAL;

	   https://nxr.netbsd.org/xref/src/sys/net/if_l2tp.c?r=1.49#1284

>How-To-Repeat:
	int s;
	struct ifreq ifr;
	struct l2tp_req l2tpr;

	s = socket(AF_INET, SOCK_DGRAM, 0);
	if (s == -1)
		err(1, "socket");

	memset(&ifr, 0, sizeof(ifr));
	ifr.ifr_data = &l2tpr;
	strncpy(ifr.ifr_name, "l2tp0", sizeof(ifr.ifr_name));

	memset(&l2tpr, 0, sizeof(l2tpr));
	l2tpr.my_cookie = 1;
	l2tpr.peer_cookie = 1;
	l2tpr.my_cookie_len = 4;
	l2tpr.peer_cookie_len = 12345;
	if (ioctl(s, SIOCSL2TPCOOKIE, &ifr) == -1)
		err(1, "ioctl(SIOCSL2TPCOOKIE)");

>Fix:

	1. add kauth check
	2. && ---> ||

>Release-Note:

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60743 CVS commit: src/sys/net
Date: Sat, 19 Sep 2026 02:14:44 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sat Sep 19 02:14:44 UTC 2026

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

 Log Message:
 l2tp(4): Add missing kauth checks for various configuration ioctls.

 PR kern/60743: l2tp(4): missing and broken access/sanity checks


 To generate a diff of this commit:
 cvs rdiff -u -r1.49 -r1.50 src/sys/net/if_l2tp.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: Sat, 19 Sep 2026 02:19:23 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-11, pullup-10


From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60743 CVS commit: src/sys/net
Date: Sat, 19 Sep 2026 02:15:13 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sat Sep 19 02:15:13 UTC 2026

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

 Log Message:
 l2tp(4): Fix logic in cookie length checks.

 PR kern/60743: l2tp(4): missing and broken access/sanity checks


 To generate a diff of this commit:
 cvs rdiff -u -r1.50 -r1.51 src/sys/net/if_l2tp.c

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.