Module Name: src Committed By: knakahara Date: Mon Apr 9 10:06:59 UTC 2018
Modified Files: src/sys/net: if_l2tp.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/net/if_l2tp.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/net/if_l2tp.c diff -u src/sys/net/if_l2tp.c:1.20 src/sys/net/if_l2tp.c:1.21 --- src/sys/net/if_l2tp.c:1.20 Fri Jan 26 14:10:15 2018 +++ src/sys/net/if_l2tp.c Mon Apr 9 10:06:59 2018 @@ -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 @@ l2tpintr(struct l2tp_variant *var) 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;