Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 Make sure im6o_memberships is protected by in6p...
details: https://anonhg.NetBSD.org/src/rev/1d4df3aeb964
branches: trunk
changeset: 351866:1d4df3aeb964
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Mar 02 05:26:24 2017 +0000
description:
Make sure im6o_memberships is protected by in6p's lock (solock)
diffstat:
sys/netinet6/in6_pcb.c | 12 ++++++++++--
sys/netinet6/in6_pcb.h | 6 ++++--
sys/netinet6/ip6_output.c | 7 ++++---
3 files changed, 18 insertions(+), 7 deletions(-)
diffs (98 lines):
diff -r b5fb11dd0c8b -r 1d4df3aeb964 sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c Thu Mar 02 05:24:23 2017 +0000
+++ b/sys/netinet6/in6_pcb.c Thu Mar 02 05:26:24 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.c,v 1.158 2017/03/02 01:05:02 ozaki-r Exp $ */
+/* $NetBSD: in6_pcb.c,v 1.159 2017/03/02 05:26:24 ozaki-r Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.158 2017/03/02 01:05:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.159 2017/03/02 05:26:24 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -844,9 +844,15 @@
TAILQ_FOREACH_SAFE(inph, &table->inpt_queue, inph_queue, ninph) {
struct in6pcb *in6p = (struct in6pcb *)inph;
+ bool need_unlock = false;
if (in6p->in6p_af != AF_INET6)
continue;
+ /* The caller holds either one of in6ps' lock */
+ if (!in6p_locked(in6p)) {
+ in6p_lock(in6p);
+ need_unlock = true;
+ }
im6o = in6p->in6p_moptions;
if (im6o) {
/*
@@ -871,6 +877,8 @@
}
}
in_purgeifmcast(in6p->in6p_v4moptions, ifp);
+ if (need_unlock)
+ in6p_unlock(in6p);
}
}
diff -r b5fb11dd0c8b -r 1d4df3aeb964 sys/netinet6/in6_pcb.h
--- a/sys/netinet6/in6_pcb.h Thu Mar 02 05:24:23 2017 +0000
+++ b/sys/netinet6/in6_pcb.h Thu Mar 02 05:26:24 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.h,v 1.48 2017/02/22 07:05:04 ozaki-r Exp $ */
+/* $NetBSD: in6_pcb.h,v 1.49 2017/03/02 05:26:24 ozaki-r Exp $ */
/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
/*
@@ -107,7 +107,9 @@
#define in6p_faddr in6p_ip6.ip6_dst
#define in6p_laddr in6p_ip6.ip6_src
-#define in6plocked(in6p) solocked((in6p)->in6p_socket)
+#define in6p_lock(in6p) solock((in6p)->in6p_socket)
+#define in6p_unlock(in6p) sounlock((in6p)->in6p_socket)
+#define in6p_locked(in6p) solocked((in6p)->in6p_socket)
/* states in inp_state: */
#define IN6P_ATTACHED INP_ATTACHED
diff -r b5fb11dd0c8b -r 1d4df3aeb964 sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Thu Mar 02 05:24:23 2017 +0000
+++ b/sys/netinet6/ip6_output.c Thu Mar 02 05:26:24 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_output.c,v 1.189 2017/03/02 05:24:23 ozaki-r Exp $ */
+/* $NetBSD: ip6_output.c,v 1.190 2017/03/02 05:26:24 ozaki-r Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.189 2017/03/02 05:24:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.190 2017/03/02 05:26:24 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -2471,7 +2471,7 @@
struct ip6_moptions *im6o = in6p->in6p_moptions;
struct in6_multi_mship *imm;
- KASSERT(in6plocked(in6p));
+ KASSERT(in6p_locked(in6p));
if (im6o == NULL) {
/*
@@ -2772,6 +2772,7 @@
if (im6o == NULL)
return;
+ /* The owner of im6o (in6p) should be protected by solock */
LIST_FOREACH_SAFE(imm, &im6o->im6o_memberships, i6mm_chain, nimm) {
LIST_REMOVE(imm, i6mm_chain);
in6_leavegroup(imm);
Home |
Main Index |
Thread Index |
Old Index