Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dbd7937 authored by Eric Dumazet's avatar Eric Dumazet Committed by Greg Kroah-Hartman
Browse files

sctp: read sk->sk_bound_dev_if once in sctp_rcv()



[ Upstream commit a20ea298071f46effa3aaf965bf9bb34c901db3f ]

sctp_rcv() reads sk->sk_bound_dev_if twice while the socket
is not locked. Another cpu could change this field under us.

Fixes: 0fd9a65a ("[SCTP] Support SO_BINDTODEVICE socket option on incoming packets.")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 21abe8b6
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -104,6 +104,7 @@ int sctp_rcv(struct sk_buff *skb)
	struct sctp_chunk *chunk;
	struct sctp_chunk *chunk;
	union sctp_addr src;
	union sctp_addr src;
	union sctp_addr dest;
	union sctp_addr dest;
	int bound_dev_if;
	int family;
	int family;
	struct sctp_af *af;
	struct sctp_af *af;
	struct net *net = dev_net(skb->dev);
	struct net *net = dev_net(skb->dev);
@@ -181,7 +182,8 @@ int sctp_rcv(struct sk_buff *skb)
	 * If a frame arrives on an interface and the receiving socket is
	 * If a frame arrives on an interface and the receiving socket is
	 * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB
	 * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB
	 */
	 */
	if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb))) {
	bound_dev_if = READ_ONCE(sk->sk_bound_dev_if);
	if (bound_dev_if && (bound_dev_if != af->skb_iif(skb))) {
		if (transport) {
		if (transport) {
			sctp_transport_put(transport);
			sctp_transport_put(transport);
			asoc = NULL;
			asoc = NULL;