Skip to content

Commit

Permalink
ipv4: ensure rcu_read_lock() in cipso_v4_error()
Browse files Browse the repository at this point in the history
commit 3e72dfd upstream.

Similarly to commit c543cb4 ("ipv4: ensure rcu_read_lock() in
ipv4_link_failure()"), __ip_options_compile() must be called under rcu
protection.

Fixes: 3da1ed7 ("net: avoid use IPCB in cipso_v4_error")
Suggested-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Matteo Croce authored and Greg Kroah-Hartman committed Mar 21, 2020
1 parent 6437ae4 commit b6b25ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/ipv4/cipso_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@ void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway)
{
unsigned char optbuf[sizeof(struct ip_options) + 40];
struct ip_options *opt = (struct ip_options *)optbuf;
int res;

if (ip_hdr(skb)->protocol == IPPROTO_ICMP || error != -EACCES)
return;
Expand All @@ -1735,7 +1736,11 @@ void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway)

memset(opt, 0, sizeof(struct ip_options));
opt->optlen = ip_hdr(skb)->ihl*4 - sizeof(struct iphdr);
if (__ip_options_compile(dev_net(skb->dev), opt, skb, NULL))
rcu_read_lock();
res = __ip_options_compile(dev_net(skb->dev), opt, skb, NULL);
rcu_read_unlock();

if (res)
return;

if (gateway)
Expand Down

0 comments on commit b6b25ba

Please sign in to comment.