Source-Changes-HG archive

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

[src/trunk]: src/sys/compat Zero out the ifreq struct for SIOCGIFCONF to avoi...



details:   https://anonhg.NetBSD.org/src/rev/27653aa516b9
branches:  trunk
changeset: 998433:27653aa516b9
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Apr 18 17:45:12 2019 +0000

description:
Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@

diffstat:

 sys/compat/common/uipc_syscalls_40.c       |  5 +++--
 sys/compat/linux/common/linux_socket.c     |  5 +++--
 sys/compat/linux32/common/linux32_socket.c |  5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diffs (75 lines):

diff -r 5bedad0a53a0 -r 27653aa516b9 sys/compat/common/uipc_syscalls_40.c
--- a/sys/compat/common/uipc_syscalls_40.c      Thu Apr 18 17:13:00 2019 +0000
+++ b/sys/compat/common/uipc_syscalls_40.c      Thu Apr 18 17:45:12 2019 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: uipc_syscalls_40.c,v 1.18 2019/03/01 11:06:56 pgoyette Exp $   */
+/*     $NetBSD: uipc_syscalls_40.c,v 1.19 2019/04/18 17:45:12 christos Exp $   */
 
 /* written by Pavel Cahyna, 2006. Public domain. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.18 2019/03/01 11:06:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.19 2019/04/18 17:45:12 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -56,6 +56,7 @@
                return ENOSYS;
        }
 
+       memset(&ifr, 0, sizeof(ifr));
        if (docopy) {
                space = ifc->ifc_len;
                ifrp = ifc->ifc_req;
diff -r 5bedad0a53a0 -r 27653aa516b9 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Thu Apr 18 17:13:00 2019 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Thu Apr 18 17:45:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_socket.c,v 1.144 2019/02/04 04:37:50 mrg Exp $   */
+/*     $NetBSD: linux_socket.c,v 1.145 2019/04/18 17:45:12 christos Exp $      */
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.144 2019/02/04 04:37:50 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.145 2019/04/18 17:45:12 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1136,6 +1136,7 @@
        if (error)
                return error;
 
+       memset(&ifr, 0, sizeof(ifr));
        docopy = ifc.ifc_req != NULL;
        if (docopy) {
                space = ifc.ifc_len;
diff -r 5bedad0a53a0 -r 27653aa516b9 sys/compat/linux32/common/linux32_socket.c
--- a/sys/compat/linux32/common/linux32_socket.c        Thu Apr 18 17:13:00 2019 +0000
+++ b/sys/compat/linux32/common/linux32_socket.c        Thu Apr 18 17:45:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_socket.c,v 1.29 2018/05/10 01:32:24 ozaki-r Exp $ */
+/*     $NetBSD: linux32_socket.c,v 1.30 2019/04/18 17:45:12 christos Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.29 2018/05/10 01:32:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.30 2019/04/18 17:45:12 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -431,6 +431,7 @@
        if (error)
                return error;
 
+       memset(&ifr, 0, sizeof(ifr));
        docopy = NETBSD32PTR64(ifc.ifc_req) != NULL;
        if (docopy) {
                space = ifc.ifc_len;



Home | Main Index | Thread Index | Old Index