Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys Pull up following revision(s) (requested by ozaki-r i...
details: https://anonhg.NetBSD.org/src/rev/a8fa1ea57cf6
branches: netbsd-8
changeset: 434457:a8fa1ea57cf6
user: martin <martin%NetBSD.org@localhost>
date: Thu Nov 30 15:57:36 2017 +0000
description:
Pull up following revision(s) (requested by ozaki-r in ticket #407):
sys/compat/linux32/common/linux32_socket.c: revision 1.28
sys/net/if.c: revision 1.400
sys/netipsec/key.c: revision 1.243
sys/compat/linux/common/linux_socket.c: revision 1.139
sys/netinet/ip_carp.c: revision 1.93
sys/netinet6/in6.c: revision 1.252
sys/netinet6/in6.c: revision 1.253
sys/netinet6/in6.c: revision 1.254
sys/net/if_spppsubr.c: revision 1.173
sys/net/if_spppsubr.c: revision 1.174
sys/compat/common/uipc_syscalls_40.c: revision 1.14
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Fix usage of FOREACH macro
key_sad.lock is held there so SAVLIST_WRITER_FOREACH is enough.
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref (more)
Fix and make consistent of usages of psz/psref in ifconf variants
Remove unnecessary goto because there is no cleanup code to share (NFC)
Tweak a condition; we don't need to care ifacount to be negative
Fix a race condition of in6_ifinit
in6_ifinit checks the number of IPv6 addresses on a given interface and
if it's zero (i.e., an IPv6 address being assigned to the interface
is the first one), call if_addr_init. However, the actual assignment of
the address (ifa_insert) is out of in6_ifinit. The check and the
assignment must be done atomically.
Fix it by holding in6_ifaddr_lock during in6_ifinit and ifa_insert.
And also add missing pserialize to IFADDR_READER_FOREACH.
diffstat:
sys/compat/common/uipc_syscalls_40.c | 29 ++++++++-----
sys/compat/linux/common/linux_socket.c | 9 ++-
sys/compat/linux32/common/linux32_socket.c | 9 ++-
sys/net/if.c | 14 ++++-
sys/net/if_spppsubr.c | 35 ++++++++++++++--
sys/netinet/ip_carp.c | 62 +++++++++++++++++++++++------
sys/netinet6/in6.c | 33 +++++++++------
sys/netipsec/key.c | 6 +-
8 files changed, 138 insertions(+), 59 deletions(-)
diffs (truncated from 721 to 300 lines):
diff -r 1c0f04576688 -r a8fa1ea57cf6 sys/compat/common/uipc_syscalls_40.c
--- a/sys/compat/common/uipc_syscalls_40.c Thu Nov 30 14:57:34 2017 +0000
+++ b/sys/compat/common/uipc_syscalls_40.c Thu Nov 30 15:57:36 2017 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: uipc_syscalls_40.c,v 1.13 2017/03/14 09:03:08 ozaki-r Exp $ */
+/* $NetBSD: uipc_syscalls_40.c,v 1.13.6.1 2017/11/30 15:57:37 martin Exp $ */
/* written by Pavel Cahyna, 2006. Public domain. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13.6.1 2017/11/30 15:57:37 martin Exp $");
/*
* System call interface to the socket abstraction.
@@ -53,6 +53,7 @@
struct ifaddr *ifa;
if_acquire(ifp, &psref);
+ pserialize_read_exit(s);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -69,9 +70,10 @@
ifrp++;
}
space -= sizeof(ifr);
- continue;
+ goto next;
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct sockaddr *sa = ifa->ifa_addr;
struct psref psref_ifa;
@@ -85,11 +87,8 @@
/*
* If it does not fit, we don't bother with it
*/
- if (sa->sa_len > sizeof(*osa)) {
- s = pserialize_read_enter();
- ifa_release(ifa, &psref_ifa);
- continue;
- }
+ if (sa->sa_len > sizeof(*osa))
+ goto next_ifa;
memcpy(&ifr.ifr_addr, sa, sa->sa_len);
osa->sa_family = sa->sa_family;
if (space >= sz) {
@@ -119,13 +118,20 @@
(char *)&ifrp->ifr_addr);
}
}
+ if (error != 0) {
+ ifa_release(ifa, &psref_ifa);
+ goto release_exit;
+ }
+ space -= sz;
+
+ next_ifa:
s = pserialize_read_enter();
ifa_release(ifa, &psref_ifa);
- if (error != 0)
- goto release_exit;
- space -= sz;
}
+ pserialize_read_exit(s);
+ next:
+ s = pserialize_read_enter();
if_release(ifp, &psref);
}
pserialize_read_exit(s);
@@ -138,7 +144,6 @@
return (0);
release_exit:
- pserialize_read_exit(s);
if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
diff -r 1c0f04576688 -r a8fa1ea57cf6 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c Thu Nov 30 14:57:34 2017 +0000
+++ b/sys/compat/linux/common/linux_socket.c Thu Nov 30 15:57:36 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.138 2017/03/14 09:03:08 ozaki-r Exp $ */
+/* $NetBSD: linux_socket.c,v 1.138.6.1 2017/11/30 15:57:37 martin 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.138 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138.6.1 2017/11/30 15:57:37 martin Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1144,6 +1144,7 @@
IFNET_READER_FOREACH(ifp) {
struct ifaddr *ifa;
if_acquire(ifp, &psref);
+ pserialize_read_exit(s);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -1152,6 +1153,7 @@
goto release_exit;
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct psref psref_ifa;
ifa_acquire(ifa, &psref_ifa);
@@ -1167,7 +1169,6 @@
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
if (error != 0) {
- s = pserialize_read_enter();
ifa_release(ifa, &psref_ifa);
goto release_exit;
}
@@ -1179,6 +1180,7 @@
ifa_release(ifa, &psref_ifa);
}
+ s = pserialize_read_enter();
if_release(ifp, &psref);
}
pserialize_read_exit(s);
@@ -1192,7 +1194,6 @@
return copyout(&ifc, data, sizeof(ifc));
release_exit:
- pserialize_read_exit(s);
if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
diff -r 1c0f04576688 -r a8fa1ea57cf6 sys/compat/linux32/common/linux32_socket.c
--- a/sys/compat/linux32/common/linux32_socket.c Thu Nov 30 14:57:34 2017 +0000
+++ b/sys/compat/linux32/common/linux32_socket.c Thu Nov 30 15:57:36 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_socket.c,v 1.27 2017/03/14 09:03:08 ozaki-r Exp $ */
+/* $NetBSD: linux32_socket.c,v 1.27.6.1 2017/11/30 15:57:36 martin 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.27 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.27.6.1 2017/11/30 15:57:36 martin Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -442,6 +442,7 @@
IFNET_READER_FOREACH(ifp) {
struct ifaddr *ifa;
if_acquire(ifp, &psref);
+ pserialize_read_exit(s);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -450,6 +451,7 @@
goto release_exit;
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct psref psref_ifa;
ifa_acquire(ifa, &psref_ifa);
@@ -465,7 +467,6 @@
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
if (error != 0) {
- s = pserialize_read_enter();
ifa_release(ifa, &psref_ifa);
goto release_exit;
}
@@ -477,6 +478,7 @@
ifa_release(ifa, &psref_ifa);
}
+ s = pserialize_read_enter();
if_release(ifp, &psref);
}
pserialize_read_exit(s);
@@ -490,7 +492,6 @@
return copyout(&ifc, data, sizeof(ifc));
release_exit:
- pserialize_read_exit(s);
if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
diff -r 1c0f04576688 -r a8fa1ea57cf6 sys/net/if.c
--- a/sys/net/if.c Thu Nov 30 14:57:34 2017 +0000
+++ b/sys/net/if.c Thu Nov 30 15:57:36 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.394.2.1 2017/07/01 08:56:06 snj Exp $ */
+/* $NetBSD: if.c,v 1.394.2.2 2017/11/30 15:57:37 martin Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.394.2.1 2017/07/01 08:56:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.394.2.2 2017/11/30 15:57:37 martin Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -3138,7 +3138,7 @@
memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
if (!docopy) {
space += sz;
- continue;
+ goto next;
}
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
@@ -3149,6 +3149,7 @@
}
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct sockaddr *sa = ifa->ifa_addr;
/* all sockaddrs must fit in sockaddr_storage */
@@ -3159,14 +3160,19 @@
continue;
}
memcpy(&ifr.ifr_space, sa, sa->sa_len);
+ pserialize_read_exit(s);
+
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
if (error != 0)
goto release_exit;
ifrp++; space -= sz;
}
+ s = pserialize_read_enter();
}
-
+ pserialize_read_exit(s);
+
+ next:
s = pserialize_read_enter();
psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
}
diff -r 1c0f04576688 -r a8fa1ea57cf6 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c Thu Nov 30 14:57:34 2017 +0000
+++ b/sys/net/if_spppsubr.c Thu Nov 30 15:57:36 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_spppsubr.c,v 1.169.6.1 2017/11/02 20:28:24 snj Exp $ */
+/* $NetBSD: if_spppsubr.c,v 1.169.6.2 2017/11/30 15:57:37 martin Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.169.6.1 2017/11/02 20:28:24 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.169.6.2 2017/11/30 15:57:37 martin Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -5219,6 +5219,8 @@
struct ifaddr *ifa;
struct sockaddr_in *si, *sm;
uint32_t ssrc, ddst;
+ int s;
+ struct psref psref;
sm = NULL;
ssrc = ddst = 0;
@@ -5227,14 +5229,18 @@
* aliases don't make any sense on a p2p link anyway.
*/
si = 0;
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family == AF_INET) {
si = (struct sockaddr_in *)ifa->ifa_addr;
sm = (struct sockaddr_in *)ifa->ifa_netmask;
- if (si)
+ if (si) {
+ ifa_acquire(ifa, &psref);
break;
+ }
}
}
+ pserialize_read_exit(s);
if (ifa) {
if (si && si->sin_addr.s_addr) {
ssrc = si->sin_addr.s_addr;
Home |
Main Index |
Thread Index |
Old Index