NetBSD Problem Report #55779

From root@sunaj.Acrys.COM  Mon Nov  2 16:39:10 2020
Return-Path: <root@sunaj.Acrys.COM>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B92F31A9239
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  2 Nov 2020 16:39:10 +0000 (UTC)
Message-Id: <20201102163505.6D0A1EE1C59@sunaj.Acrys.COM>
Date: Mon,  2 Nov 2020 16:35:05 +0000 (UTC)
From: kardel@netbsd.org
Reply-To: kardel@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: NetBSD multicast router sends multicast packet with invalid UDP checksum
X-Send-Pr-Version: 3.95

>Number:         55779
>Notify-List:    kim
>Category:       kern
>Synopsis:       NetBSD multicast router sends multicast packet with invalid UDP checksum
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 02 16:40:00 +0000 2020
>Closed-Date:    Tue Dec 08 07:34:54 +0000 2020
>Last-Modified:  Tue Dec 08 07:34:54 +0000 2020
>Originator:     Frank Kardel
>Release:        NetBSD 9.0_STABLE/-current
>Organization:

>Environment:


System: NetBSD sunaj 9.0_STABLE NetBSD 9.0_STABLE (ROUTER) #2: Tue Oct 20 09:55:21 UTC 2020 kardel@sunaj:/src/NetBSD/n9/src/obj.amd64/sys/arch/amd64/compile/ROUTER amd64
Architecture: x86_64
Machine: amd64
>Description:
	Configure a kernel to support MROUTING,PIM.
	Use a routing suite like FRRouting (FRRouting.org - see wip/frr)
	UDP checksumming must be enabled
	Start the routing suite just for RIP and observe RIP packets with
	invalid checksums being sent.

	Analysis:
	udp_output() correctly sets up m->m_pkthdr.csum_flags = M_CSUM_UDPv4.
	in the ip_output the path following MROUTING section is reached:

            if (ip_mrouter && (flags & IP_FORWARDING) == 0) {
                    if (ip_mforward(m, ifp) != 0) {
                            m_freem(m);
                            goto done;
                    }
            }

	at this point m->m_pkthdr.csum_flags ==  M_CSUM_UDPv4. after the
	call to ip_mforward m->m_pkthdr.csum_flags is zero.

	this is caused by commit 1.112->1.113:
-------
revision 1.113
date: 2008-05-08 08:00:55 +0000;  author: taca;  state: Exp;  lines: +7 -2;
Make sure to clear csum_flags before forward the packet.

This change should be fix DIAGNOSTIC kernel's panic when the machine act
as multicast router.

Advised from tls@ and approved by thorpej@.
-------
	The zeroing of m->m_pkthdr.csum_flags directly violates the
	guarantee from the boilerplate comment:

 * The packet is returned unscathed to the caller, unless it is
 * erroneous, in which case a non-zero return value tells the caller to
 * discard it.

	this is problematic as we lose the M_CSUM_UDPv4 information which
	in turn causes *NO UDP checksums* for multicast packets to be
	calculated.

>How-To-Repeat:
	see Description:
>Fix:
	Crude fix 1:
		restore m->m_pkthdr.csum_flags after ip_mforward call.

	Crude fix 2:
		wrap ip_mforward with flag restoration.

	Alternate fixes:
		Is the diagnostic issue gone after 12 years?
			yes - remove the zeroing
			no - examine the actual root cause

>Release-Note:

>Audit-Trail:

From: "Frank Kardel" <kardel@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55779 CVS commit: src/sys/netinet
Date: Thu, 12 Nov 2020 13:13:45 +0000

 Module Name:	src
 Committed By:	kardel
 Date:		Thu Nov 12 13:13:45 UTC 2020

 Modified Files:
 	src/sys/netinet: ip_mroute.c

 Log Message:
 PR kern/55779:

 restore non-desctructive guarantee of ip_mforward() mbuf
 argument. This avoids generation invalid UDP checksums
 on multicast packets in ip_output().

 XXX the root cause of the misguided fix in 2008 should be
 XXX investigated


 To generate a diff of this commit:
 cvs rdiff -u -r1.163 -r1.164 src/sys/netinet/ip_mroute.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->pending-pullups
State-Changed-By: kardel@NetBSD.org
State-Changed-When: Mon, 07 Dec 2020 12:32:51 +0000
State-Changed-Why:
[pullup-8 #1632] pullup fix for PR kern/55779 (invalid mcast UDP checksums) (patch)
[pullup-9 #1143] pullup fix for PR kern/55779 (invalid mcast UDP checksums) (patch)


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55779 CVS commit: [netbsd-9] src/sys/netinet
Date: Mon, 7 Dec 2020 19:58:04 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Dec  7 19:58:04 UTC 2020

 Modified Files:
 	src/sys/netinet [netbsd-9]: ip_mroute.c

 Log Message:
 Pull up following revision(s) (requested by kardel in ticket #1143):

 	sys/netinet/ip_mroute.c: revision 1.164

 PR kern/55779:

 restore non-desctructive guarantee of ip_mforward() mbuf
 argument. This avoids generation invalid UDP checksums
 on multicast packets in ip_output().

 XXX the root cause of the misguided fix in 2008 should be
 XXX investigated


 To generate a diff of this commit:
 cvs rdiff -u -r1.163 -r1.163.4.1 src/sys/netinet/ip_mroute.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55779 CVS commit: [netbsd-8] src/sys/netinet
Date: Mon, 7 Dec 2020 20:01:02 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Dec  7 20:01:02 UTC 2020

 Modified Files:
 	src/sys/netinet [netbsd-8]: ip_mroute.c

 Log Message:
 Pull up following revision(s) (requested by kardel in ticket #1632):

 	sys/netinet/ip_mroute.c: revision 1.164 (patch)

 PR kern/55779:

 restore non-desctructive guarantee of ip_mforward() mbuf
 argument. This avoids generation invalid UDP checksums
 on multicast packets in ip_output().

 XXX the root cause of the misguided fix in 2008 should be
 XXX investigated


 To generate a diff of this commit:
 cvs rdiff -u -r1.146.6.4 -r1.146.6.5 src/sys/netinet/ip_mroute.c

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

State-Changed-From-To: pending-pullups->closed
State-Changed-By: kardel@NetBSD.org
State-Changed-When: Tue, 08 Dec 2020 07:34:54 +0000
State-Changed-Why:
pullups done.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.