Module Name: src
Committed By: martin
Date: Mon May 25 17:48:16 UTC 2020
Modified Files:
src/sys/kern [netbsd-8]: kern_time.c
src/sys/netinet [netbsd-8]: igmp.c
Log Message:
Pull up following revision(s) (requested by christos in ticket #1549):
sys/netinet/igmp.c: revision 1.70
sys/kern/kern_time.c: revision 1.204
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.
-
Fix uninitialized memory access. Found by KMSAN.
To generate a diff of this commit:
cvs rdiff -u -r1.189.8.5 -r1.189.8.6 src/sys/kern/kern_time.c
cvs rdiff -u -r1.64.6.2 -r1.64.6.3 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/kern/kern_time.c
diff -u src/sys/kern/kern_time.c:1.189.8.5 src/sys/kern/kern_time.c:1.189.8.6
--- src/sys/kern/kern_time.c:1.189.8.5 Sun Feb 24 10:49:53 2019
+++ src/sys/kern/kern_time.c Mon May 25 17:48:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_time.c,v 1.189.8.5 2019/02/24 10:49:53 martin Exp $ */
+/* $NetBSD: kern_time.c,v 1.189.8.6 2020/05/25 17:48:16 martin Exp $ */
/*-
* Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.5 2019/02/24 10:49:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.6 2020/05/25 17:48:16 martin Exp $");
#include <sys/param.h>
#include <sys/resourcevar.h>
@@ -354,8 +354,12 @@ again:
struct timespec rmtend;
struct timespec t0;
struct timespec *t;
+ int err;
+
+ err = clock_gettime1(clock_id, &rmtend);
+ if (err != 0)
+ return err;
- (void)clock_gettime1(clock_id, &rmtend);
t = (rmt != NULL) ? rmt : &t0;
if (flags & TIMER_ABSTIME) {
timespecsub(rqt, &rmtend, t);
Index: src/sys/netinet/igmp.c
diff -u src/sys/netinet/igmp.c:1.64.6.2 src/sys/netinet/igmp.c:1.64.6.3
--- src/sys/netinet/igmp.c:1.64.6.2 Fri Jul 13 14:26:47 2018
+++ src/sys/netinet/igmp.c Mon May 25 17:48:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: igmp.c,v 1.64.6.2 2018/07/13 14:26:47 martin Exp $ */
+/* $NetBSD: igmp.c,v 1.64.6.3 2020/05/25 17:48:16 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.64.6.2 2018/07/13 14:26:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64.6.3 2020/05/25 17:48:16 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
@@ -620,6 +620,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;