Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet igmp_sendpkt() expects ip_output() to set 'imo.i...



details:   https://anonhg.NetBSD.org/src/rev/f6b5451aa8e2
branches:  trunk
changeset: 972073:f6b5451aa8e2
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri May 15 06:34:34 2020 +0000

description:
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.

Reported-by: syzbot+e49f7b8a8fec5a477c9a%syzkaller.appspotmail.com@localhost

diffstat:

 sys/netinet/igmp.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r e19217b6f9e7 -r f6b5451aa8e2 sys/netinet/igmp.c
--- a/sys/netinet/igmp.c        Fri May 15 06:26:44 2020 +0000
+++ b/sys/netinet/igmp.c        Fri May 15 06:34:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: igmp.c,v 1.69 2018/09/14 05:09:51 maxv Exp $   */
+/*     $NetBSD: igmp.c,v 1.70 2020/05/15 06:34:34 maxv 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.70 2020/05/15 06:34:34 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -613,6 +613,7 @@
        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;



Home | Main Index | Thread Index | Old Index