From: Eric Dumazet <eric.dumazet@gmail.com>
To: Networking <netdev@vger.kernel.org>
Cc: David Ahern <dsahern@gmail.com>, Florian Westphal <fw@strlen.de>
Subject: [RFC] ifa_list needs proper rcu protection
Date: Thu, 25 Apr 2019 15:50:53 -0700 [thread overview]
Message-ID: <7bdc26e6-ce41-02ba-baef-3e4e908f6dd7@gmail.com> (raw)
It looks that unless RTNL is held, accessing ifa_list needs proper RCU protection ?
indev->ifa_list can be changed under us by another cpu (which owns RTNL)
Lets took an example.
(A proper rcu_dereference() with an happy sparse support would require adding __rcu attribute,
I put a READ_ONCE() which should be just fine in this particular context)
diff --git a/net/netfilter/nf_nat_redirect.c b/net/netfilter/nf_nat_redirect.c
index 78a9e6454ff3d712926397beb904b478b8fab0f1..8619b8d02b0530c5735c31d029f1d79969d979c7 100644
--- a/net/netfilter/nf_nat_redirect.c
+++ b/net/netfilter/nf_nat_redirect.c
@@ -48,14 +48,17 @@ nf_nat_redirect_ipv4(struct sk_buff *skb,
newdst = htonl(0x7F000001);
} else {
struct in_device *indev;
- struct in_ifaddr *ifa;
newdst = 0;
indev = __in_dev_get_rcu(skb->dev);
- if (indev && indev->ifa_list) {
- ifa = indev->ifa_list;
- newdst = ifa->ifa_local;
+ if (indev) {
+ struct in_ifaddr *ifa;
+
+ ifa = READ_ONCE(indev->ifa_list); // rcu_dereference(xxx)
+
+ if (ifa)
+ newdst = ifa->ifa_local;
}
if (!newdst)
next reply other threads:[~2019-04-25 22:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-25 22:50 Eric Dumazet [this message]
2019-05-04 18:01 ` [RFC] ifa_list needs proper rcu protection Florian Westphal
2019-05-04 18:06 ` Eric Dumazet
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=7bdc26e6-ce41-02ba-baef-3e4e908f6dd7@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=dsahern@gmail.com \
--cc=fw@strlen.de \
--cc=netdev@vger.kernel.org \
/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