Source-Changes-HG archive

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

src: Fix l2tp(4) alignment check. Pointed out and reviewed by k-...



details:   https://anonhg.NetBSD.org/src/rev/a86b43f40373
branches:  trunk
changeset: 317932:a86b43f40373
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Apr 09 10:06:59 2018 +0000
description:
Fix l2tp(4) alignment check. Pointed out and reviewed by k-goda@IIJ.

The alignment check should be done for the address of m_data instead of
the value of m_data.

XXX pullup-8

diffstat:

 sys/net/if_l2tp.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (44 lines):

diff -r 45f8b8b6e1c4 -r a86b43f40373 sys/net/if_l2tp.c
--- a/sys/net/if_l2tp.c Mon Apr 09 07:22:03 2018 +0000
+++ b/sys/net/if_l2tp.c Mon Apr 09 10:06:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_l2tp.c,v 1.20 2018/01/26 14:10:15 maxv Exp $        */
+/*     $NetBSD: if_l2tp.c,v 1.21 2018/04/09 10:06:59 knakahara Exp $   */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.20 2018/01/26 14:10:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.21 2018/04/09 10:06:59 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -465,18 +465,20 @@
 void
 l2tp_input(struct mbuf *m, struct ifnet *ifp)
 {
-       u_long val;
+       vaddr_t addr;
 
        KASSERT(ifp != NULL);
 
-       if (m->m_pkthdr.len < sizeof(val)) {
+       /*
+        * Currently, l2tp(4) supports only ethernet as inner protocol.
+        */
+       if (m->m_pkthdr.len < sizeof(struct ether_header)) {
                m_freem(m);
                return;
        }
 
-       m_copydata(m, 0, sizeof(val), &val);
-
-       if ((val & 0x03) == 0) {
+       addr = mtod(m, vaddr_t);
+       if ((addr & 0x03) == 0) {
                /* copy and align head of payload */
                struct mbuf *m_head;
                int copy_length;



Home | Main Index | Thread Index | Old Index