From: Eric Dumazet <eric.dumazet@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev <netdev@vger.kernel.org>,
Eric Dumazet <edumazet@google.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
Vlad Yasevich <vyasevich@gmail.com>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Subject: [PATCH v2 net-next 02/10] sctp: read sk->sk_bound_dev_if once in sctp_rcv()
Date: Fri, 13 May 2022 11:55:42 -0700 [thread overview]
Message-ID: <20220513185550.844558-3-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20220513185550.844558-1-eric.dumazet@gmail.com>
From: Eric Dumazet <edumazet@google.com>
sctp_rcv() reads sk->sk_bound_dev_if twice while the socket
is not locked. Another cpu could change this field under us.
Fixes: 0fd9a65a76e8 ("[SCTP] Support SO_BINDTODEVICE socket option on incoming packets.")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
net/sctp/input.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 90e12bafdd4894624b3a63d625ed21c85b60a4f0..4f43afa8678f9febf2f02c2ce1a840ce3ab6a07d 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -92,6 +92,7 @@ int sctp_rcv(struct sk_buff *skb)
struct sctp_chunk *chunk;
union sctp_addr src;
union sctp_addr dest;
+ int bound_dev_if;
int family;
struct sctp_af *af;
struct net *net = dev_net(skb->dev);
@@ -169,7 +170,8 @@ int sctp_rcv(struct sk_buff *skb)
* If a frame arrives on an interface and the receiving socket is
* 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) {
sctp_transport_put(transport);
asoc = NULL;
--
2.36.0.550.gb090851708-goog
next prev parent reply other threads:[~2022-05-13 18:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 18:55 [PATCH v2 net-next 00/10] Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 01/10] net: annotate races around sk->sk_bound_dev_if Eric Dumazet
2022-05-13 18:55 ` Eric Dumazet [this message]
2022-05-13 19:46 ` [PATCH v2 net-next 02/10] sctp: read sk->sk_bound_dev_if once in sctp_rcv() Marcelo Ricardo Leitner
2022-05-13 18:55 ` [PATCH v2 net-next 03/10] tcp: sk->sk_bound_dev_if once in inet_request_bound_dev_if() Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 04/10] net: core: add READ_ONCE/WRITE_ONCE annotations for sk->sk_bound_dev_if Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 05/10] dccp: use READ_ONCE() to read sk->sk_bound_dev_if Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 06/10] inet: add READ_ONCE(sk->sk_bound_dev_if) in inet_csk_bind_conflict() Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 07/10] net_sched: em_meta: add READ_ONCE() in var_sk_bound_if() Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 08/10] l2tp: use add READ_ONCE() to fetch sk->sk_bound_dev_if Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 09/10] ipv6: add READ_ONCE(sk->sk_bound_dev_if) in INET6_MATCH() Eric Dumazet
2022-05-13 18:55 ` [PATCH v2 net-next 10/10] inet: rename INET_MATCH() Eric Dumazet
2022-05-16 9:40 ` [PATCH v2 net-next 00/10] patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220513185550.844558-3-eric.dumazet@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=pabeni@redhat.com \
--cc=vyasevich@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).