diff options
author | Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> | 2015-06-12 10:16:41 -0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-06-14 12:55:49 -0700 |
commit | 2d45a02d0166caf2627fe91897c6ffc3b19514c4 (patch) | |
tree | 89469e59272cf6fd8efd2878801a1e2c2d8f5fe6 /include/net/netns | |
parent | c8d17b451aa18b07b60e771addf17a5fdd4138c7 (diff) | |
download | op-kernel-dev-2d45a02d0166caf2627fe91897c6ffc3b19514c4.zip op-kernel-dev-2d45a02d0166caf2627fe91897c6ffc3b19514c4.tar.gz |
sctp: fix ASCONF list handling
->auto_asconf_splist is per namespace and mangled by functions like
sctp_setsockopt_auto_asconf() which doesn't guarantee any serialization.
Also, the call to inet_sk_copy_descendant() was backuping
->auto_asconf_list through the copy but was not honoring
->do_auto_asconf, which could lead to list corruption if it was
different between both sockets.
This commit thus fixes the list handling by using ->addr_wq_lock
spinlock to protect the list. A special handling is done upon socket
creation and destruction for that. Error handlig on sctp_init_sock()
will never return an error after having initialized asconf, so
sctp_destroy_sock() can be called without addrq_wq_lock. The lock now
will be take on sctp_close_sock(), before locking the socket, so we
don't do it in inverse order compared to sctp_addr_wq_timeout_handler().
Instead of taking the lock on sctp_sock_migrate() for copying and
restoring the list values, it's preferred to avoid rewritting it by
implementing sctp_copy_descendant().
Issue was found with a test application that kept flipping sysctl
default_auto_asconf on and off, but one could trigger it by issuing
simultaneous setsockopt() calls on multiple sockets or by
creating/destroying sockets fast enough. This is only triggerable
locally.
Fixes: 9f7d653b67ae ("sctp: Add Auto-ASCONF support (core).")
Reported-by: Ji Jianwen <jiji@redhat.com>
Suggested-by: Neil Horman <nhorman@tuxdriver.com>
Suggested-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/netns')
-rw-r--r-- | include/net/netns/sctp.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h index 3573a81..8ba379f 100644 --- a/include/net/netns/sctp.h +++ b/include/net/netns/sctp.h @@ -31,6 +31,7 @@ struct netns_sctp { struct list_head addr_waitq; struct timer_list addr_wq_timer; struct list_head auto_asconf_splist; + /* Lock that protects both addr_waitq and auto_asconf_splist */ spinlock_t addr_wq_lock; /* Lock that protects the local_addr_list writers */ |