Source-Changes-HG archive

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

[src/trunk]: src/sys/net wg: Make sure all paths into wg_handle_msg_data guar...



details:   https://anonhg.NetBSD.org/src/rev/3b245f619fe1
branches:  trunk
changeset: 943119:3b245f619fe1
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Aug 27 03:05:34 2020 +0000

description:
wg: Make sure all paths into wg_handle_msg_data guarantee enough m_len.

Earlier commit moved the m_pullup into wg_validate_msg_header, but
wg_overudp_cb doesn't go through that.

diffstat:

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

diffs (30 lines):

diff -r f8096ed04abd -r 3b245f619fe1 sys/net/if_wg.c
--- a/sys/net/if_wg.c   Thu Aug 27 02:55:04 2020 +0000
+++ b/sys/net/if_wg.c   Thu Aug 27 03:05:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $     */
+/*     $NetBSD: if_wg.c,v 1.29 2020/08/27 03:05:34 riastradh Exp $     */
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ryota%gmail.com@localhost>
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.29 2020/08/27 03:05:34 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2955,6 +2955,11 @@
        case WG_MSG_TYPE_DATA:
                /* handle immediately */
                m_adj(m, offset);
+               if (__predict_false(m->m_len < sizeof(struct wg_msg_data))) {
+                       m = m_pullup(m, sizeof(struct wg_msg_data));
+                       if (m == NULL)
+                               return -1;
+               }
                wg_handle_msg_data(wg, m, src);
                *mp = NULL;
                return 1;



Home | Main Index | Thread Index | Old Index