Pull up following revision(s) (requested by christos in ticket #1233): sys/compat/linux/common/linux_socket.c: revision 1.145 sys/net/if.c: revision 1.449 sys/compat/linux32/common/linux32_socket.c: revision 1.30 sys/compat/common/uipc_syscalls_40.c: revision 1.19 Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack disclosure. From Andy Nguyen, many thanks! - 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@diff -r1.13.6.2 -r1.13.6.3 src/sys/compat/common/uipc_syscalls_40.c
(martin)
--- src/sys/compat/common/uipc_syscalls_40.c 2017/12/04 13:55:00 1.13.6.2
+++ src/sys/compat/common/uipc_syscalls_40.c 2019/04/19 09:12:58 1.13.6.3
@@ -1,19 +1,19 @@ | @@ -1,19 +1,19 @@ | |||
1 | /* $NetBSD: uipc_syscalls_40.c,v 1.13.6.2 2017/12/04 13:55:00 martin Exp $ */ | 1 | /* $NetBSD: uipc_syscalls_40.c,v 1.13.6.3 2019/04/19 09:12:58 martin Exp $ */ | |
2 | 2 | |||
3 | /* written by Pavel Cahyna, 2006. Public domain. */ | 3 | /* written by Pavel Cahyna, 2006. Public domain. */ | |
4 | 4 | |||
5 | #include <sys/cdefs.h> | 5 | #include <sys/cdefs.h> | |
6 | __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13.6.2 2017/12/04 13:55:00 martin Exp $"); | 6 | __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13.6.3 2019/04/19 09:12:58 martin Exp $"); | |
7 | 7 | |||
8 | /* | 8 | /* | |
9 | * System call interface to the socket abstraction. | 9 | * System call interface to the socket abstraction. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | #include <sys/param.h> | 12 | #include <sys/param.h> | |
13 | #include <sys/kernel.h> | 13 | #include <sys/kernel.h> | |
14 | #include <sys/msg.h> | 14 | #include <sys/msg.h> | |
15 | #include <sys/sysctl.h> | 15 | #include <sys/sysctl.h> | |
16 | #include <sys/syscallargs.h> | 16 | #include <sys/syscallargs.h> | |
17 | #include <sys/errno.h> | 17 | #include <sys/errno.h> | |
18 | 18 | |||
19 | #include <net/if.h> | 19 | #include <net/if.h> | |
@@ -32,26 +32,27 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscall | @@ -32,26 +32,27 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscall | |||
32 | int | 32 | int | |
33 | compat_ifconf(u_long cmd, void *data) | 33 | compat_ifconf(u_long cmd, void *data) | |
34 | { | 34 | { | |
35 | struct oifconf *ifc = data; | 35 | struct oifconf *ifc = data; | |
36 | struct ifnet *ifp; | 36 | struct ifnet *ifp; | |
37 | struct oifreq ifr, *ifrp = NULL; | 37 | struct oifreq ifr, *ifrp = NULL; | |
38 | int space = 0, error = 0; | 38 | int space = 0, error = 0; | |
39 | const int sz = (int)sizeof(ifr); | 39 | const int sz = (int)sizeof(ifr); | |
40 | const bool docopy = ifc->ifc_req != NULL; | 40 | const bool docopy = ifc->ifc_req != NULL; | |
41 | int s; | 41 | int s; | |
42 | int bound; | 42 | int bound; | |
43 | struct psref psref; | 43 | struct psref psref; | |
44 | 44 | |||
45 | memset(&ifr, 0, sizeof(ifr)); | |||
45 | if (docopy) { | 46 | if (docopy) { | |
46 | space = ifc->ifc_len; | 47 | space = ifc->ifc_len; | |
47 | ifrp = ifc->ifc_req; | 48 | ifrp = ifc->ifc_req; | |
48 | } | 49 | } | |
49 | 50 | |||
50 | bound = curlwp_bind(); | 51 | bound = curlwp_bind(); | |
51 | s = pserialize_read_enter(); | 52 | s = pserialize_read_enter(); | |
52 | IFNET_READER_FOREACH(ifp) { | 53 | IFNET_READER_FOREACH(ifp) { | |
53 | struct ifaddr *ifa; | 54 | struct ifaddr *ifa; | |
54 | 55 | |||
55 | if_acquire(ifp, &psref); | 56 | if_acquire(ifp, &psref); | |
56 | pserialize_read_exit(s); | 57 | pserialize_read_exit(s); | |
57 | 58 |
--- src/sys/compat/linux/common/linux_socket.c 2018/12/08 12:24:18 1.138.6.3
+++ src/sys/compat/linux/common/linux_socket.c 2019/04/19 09:12:58 1.138.6.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_socket.c,v 1.138.6.3 2018/12/08 12:24:18 martin Exp $ */ | 1 | /* $NetBSD: linux_socket.c,v 1.138.6.4 2019/04/19 09:12:58 martin Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Frank van der Linden and Eric Haszlakiewicz. | 8 | * by Frank van der Linden and Eric Haszlakiewicz. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Functions in multiarch: | 33 | * Functions in multiarch: | |
34 | * linux_sys_socketcall : linux_socketcall.c | 34 | * linux_sys_socketcall : linux_socketcall.c | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138.6.3 2018/12/08 12:24:18 martin Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138.6.4 2019/04/19 09:12:58 martin Exp $"); | |
39 | 39 | |||
40 | #if defined(_KERNEL_OPT) | 40 | #if defined(_KERNEL_OPT) | |
41 | #include "opt_inet.h" | 41 | #include "opt_inet.h" | |
42 | #endif /* defined(_KERNEL_OPT) */ | 42 | #endif /* defined(_KERNEL_OPT) */ | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/buf.h> | 47 | #include <sys/buf.h> | |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> | |
49 | #include <sys/tty.h> | 49 | #include <sys/tty.h> | |
50 | #include <sys/file.h> | 50 | #include <sys/file.h> | |
51 | #include <sys/filedesc.h> | 51 | #include <sys/filedesc.h> | |
@@ -1142,26 +1142,27 @@ linux_getifconf(struct lwp *l, register_ | @@ -1142,26 +1142,27 @@ linux_getifconf(struct lwp *l, register_ | |||
1142 | struct sockaddr *sa; | 1142 | struct sockaddr *sa; | |
1143 | struct osockaddr *osa; | 1143 | struct osockaddr *osa; | |
1144 | int space = 0, error; | 1144 | int space = 0, error; | |
1145 | const int sz = (int)sizeof(ifr); | 1145 | const int sz = (int)sizeof(ifr); | |
1146 | bool docopy; | 1146 | bool docopy; | |
1147 | int s; | 1147 | int s; | |
1148 | int bound; | 1148 | int bound; | |
1149 | struct psref psref; | 1149 | struct psref psref; | |
1150 | 1150 | |||
1151 | error = copyin(data, &ifc, sizeof(ifc)); | 1151 | error = copyin(data, &ifc, sizeof(ifc)); | |
1152 | if (error) | 1152 | if (error) | |
1153 | return error; | 1153 | return error; | |
1154 | 1154 | |||
1155 | memset(&ifr, 0, sizeof(ifr)); | |||
1155 | docopy = ifc.ifc_req != NULL; | 1156 | docopy = ifc.ifc_req != NULL; | |
1156 | if (docopy) { | 1157 | if (docopy) { | |
1157 | space = ifc.ifc_len; | 1158 | space = ifc.ifc_len; | |
1158 | ifrp = ifc.ifc_req; | 1159 | ifrp = ifc.ifc_req; | |
1159 | } | 1160 | } | |
1160 | 1161 | |||
1161 | bound = curlwp_bind(); | 1162 | bound = curlwp_bind(); | |
1162 | s = pserialize_read_enter(); | 1163 | s = pserialize_read_enter(); | |
1163 | IFNET_READER_FOREACH(ifp) { | 1164 | IFNET_READER_FOREACH(ifp) { | |
1164 | struct ifaddr *ifa; | 1165 | struct ifaddr *ifa; | |
1165 | if_acquire(ifp, &psref); | 1166 | if_acquire(ifp, &psref); | |
1166 | pserialize_read_exit(s); | 1167 | pserialize_read_exit(s); | |
1167 | 1168 |
--- src/sys/compat/linux32/common/linux32_socket.c 2018/05/12 10:29:08 1.27.6.2
+++ src/sys/compat/linux32/common/linux32_socket.c 2019/04/19 09:12:58 1.27.6.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux32_socket.c,v 1.27.6.2 2018/05/12 10:29:08 martin Exp $ */ | 1 | /* $NetBSD: linux32_socket.c,v 1.27.6.3 2019/04/19 09:12:58 martin Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. | 4 | * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. All advertising materials mentioning features or use of this software | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS | |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | 35 | |||
36 | __KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.27.6.2 2018/05/12 10:29:08 martin Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.27.6.3 2019/04/19 09:12:58 martin Exp $"); | |
37 | 37 | |||
38 | #include <sys/types.h> | 38 | #include <sys/types.h> | |
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/fstypes.h> | 40 | #include <sys/fstypes.h> | |
41 | #include <sys/signal.h> | 41 | #include <sys/signal.h> | |
42 | #include <sys/dirent.h> | 42 | #include <sys/dirent.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/fcntl.h> | 44 | #include <sys/fcntl.h> | |
45 | #include <sys/select.h> | 45 | #include <sys/select.h> | |
46 | #include <sys/proc.h> | 46 | #include <sys/proc.h> | |
47 | #include <sys/ucred.h> | 47 | #include <sys/ucred.h> | |
48 | #include <sys/swap.h> | 48 | #include <sys/swap.h> | |
49 | #include <sys/file.h> | 49 | #include <sys/file.h> | |
@@ -421,26 +421,27 @@ linux32_getifconf(struct lwp *l, registe | @@ -421,26 +421,27 @@ linux32_getifconf(struct lwp *l, registe | |||
421 | struct sockaddr *sa; | 421 | struct sockaddr *sa; | |
422 | struct osockaddr *osa; | 422 | struct osockaddr *osa; | |
423 | int space = 0, error; | 423 | int space = 0, error; | |
424 | const int sz = (int)sizeof(ifr); | 424 | const int sz = (int)sizeof(ifr); | |
425 | bool docopy; | 425 | bool docopy; | |
426 | int s; | 426 | int s; | |
427 | int bound; | 427 | int bound; | |
428 | struct psref psref; | 428 | struct psref psref; | |
429 | 429 | |||
430 | error = copyin(data, &ifc, sizeof(ifc)); | 430 | error = copyin(data, &ifc, sizeof(ifc)); | |
431 | if (error) | 431 | if (error) | |
432 | return error; | 432 | return error; | |
433 | 433 | |||
434 | memset(&ifr, 0, sizeof(ifr)); | |||
434 | docopy = NETBSD32PTR64(ifc.ifc_req) != NULL; | 435 | docopy = NETBSD32PTR64(ifc.ifc_req) != NULL; | |
435 | if (docopy) { | 436 | if (docopy) { | |
436 | space = ifc.ifc_len; | 437 | space = ifc.ifc_len; | |
437 | ifrp = NETBSD32PTR64(ifc.ifc_req); | 438 | ifrp = NETBSD32PTR64(ifc.ifc_req); | |
438 | } | 439 | } | |
439 | 440 | |||
440 | bound = curlwp_bind(); | 441 | bound = curlwp_bind(); | |
441 | s = pserialize_read_enter(); | 442 | s = pserialize_read_enter(); | |
442 | IFNET_READER_FOREACH(ifp) { | 443 | IFNET_READER_FOREACH(ifp) { | |
443 | struct ifaddr *ifa; | 444 | struct ifaddr *ifa; | |
444 | if_acquire(ifp, &psref); | 445 | if_acquire(ifp, &psref); | |
445 | pserialize_read_exit(s); | 446 | pserialize_read_exit(s); | |
446 | 447 |
--- src/sys/net/if.c 2018/11/06 14:38:58 1.394.2.15
+++ src/sys/net/if.c 2019/04/19 09:12:58 1.394.2.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if.c,v 1.394.2.15 2018/11/06 14:38:58 martin Exp $ */ | 1 | /* $NetBSD: if.c,v 1.394.2.16 2019/04/19 09:12:58 martin Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by William Studenmund and Jason R. Thorpe. | 8 | * by William Studenmund and Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -80,27 +80,27 @@ | @@ -80,27 +80,27 @@ | |||
80 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 80 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
81 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 81 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
82 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 82 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
83 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 83 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
84 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 84 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
85 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 85 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
86 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 86 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
87 | * SUCH DAMAGE. | 87 | * SUCH DAMAGE. | |
88 | * | 88 | * | |
89 | * @(#)if.c 8.5 (Berkeley) 1/9/95 | 89 | * @(#)if.c 8.5 (Berkeley) 1/9/95 | |
90 | */ | 90 | */ | |
91 | 91 | |||
92 | #include <sys/cdefs.h> | 92 | #include <sys/cdefs.h> | |
93 | __KERNEL_RCSID(0, "$NetBSD: if.c,v 1.394.2.15 2018/11/06 14:38:58 martin Exp $"); | 93 | __KERNEL_RCSID(0, "$NetBSD: if.c,v 1.394.2.16 2019/04/19 09:12:58 martin Exp $"); | |
94 | 94 | |||
95 | #if defined(_KERNEL_OPT) | 95 | #if defined(_KERNEL_OPT) | |
96 | #include "opt_inet.h" | 96 | #include "opt_inet.h" | |
97 | #include "opt_ipsec.h" | 97 | #include "opt_ipsec.h" | |
98 | #include "opt_atalk.h" | 98 | #include "opt_atalk.h" | |
99 | #include "opt_natm.h" | 99 | #include "opt_natm.h" | |
100 | #include "opt_wlan.h" | 100 | #include "opt_wlan.h" | |
101 | #include "opt_net_mpsafe.h" | 101 | #include "opt_net_mpsafe.h" | |
102 | #include "opt_mrouting.h" | 102 | #include "opt_mrouting.h" | |
103 | #endif | 103 | #endif | |
104 | 104 | |||
105 | #include <sys/param.h> | 105 | #include <sys/param.h> | |
106 | #include <sys/mbuf.h> | 106 | #include <sys/mbuf.h> | |
@@ -3313,26 +3313,27 @@ static int | @@ -3313,26 +3313,27 @@ static int | |||
3313 | ifconf(u_long cmd, void *data) | 3313 | ifconf(u_long cmd, void *data) | |
3314 | { | 3314 | { | |
3315 | struct ifconf *ifc = (struct ifconf *)data; | 3315 | struct ifconf *ifc = (struct ifconf *)data; | |
3316 | struct ifnet *ifp; | 3316 | struct ifnet *ifp; | |
3317 | struct ifaddr *ifa; | 3317 | struct ifaddr *ifa; | |
3318 | struct ifreq ifr, *ifrp = NULL; | 3318 | struct ifreq ifr, *ifrp = NULL; | |
3319 | int space = 0, error = 0; | 3319 | int space = 0, error = 0; | |
3320 | const int sz = (int)sizeof(struct ifreq); | 3320 | const int sz = (int)sizeof(struct ifreq); | |
3321 | const bool docopy = ifc->ifc_req != NULL; | 3321 | const bool docopy = ifc->ifc_req != NULL; | |
3322 | int s; | 3322 | int s; | |
3323 | int bound; | 3323 | int bound; | |
3324 | struct psref psref; | 3324 | struct psref psref; | |
3325 | 3325 | |||
3326 | memset(&ifr, 0, sizeof(ifr)); | |||
3326 | if (docopy) { | 3327 | if (docopy) { | |
3327 | space = ifc->ifc_len; | 3328 | space = ifc->ifc_len; | |
3328 | ifrp = ifc->ifc_req; | 3329 | ifrp = ifc->ifc_req; | |
3329 | } | 3330 | } | |
3330 | 3331 | |||
3331 | bound = curlwp_bind(); | 3332 | bound = curlwp_bind(); | |
3332 | s = pserialize_read_enter(); | 3333 | s = pserialize_read_enter(); | |
3333 | IFNET_READER_FOREACH(ifp) { | 3334 | IFNET_READER_FOREACH(ifp) { | |
3334 | psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class); | 3335 | psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class); | |
3335 | pserialize_read_exit(s); | 3336 | pserialize_read_exit(s); | |
3336 | 3337 | |||
3337 | (void)strncpy(ifr.ifr_name, ifp->if_xname, | 3338 | (void)strncpy(ifr.ifr_name, ifp->if_xname, | |
3338 | sizeof(ifr.ifr_name)); | 3339 | sizeof(ifr.ifr_name)); |