Source-Changes-HG archive

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

[src/trunk]: src/sys Fix pullup'ed mbuf leaks. The match function just requir...



details:   https://anonhg.NetBSD.org/src/rev/d543771381b8
branches:  trunk
changeset: 828466:d543771381b8
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Fri Dec 15 05:01:16 2017 +0000

description:
Fix pullup'ed mbuf leaks. The match function just requires enough mbuf length.

XXX need pullup-8

diffstat:

 sys/netinet/in_l2tp.c   |  12 +++++-------
 sys/netinet6/in6_l2tp.c |  12 +++++-------
 2 files changed, 10 insertions(+), 14 deletions(-)

diffs (68 lines):

diff -r 340eb1aff6e5 -r d543771381b8 sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c     Fri Dec 15 04:58:31 2017 +0000
+++ b/sys/netinet/in_l2tp.c     Fri Dec 15 05:01:16 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_l2tp.c,v 1.6 2017/12/15 04:58:31 knakahara Exp $    */
+/*     $NetBSD: in_l2tp.c,v 1.7 2017/12/15 05:01:16 knakahara Exp $    */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.6 2017/12/15 04:58:31 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.7 2017/12/15 05:01:16 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -369,12 +369,10 @@
        KASSERT(proto == IPPROTO_L2TP);
 
        if (m->m_len < off + sizeof(uint32_t)) {
-               m = m_pullup(m, off + sizeof(uint32_t));
-               if (!m) {
-                       /* if payload length < 4 octets */
+               /* if payload length < 4 octets */
+               if(!m_ensure_contig(&m, off + sizeof(uint32_t)))
                        return 0;
-               }
-        }
+       }
 
        /* get L2TP session ID */
        m_copydata(m, off, sizeof(uint32_t), (void *)&sess_id);
diff -r 340eb1aff6e5 -r d543771381b8 sys/netinet6/in6_l2tp.c
--- a/sys/netinet6/in6_l2tp.c   Fri Dec 15 04:58:31 2017 +0000
+++ b/sys/netinet6/in6_l2tp.c   Fri Dec 15 05:01:16 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_l2tp.c,v 1.9 2017/12/15 04:58:31 knakahara Exp $   */
+/*     $NetBSD: in6_l2tp.c,v 1.10 2017/12/15 05:01:16 knakahara Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.9 2017/12/15 04:58:31 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.10 2017/12/15 05:01:16 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -361,12 +361,10 @@
        KASSERT(proto == IPPROTO_L2TP);
 
        if (m->m_len < off + sizeof(uint32_t)) {
-               m = m_pullup(m, off + sizeof(uint32_t));
-               if (!m) {
-                       /* if payload length < 4 octets */
+               /* if payload length < 4 octets */
+               if(!m_ensure_contig(&m, off + sizeof(uint32_t)))
                        return 0;
-               }
-        }
+       }
 
        /* get L2TP session ID */
        m_copydata(m, off, sizeof(uint32_t), (void *)&sess_id);



Home | Main Index | Thread Index | Old Index