Module Name:    src
Committed By:   martin
Date:           Mon May 18 18:59:40 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by maxv in ticket #915):

        sys/netinet/igmp.c: revision 1.70

igmp_sendpkt() expects ip_output() to set 'imo.imo_multicast_ttl' into
'ip->ip_ttl'; but ip_output() won't if the target is not a multicast
address, meaning that the uninitialized 'ip->ip_ttl' byte gets sent to
the network. This leaks one byte of kernel heap.

Fix this by filling 'ip->ip_ttl' with a TTL of one.

Found by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.69.4.1 src/sys/netinet/igmp.c

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

Modified files:

Index: src/sys/netinet/igmp.c
diff -u src/sys/netinet/igmp.c:1.69 src/sys/netinet/igmp.c:1.69.4.1
--- src/sys/netinet/igmp.c:1.69	Fri Sep 14 05:09:51 2018
+++ src/sys/netinet/igmp.c	Mon May 18 18:59:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: igmp.c,v 1.69 2018/09/14 05:09:51 maxv Exp $	*/
+/*	$NetBSD: igmp.c,v 1.69.4.1 2020/05/18 18:59:39 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.69 2018/09/14 05:09:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.69.4.1 2020/05/18 18:59:39 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -613,6 +613,7 @@ igmp_sendpkt(struct in_multi *inm, int t
 	ip->ip_tos = 0;
 	ip->ip_len = htons(sizeof(struct ip) + IGMP_MINLEN);
 	ip->ip_off = htons(0);
+	ip->ip_ttl = IP_DEFAULT_MULTICAST_TTL;
 	ip->ip_p = IPPROTO_IGMP;
 	ip->ip_src = zeroin_addr;
 	ip->ip_dst = inm->inm_addr;

Reply via email to