From: Matteo Croce <mcroce@redhat.com>
To: netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Stephen Suryaputra <ssuryaextr@gmail.com>
Subject: [PATCH nf] netfilter: ensure rcu_read_lock() in ipv4_find_option()
Date: Mon, 24 Feb 2020 19:55:29 +0100 [thread overview]
Message-ID: <20200224185529.50530-1-mcroce@redhat.com> (raw)
As in commit c543cb4a5f07 ("ipv4: ensure rcu_read_lock() in ipv4_link_failure()")
and commit 3e72dfdf8227 ("ipv4: ensure rcu_read_lock() in cipso_v4_error()"),
__ip_options_compile() must be called under rcu protection.
Fixes: dbb5281a1f84 ("netfilter: nf_tables: add support for matching IPv4 options")
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
net/netfilter/nft_exthdr.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index a5e8469859e3..752264b3043a 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -77,6 +77,7 @@ static int ipv4_find_option(struct net *net, struct sk_buff *skb,
bool found = false;
__be32 info;
int optlen;
+ int ret;
iph = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
if (!iph)
@@ -95,7 +96,11 @@ static int ipv4_find_option(struct net *net, struct sk_buff *skb,
return -EBADMSG;
opt->optlen = optlen;
- if (__ip_options_compile(net, opt, NULL, &info))
+ rcu_read_lock();
+ ret = __ip_options_compile(net, opt, NULL, &info);
+ rcu_read_unlock();
+
+ if (ret)
return -EBADMSG;
switch (target) {
--
2.24.1
next reply other threads:[~2020-02-24 18:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 18:55 Matteo Croce [this message]
2020-02-24 19:11 ` [PATCH nf] netfilter: ensure rcu_read_lock() in ipv4_find_option() Florian Westphal
2020-02-24 19:42 ` Matteo Croce
2020-02-24 19:47 ` Matteo Croce
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=20200224185529.50530-1-mcroce@redhat.com \
--to=mcroce@redhat.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=ssuryaextr@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).