Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv4: ensure rcu_read_lock() in cipso_v4_error()

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

Fixes: 3da1ed7ac398 ("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>

authored by

Matteo Croce and committed by
David S. Miller
3e72dfdf 42d84c84

+6 -1
+6 -1
net/ipv4/cipso_ipv4.c
··· 1724 1724 { 1725 1725 unsigned char optbuf[sizeof(struct ip_options) + 40]; 1726 1726 struct ip_options *opt = (struct ip_options *)optbuf; 1727 + int res; 1727 1728 1728 1729 if (ip_hdr(skb)->protocol == IPPROTO_ICMP || error != -EACCES) 1729 1730 return; ··· 1736 1735 1737 1736 memset(opt, 0, sizeof(struct ip_options)); 1738 1737 opt->optlen = ip_hdr(skb)->ihl*4 - sizeof(struct iphdr); 1739 - if (__ip_options_compile(dev_net(skb->dev), opt, skb, NULL)) 1738 + rcu_read_lock(); 1739 + res = __ip_options_compile(dev_net(skb->dev), opt, skb, NULL); 1740 + rcu_read_unlock(); 1741 + 1742 + if (res) 1740 1743 return; 1741 1744 1742 1745 if (gateway)