diff options
| author | ozaki-r <ozaki-r@NetBSD.org> | 2016-06-15 06:01:21 +0000 |
|---|---|---|
| committer | ozaki-r <ozaki-r@NetBSD.org> | 2016-06-15 06:01:21 +0000 |
| commit | 8edd76059eba50e289d8511b3efa523074a132f0 (patch) | |
| tree | 692144b533c5a3b9cc5c2acd9f80a523c08d4498 /sys/compat/linux/common/linux_socket.c | |
| parent | dede62b2338dde1d16dfdaf96db1dc1ec3a08a6c (diff) | |
Protect if_byindex by pserialize
Diffstat (limited to 'sys/compat/linux/common/linux_socket.c')
| -rw-r--r-- | sys/compat/linux/common/linux_socket.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c index 2c2e7cdb6d4..ad62a60e6cc 100644 --- a/sys/compat/linux/common/linux_socket.c +++ b/sys/compat/linux/common/linux_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.127 2016/05/12 02:24:16 ozaki-r Exp $ */ +/* $NetBSD: linux_socket.c,v 1.128 2016/06/15 06:01:21 ozaki-r 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.127 2016/05/12 02:24:16 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.128 2016/06/15 06:01:21 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1092,16 +1092,21 @@ linux_getifname(struct lwp *l, register_t *retval, void *data) struct ifnet *ifp; struct linux_ifreq ifr; int error; + int s; error = copyin(data, &ifr, sizeof(ifr)); if (error) return error; + s = pserialize_read_enter(); ifp = if_byindex(ifr.ifr_ifru.ifru_ifindex); - if (ifp == NULL) + if (ifp == NULL) { + pserialize_read_exit(s); return ENODEV; + } strncpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name)); + pserialize_read_exit(s); return copyout(&ifr, data, sizeof(ifr)); } |
