提交 5cb2cd68 编写于 作者: X Xin Long 提交者: David S. Miller

sctp: sctp_epaddr_lookup_transport should be protected by rcu_read_lock

Since commit 7fda702f ("sctp: use new rhlist interface on sctp transport
rhashtable"), sctp has changed to use rhlist_lookup to look up transport, but
rhlist_lookup doesn't call rcu_read_lock inside, unlike rhashtable_lookup_fast.

It is called in sctp_epaddr_lookup_transport and sctp_addrs_lookup_transport.
sctp_addrs_lookup_transport is always in the protection of rcu_read_lock(),
as __sctp_lookup_association is called in rx path or sctp_lookup_association
which are in the protection of rcu_read_lock() already.

But sctp_epaddr_lookup_transport is called by sctp_endpoint_lookup_assoc, it
doesn't call rcu_read_lock, which may cause "suspicious rcu_dereference_check
usage' in __rhashtable_lookup.

This patch is to fix it by adding rcu_read_lock in sctp_endpoint_lookup_assoc
before calling sctp_epaddr_lookup_transport.

Fixes: 7fda702f ("sctp: use new rhlist interface on sctp transport rhashtable")
Reported-by: NDmitry Vyukov <dvyukov@google.com>
Signed-off-by: NXin Long <lucien.xin@gmail.com>
Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 10a3ecf4
...@@ -331,7 +331,9 @@ struct sctp_association *sctp_endpoint_lookup_assoc( ...@@ -331,7 +331,9 @@ struct sctp_association *sctp_endpoint_lookup_assoc(
* on this endpoint. * on this endpoint.
*/ */
if (!ep->base.bind_addr.port) if (!ep->base.bind_addr.port)
goto out; return NULL;
rcu_read_lock();
t = sctp_epaddr_lookup_transport(ep, paddr); t = sctp_epaddr_lookup_transport(ep, paddr);
if (!t) if (!t)
goto out; goto out;
...@@ -339,6 +341,7 @@ struct sctp_association *sctp_endpoint_lookup_assoc( ...@@ -339,6 +341,7 @@ struct sctp_association *sctp_endpoint_lookup_assoc(
*transport = t; *transport = t;
asoc = t->asoc; asoc = t->asoc;
out: out:
rcu_read_unlock();
return asoc; return asoc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册