* [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs @ 2012-12-06 19:25 Thomas Graf 2012-12-06 19:25 ` [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() Thomas Graf ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Thomas Graf @ 2012-12-06 19:25 UTC (permalink / raw) To: linux-sctp; +Cc: netdev, vyasevich, nhorman @Dave: This is a respin of the following patches: [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() [PATCH] sctp: Add RCU protection to assoc->transport_addr_list Thomas Graf (2): sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() sctp: Add RCU protection to assoc->transport_addr_list include/net/sctp/structs.h | 2 ++ net/sctp/associola.c | 6 +++--- net/sctp/proc.c | 21 ++++++++++++++++++--- net/sctp/transport.c | 18 +++++++++++++----- 4 files changed, 36 insertions(+), 11 deletions(-) -- 1.7.11.7 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() 2012-12-06 19:25 [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs Thomas Graf @ 2012-12-06 19:25 ` Thomas Graf 2012-12-06 20:07 ` Vlad Yasevich 2012-12-06 19:25 ` [PATCH 2/2] sctp: Add RCU protection to assoc->transport_addr_list Thomas Graf 2012-12-07 19:15 ` [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs David Miller 2 siblings, 1 reply; 8+ messages in thread From: Thomas Graf @ 2012-12-06 19:25 UTC (permalink / raw) To: linux-sctp; +Cc: netdev, vyasevich, nhorman, Thomas Graf From: Thomas Graf <tgraf@redhat.com> address_list is protected via the socket lock or RCU. Since we don't want to take the socket lock for each assoc we dump in procfs a RCU read-side critical section must be entered. V2: Skip local addresses marked as dead Cc: Vlad Yasevich <vyasevich@gmail.com> Cc: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Thomas Graf <tgraf@suug.ch> --- net/sctp/proc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 9966e7b..06b05ee 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c @@ -139,7 +139,11 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo primary = &peer->saddr; } - list_for_each_entry(laddr, &epb->bind_addr.address_list, list) { + rcu_read_lock(); + list_for_each_entry_rcu(laddr, &epb->bind_addr.address_list, list) { + if (!laddr->valid) + continue; + addr = &laddr->a; af = sctp_get_af_specific(addr->sa.sa_family); if (primary && af->cmp_addr(addr, primary)) { @@ -147,6 +151,7 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo } af->seq_dump_addr(seq, addr); } + rcu_read_unlock(); } /* Dump remote addresses of an association. */ -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() 2012-12-06 19:25 ` [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() Thomas Graf @ 2012-12-06 20:07 ` Vlad Yasevich 2012-12-06 21:12 ` Neil Horman 0 siblings, 1 reply; 8+ messages in thread From: Vlad Yasevich @ 2012-12-06 20:07 UTC (permalink / raw) To: Thomas Graf; +Cc: linux-sctp, netdev, nhorman, Thomas Graf On 12/06/2012 02:25 PM, Thomas Graf wrote: > From: Thomas Graf <tgraf@redhat.com> > > address_list is protected via the socket lock or RCU. Since we don't want > to take the socket lock for each assoc we dump in procfs a RCU read-side > critical section must be entered. > > V2: Skip local addresses marked as dead > > Cc: Vlad Yasevich <vyasevich@gmail.com> > Cc: Neil Horman <nhorman@tuxdriver.com> > Signed-off-by: Thomas Graf <tgraf@suug.ch> Acked-by: Vlad Yasevich <vyasevic@gmail.com> -vlad > --- > net/sctp/proc.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/net/sctp/proc.c b/net/sctp/proc.c > index 9966e7b..06b05ee 100644 > --- a/net/sctp/proc.c > +++ b/net/sctp/proc.c > @@ -139,7 +139,11 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo > primary = &peer->saddr; > } > > - list_for_each_entry(laddr, &epb->bind_addr.address_list, list) { > + rcu_read_lock(); > + list_for_each_entry_rcu(laddr, &epb->bind_addr.address_list, list) { > + if (!laddr->valid) > + continue; > + > addr = &laddr->a; > af = sctp_get_af_specific(addr->sa.sa_family); > if (primary && af->cmp_addr(addr, primary)) { > @@ -147,6 +151,7 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo > } > af->seq_dump_addr(seq, addr); > } > + rcu_read_unlock(); > } > > /* Dump remote addresses of an association. */ > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() 2012-12-06 20:07 ` Vlad Yasevich @ 2012-12-06 21:12 ` Neil Horman 0 siblings, 0 replies; 8+ messages in thread From: Neil Horman @ 2012-12-06 21:12 UTC (permalink / raw) To: Vlad Yasevich; +Cc: Thomas Graf, linux-sctp, netdev, Thomas Graf On Thu, Dec 06, 2012 at 03:07:20PM -0500, Vlad Yasevich wrote: > On 12/06/2012 02:25 PM, Thomas Graf wrote: > >From: Thomas Graf <tgraf@redhat.com> > > > >address_list is protected via the socket lock or RCU. Since we don't want > >to take the socket lock for each assoc we dump in procfs a RCU read-side > >critical section must be entered. > > > >V2: Skip local addresses marked as dead > > > >Cc: Vlad Yasevich <vyasevich@gmail.com> > >Cc: Neil Horman <nhorman@tuxdriver.com> > >Signed-off-by: Thomas Graf <tgraf@suug.ch> > > Acked-by: Vlad Yasevich <vyasevic@gmail.com> > > -vlad > Acked-by: Neil Horman <nhorman@tuxdriver.com> > >--- > > net/sctp/proc.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > >diff --git a/net/sctp/proc.c b/net/sctp/proc.c > >index 9966e7b..06b05ee 100644 > >--- a/net/sctp/proc.c > >+++ b/net/sctp/proc.c > >@@ -139,7 +139,11 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo > > primary = &peer->saddr; > > } > > > >- list_for_each_entry(laddr, &epb->bind_addr.address_list, list) { > >+ rcu_read_lock(); > >+ list_for_each_entry_rcu(laddr, &epb->bind_addr.address_list, list) { > >+ if (!laddr->valid) > >+ continue; > >+ > > addr = &laddr->a; > > af = sctp_get_af_specific(addr->sa.sa_family); > > if (primary && af->cmp_addr(addr, primary)) { > >@@ -147,6 +151,7 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo > > } > > af->seq_dump_addr(seq, addr); > > } > >+ rcu_read_unlock(); > > } > > > > /* Dump remote addresses of an association. */ > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] sctp: Add RCU protection to assoc->transport_addr_list 2012-12-06 19:25 [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs Thomas Graf 2012-12-06 19:25 ` [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() Thomas Graf @ 2012-12-06 19:25 ` Thomas Graf 2012-12-06 20:07 ` Vlad Yasevich 2012-12-07 19:15 ` [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs David Miller 2 siblings, 1 reply; 8+ messages in thread From: Thomas Graf @ 2012-12-06 19:25 UTC (permalink / raw) To: linux-sctp; +Cc: netdev, vyasevich, nhorman peer.transport_addr_list is currently only protected by sk_sock which is inpractical to acquire for procfs dumping purposes. This patch adds RCU protection allowing for the procfs readers to enter RCU read-side critical sections. Modification of the list continues to be serialized via sk_lock. V2: Use list_del_rcu() in sctp_association_free() to be safe Skip transports marked dead when dumping for procfs Cc: Vlad Yasevich <vyasevich@gmail.com> Cc: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Thomas Graf <tgraf@suug.ch> --- include/net/sctp/structs.h | 2 ++ net/sctp/associola.c | 6 +++--- net/sctp/proc.c | 14 ++++++++++++-- net/sctp/transport.c | 18 +++++++++++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 64158aa..5d6987b 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -948,6 +948,8 @@ struct sctp_transport { /* 64-bit random number sent with heartbeat. */ __u64 hb_nonce; + + struct rcu_head rcu; }; struct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *, diff --git a/net/sctp/associola.c b/net/sctp/associola.c index b1ef3bc..81b1236 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -445,7 +445,7 @@ void sctp_association_free(struct sctp_association *asoc) /* Release the transport structures. */ list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports); - list_del(pos); + list_del_rcu(pos); sctp_transport_free(transport); } @@ -565,7 +565,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, sctp_assoc_update_retran_path(asoc); /* Remove this peer from the list. */ - list_del(&peer->transports); + list_del_rcu(&peer->transports); /* Get the first transport of asoc. */ pos = asoc->peer.transport_addr_list.next; @@ -765,7 +765,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, peer->state = peer_state; /* Attach the remote transport to our asoc. */ - list_add_tail(&peer->transports, &asoc->peer.transport_addr_list); + list_add_tail_rcu(&peer->transports, &asoc->peer.transport_addr_list); asoc->peer.transport_count++; /* If we do not yet have a primary path, set one. */ diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 06b05ee..8c19e97 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c @@ -162,15 +162,20 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa struct sctp_af *af; primary = &assoc->peer.primary_addr; - list_for_each_entry(transport, &assoc->peer.transport_addr_list, + rcu_read_lock(); + list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list, transports) { addr = &transport->ipaddr; + if (transport->dead) + continue; + af = sctp_get_af_specific(addr->sa.sa_family); if (af->cmp_addr(addr, primary)) { seq_printf(seq, "*"); } af->seq_dump_addr(seq, addr); } + rcu_read_unlock(); } static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos) @@ -441,12 +446,16 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) head = &sctp_assoc_hashtable[hash]; sctp_local_bh_disable(); read_lock(&head->lock); + rcu_read_lock(); sctp_for_each_hentry(epb, node, &head->chain) { if (!net_eq(sock_net(epb->sk), seq_file_net(seq))) continue; assoc = sctp_assoc(epb); - list_for_each_entry(tsp, &assoc->peer.transport_addr_list, + list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list, transports) { + if (tsp->dead) + continue; + /* * The remote address (ADDR) */ @@ -492,6 +501,7 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) } } + rcu_read_unlock(); read_unlock(&head->lock); sctp_local_bh_enable(); diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 206cf52..1295aec 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c @@ -163,13 +163,11 @@ void sctp_transport_free(struct sctp_transport *transport) sctp_transport_put(transport); } -/* Destroy the transport data structure. - * Assumes there are no more users of this structure. - */ -static void sctp_transport_destroy(struct sctp_transport *transport) +static void sctp_transport_destroy_rcu(struct rcu_head *head) { - SCTP_ASSERT(transport->dead, "Transport is not dead", return); + struct sctp_transport *transport; + transport = container_of(head, struct sctp_transport, rcu); if (transport->asoc) sctp_association_put(transport->asoc); @@ -180,6 +178,16 @@ static void sctp_transport_destroy(struct sctp_transport *transport) SCTP_DBG_OBJCNT_DEC(transport); } +/* Destroy the transport data structure. + * Assumes there are no more users of this structure. + */ +static void sctp_transport_destroy(struct sctp_transport *transport) +{ + SCTP_ASSERT(transport->dead, "Transport is not dead", return); + + call_rcu(&transport->rcu, sctp_transport_destroy_rcu); +} + /* Start T3_rtx timer if it is not already running and update the heartbeat * timer. This routine is called every time a DATA chunk is sent. */ -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] sctp: Add RCU protection to assoc->transport_addr_list 2012-12-06 19:25 ` [PATCH 2/2] sctp: Add RCU protection to assoc->transport_addr_list Thomas Graf @ 2012-12-06 20:07 ` Vlad Yasevich 2012-12-06 21:14 ` Neil Horman 0 siblings, 1 reply; 8+ messages in thread From: Vlad Yasevich @ 2012-12-06 20:07 UTC (permalink / raw) To: Thomas Graf; +Cc: linux-sctp, netdev, nhorman On 12/06/2012 02:25 PM, Thomas Graf wrote: > peer.transport_addr_list is currently only protected by sk_sock > which is inpractical to acquire for procfs dumping purposes. > > This patch adds RCU protection allowing for the procfs readers to > enter RCU read-side critical sections. > > Modification of the list continues to be serialized via sk_lock. > > V2: Use list_del_rcu() in sctp_association_free() to be safe > Skip transports marked dead when dumping for procfs > > Cc: Vlad Yasevich <vyasevich@gmail.com> > Cc: Neil Horman <nhorman@tuxdriver.com> > Signed-off-by: Thomas Graf <tgraf@suug.ch> Acked-by: Vlad Yasevich <vyasevich@gmail.com> -vlad > --- > include/net/sctp/structs.h | 2 ++ > net/sctp/associola.c | 6 +++--- > net/sctp/proc.c | 14 ++++++++++++-- > net/sctp/transport.c | 18 +++++++++++++----- > 4 files changed, 30 insertions(+), 10 deletions(-) > > diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h > index 64158aa..5d6987b 100644 > --- a/include/net/sctp/structs.h > +++ b/include/net/sctp/structs.h > @@ -948,6 +948,8 @@ struct sctp_transport { > > /* 64-bit random number sent with heartbeat. */ > __u64 hb_nonce; > + > + struct rcu_head rcu; > }; > > struct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *, > diff --git a/net/sctp/associola.c b/net/sctp/associola.c > index b1ef3bc..81b1236 100644 > --- a/net/sctp/associola.c > +++ b/net/sctp/associola.c > @@ -445,7 +445,7 @@ void sctp_association_free(struct sctp_association *asoc) > /* Release the transport structures. */ > list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { > transport = list_entry(pos, struct sctp_transport, transports); > - list_del(pos); > + list_del_rcu(pos); > sctp_transport_free(transport); > } > > @@ -565,7 +565,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, > sctp_assoc_update_retran_path(asoc); > > /* Remove this peer from the list. */ > - list_del(&peer->transports); > + list_del_rcu(&peer->transports); > > /* Get the first transport of asoc. */ > pos = asoc->peer.transport_addr_list.next; > @@ -765,7 +765,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, > peer->state = peer_state; > > /* Attach the remote transport to our asoc. */ > - list_add_tail(&peer->transports, &asoc->peer.transport_addr_list); > + list_add_tail_rcu(&peer->transports, &asoc->peer.transport_addr_list); > asoc->peer.transport_count++; > > /* If we do not yet have a primary path, set one. */ > diff --git a/net/sctp/proc.c b/net/sctp/proc.c > index 06b05ee..8c19e97 100644 > --- a/net/sctp/proc.c > +++ b/net/sctp/proc.c > @@ -162,15 +162,20 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa > struct sctp_af *af; > > primary = &assoc->peer.primary_addr; > - list_for_each_entry(transport, &assoc->peer.transport_addr_list, > + rcu_read_lock(); > + list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list, > transports) { > addr = &transport->ipaddr; > + if (transport->dead) > + continue; > + > af = sctp_get_af_specific(addr->sa.sa_family); > if (af->cmp_addr(addr, primary)) { > seq_printf(seq, "*"); > } > af->seq_dump_addr(seq, addr); > } > + rcu_read_unlock(); > } > > static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos) > @@ -441,12 +446,16 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) > head = &sctp_assoc_hashtable[hash]; > sctp_local_bh_disable(); > read_lock(&head->lock); > + rcu_read_lock(); > sctp_for_each_hentry(epb, node, &head->chain) { > if (!net_eq(sock_net(epb->sk), seq_file_net(seq))) > continue; > assoc = sctp_assoc(epb); > - list_for_each_entry(tsp, &assoc->peer.transport_addr_list, > + list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list, > transports) { > + if (tsp->dead) > + continue; > + > /* > * The remote address (ADDR) > */ > @@ -492,6 +501,7 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) > } > } > > + rcu_read_unlock(); > read_unlock(&head->lock); > sctp_local_bh_enable(); > > diff --git a/net/sctp/transport.c b/net/sctp/transport.c > index 206cf52..1295aec 100644 > --- a/net/sctp/transport.c > +++ b/net/sctp/transport.c > @@ -163,13 +163,11 @@ void sctp_transport_free(struct sctp_transport *transport) > sctp_transport_put(transport); > } > > -/* Destroy the transport data structure. > - * Assumes there are no more users of this structure. > - */ > -static void sctp_transport_destroy(struct sctp_transport *transport) > +static void sctp_transport_destroy_rcu(struct rcu_head *head) > { > - SCTP_ASSERT(transport->dead, "Transport is not dead", return); > + struct sctp_transport *transport; > > + transport = container_of(head, struct sctp_transport, rcu); > if (transport->asoc) > sctp_association_put(transport->asoc); > > @@ -180,6 +178,16 @@ static void sctp_transport_destroy(struct sctp_transport *transport) > SCTP_DBG_OBJCNT_DEC(transport); > } > > +/* Destroy the transport data structure. > + * Assumes there are no more users of this structure. > + */ > +static void sctp_transport_destroy(struct sctp_transport *transport) > +{ > + SCTP_ASSERT(transport->dead, "Transport is not dead", return); > + > + call_rcu(&transport->rcu, sctp_transport_destroy_rcu); > +} > + > /* Start T3_rtx timer if it is not already running and update the heartbeat > * timer. This routine is called every time a DATA chunk is sent. > */ > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] sctp: Add RCU protection to assoc->transport_addr_list 2012-12-06 20:07 ` Vlad Yasevich @ 2012-12-06 21:14 ` Neil Horman 0 siblings, 0 replies; 8+ messages in thread From: Neil Horman @ 2012-12-06 21:14 UTC (permalink / raw) To: Vlad Yasevich; +Cc: Thomas Graf, linux-sctp, netdev On Thu, Dec 06, 2012 at 03:07:51PM -0500, Vlad Yasevich wrote: > On 12/06/2012 02:25 PM, Thomas Graf wrote: > >peer.transport_addr_list is currently only protected by sk_sock > >which is inpractical to acquire for procfs dumping purposes. > > > >This patch adds RCU protection allowing for the procfs readers to > >enter RCU read-side critical sections. > > > >Modification of the list continues to be serialized via sk_lock. > > > >V2: Use list_del_rcu() in sctp_association_free() to be safe > > Skip transports marked dead when dumping for procfs > > > >Cc: Vlad Yasevich <vyasevich@gmail.com> > >Cc: Neil Horman <nhorman@tuxdriver.com> > >Signed-off-by: Thomas Graf <tgraf@suug.ch> > > Acked-by: Vlad Yasevich <vyasevich@gmail.com> > > -vlad > Acked-by: Neil Horman <nhorman@tuxdriver.com> > >--- > > include/net/sctp/structs.h | 2 ++ > > net/sctp/associola.c | 6 +++--- > > net/sctp/proc.c | 14 ++++++++++++-- > > net/sctp/transport.c | 18 +++++++++++++----- > > 4 files changed, 30 insertions(+), 10 deletions(-) > > > >diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h > >index 64158aa..5d6987b 100644 > >--- a/include/net/sctp/structs.h > >+++ b/include/net/sctp/structs.h > >@@ -948,6 +948,8 @@ struct sctp_transport { > > > > /* 64-bit random number sent with heartbeat. */ > > __u64 hb_nonce; > >+ > >+ struct rcu_head rcu; > > }; > > > > struct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *, > >diff --git a/net/sctp/associola.c b/net/sctp/associola.c > >index b1ef3bc..81b1236 100644 > >--- a/net/sctp/associola.c > >+++ b/net/sctp/associola.c > >@@ -445,7 +445,7 @@ void sctp_association_free(struct sctp_association *asoc) > > /* Release the transport structures. */ > > list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { > > transport = list_entry(pos, struct sctp_transport, transports); > >- list_del(pos); > >+ list_del_rcu(pos); > > sctp_transport_free(transport); > > } > > > >@@ -565,7 +565,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, > > sctp_assoc_update_retran_path(asoc); > > > > /* Remove this peer from the list. */ > >- list_del(&peer->transports); > >+ list_del_rcu(&peer->transports); > > > > /* Get the first transport of asoc. */ > > pos = asoc->peer.transport_addr_list.next; > >@@ -765,7 +765,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, > > peer->state = peer_state; > > > > /* Attach the remote transport to our asoc. */ > >- list_add_tail(&peer->transports, &asoc->peer.transport_addr_list); > >+ list_add_tail_rcu(&peer->transports, &asoc->peer.transport_addr_list); > > asoc->peer.transport_count++; > > > > /* If we do not yet have a primary path, set one. */ > >diff --git a/net/sctp/proc.c b/net/sctp/proc.c > >index 06b05ee..8c19e97 100644 > >--- a/net/sctp/proc.c > >+++ b/net/sctp/proc.c > >@@ -162,15 +162,20 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa > > struct sctp_af *af; > > > > primary = &assoc->peer.primary_addr; > >- list_for_each_entry(transport, &assoc->peer.transport_addr_list, > >+ rcu_read_lock(); > >+ list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list, > > transports) { > > addr = &transport->ipaddr; > >+ if (transport->dead) > >+ continue; > >+ > > af = sctp_get_af_specific(addr->sa.sa_family); > > if (af->cmp_addr(addr, primary)) { > > seq_printf(seq, "*"); > > } > > af->seq_dump_addr(seq, addr); > > } > >+ rcu_read_unlock(); > > } > > > > static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos) > >@@ -441,12 +446,16 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) > > head = &sctp_assoc_hashtable[hash]; > > sctp_local_bh_disable(); > > read_lock(&head->lock); > >+ rcu_read_lock(); > > sctp_for_each_hentry(epb, node, &head->chain) { > > if (!net_eq(sock_net(epb->sk), seq_file_net(seq))) > > continue; > > assoc = sctp_assoc(epb); > >- list_for_each_entry(tsp, &assoc->peer.transport_addr_list, > >+ list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list, > > transports) { > >+ if (tsp->dead) > >+ continue; > >+ > > /* > > * The remote address (ADDR) > > */ > >@@ -492,6 +501,7 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) > > } > > } > > > >+ rcu_read_unlock(); > > read_unlock(&head->lock); > > sctp_local_bh_enable(); > > > >diff --git a/net/sctp/transport.c b/net/sctp/transport.c > >index 206cf52..1295aec 100644 > >--- a/net/sctp/transport.c > >+++ b/net/sctp/transport.c > >@@ -163,13 +163,11 @@ void sctp_transport_free(struct sctp_transport *transport) > > sctp_transport_put(transport); > > } > > > >-/* Destroy the transport data structure. > >- * Assumes there are no more users of this structure. > >- */ > >-static void sctp_transport_destroy(struct sctp_transport *transport) > >+static void sctp_transport_destroy_rcu(struct rcu_head *head) > > { > >- SCTP_ASSERT(transport->dead, "Transport is not dead", return); > >+ struct sctp_transport *transport; > > > >+ transport = container_of(head, struct sctp_transport, rcu); > > if (transport->asoc) > > sctp_association_put(transport->asoc); > > > >@@ -180,6 +178,16 @@ static void sctp_transport_destroy(struct sctp_transport *transport) > > SCTP_DBG_OBJCNT_DEC(transport); > > } > > > >+/* Destroy the transport data structure. > >+ * Assumes there are no more users of this structure. > >+ */ > >+static void sctp_transport_destroy(struct sctp_transport *transport) > >+{ > >+ SCTP_ASSERT(transport->dead, "Transport is not dead", return); > >+ > >+ call_rcu(&transport->rcu, sctp_transport_destroy_rcu); > >+} > >+ > > /* Start T3_rtx timer if it is not already running and update the heartbeat > > * timer. This routine is called every time a DATA chunk is sent. > > */ > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs 2012-12-06 19:25 [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs Thomas Graf 2012-12-06 19:25 ` [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() Thomas Graf 2012-12-06 19:25 ` [PATCH 2/2] sctp: Add RCU protection to assoc->transport_addr_list Thomas Graf @ 2012-12-07 19:15 ` David Miller 2 siblings, 0 replies; 8+ messages in thread From: David Miller @ 2012-12-07 19:15 UTC (permalink / raw) To: tgraf; +Cc: linux-sctp, netdev, vyasevich, nhorman From: Thomas Graf <tgraf@suug.ch> Date: Thu, 6 Dec 2012 20:25:03 +0100 > @Dave: This is a respin of the following patches: > [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() > [PATCH] sctp: Add RCU protection to assoc->transport_addr_list > > Thomas Graf (2): > sctp: proc: protect bind_addr->address_list accesses with > rcu_read_lock() > sctp: Add RCU protection to assoc->transport_addr_list Series applied, thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-12-07 19:16 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-12-06 19:25 [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs Thomas Graf 2012-12-06 19:25 ` [PATCH 1/2] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() Thomas Graf 2012-12-06 20:07 ` Vlad Yasevich 2012-12-06 21:12 ` Neil Horman 2012-12-06 19:25 ` [PATCH 2/2] sctp: Add RCU protection to assoc->transport_addr_list Thomas Graf 2012-12-06 20:07 ` Vlad Yasevich 2012-12-06 21:14 ` Neil Horman 2012-12-07 19:15 ` [PATCH 0/2 v2] sctp: RCU protection when accessing assoc members for procfs David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).