netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock()
@ 2012-12-06 17:34 Thomas Graf
  2012-12-06 18:25 ` Vlad Yasevich
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Graf @ 2012-12-06 17:34 UTC (permalink / raw)
  To: linux-sctp; +Cc: netdev, Vlad Yasevich, Neil Horman

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.

Cc: Vlad Yasevich <vyasevich@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
 net/sctp/proc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 9966e7b..ec9b0c8 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -139,7 +139,8 @@ 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) {
 		addr = &laddr->a;
 		af = sctp_get_af_specific(addr->sa.sa_family);
 		if (primary && af->cmp_addr(addr, primary)) {
@@ -147,6 +148,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] 4+ messages in thread

* Re: [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock()
  2012-12-06 17:34 [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() Thomas Graf
@ 2012-12-06 18:25 ` Vlad Yasevich
  2012-12-06 18:28   ` Thomas Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Vlad Yasevich @ 2012-12-06 18:25 UTC (permalink / raw)
  To: Thomas Graf; +Cc: linux-sctp, netdev, Neil Horman

On 12/06/2012 12:34 PM, Thomas Graf wrote:
> 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.
>
> Cc: Vlad Yasevich <vyasevich@gmail.com>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> ---
>   net/sctp/proc.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/sctp/proc.c b/net/sctp/proc.c
> index 9966e7b..ec9b0c8 100644
> --- a/net/sctp/proc.c
> +++ b/net/sctp/proc.c
> @@ -139,7 +139,8 @@ 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) {
>   		addr = &laddr->a;
>   		af = sctp_get_af_specific(addr->sa.sa_family);
>   		if (primary && af->cmp_addr(addr, primary)) {
> @@ -147,6 +148,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. */
>

May want to avoid printing addresses that are !addr->valid.

Otherwise looks good.

-vlad

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock()
  2012-12-06 18:25 ` Vlad Yasevich
@ 2012-12-06 18:28   ` Thomas Graf
  2012-12-06 19:16     ` Neil Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Graf @ 2012-12-06 18:28 UTC (permalink / raw)
  To: Vlad Yasevich; +Cc: linux-sctp, netdev, Neil Horman

On 12/06/12 at 01:25pm, Vlad Yasevich wrote:
> May want to avoid printing addresses that are !addr->valid.
> 
> Otherwise looks good.

Good point, I'll send a follow-up patch if that is OK. Same
applies to dead transports obviously.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock()
  2012-12-06 18:28   ` Thomas Graf
@ 2012-12-06 19:16     ` Neil Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Horman @ 2012-12-06 19:16 UTC (permalink / raw)
  To: Thomas Graf; +Cc: Vlad Yasevich, linux-sctp, netdev

On Thu, Dec 06, 2012 at 06:28:40PM +0000, Thomas Graf wrote:
> On 12/06/12 at 01:25pm, Vlad Yasevich wrote:
> > May want to avoid printing addresses that are !addr->valid.
> > 
> > Otherwise looks good.
> 
> Good point, I'll send a follow-up patch if that is OK. Same
> applies to dead transports obviously.
Assuming a followup patch to avoid dead addresses..
Acked-by: Neil Horman <nhorman@tuxdriver.com>

> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-06 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-06 17:34 [PATCH] sctp: proc: protect bind_addr->address_list accesses with rcu_read_lock() Thomas Graf
2012-12-06 18:25 ` Vlad Yasevich
2012-12-06 18:28   ` Thomas Graf
2012-12-06 19:16     ` Neil Horman

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).