diff options
author | Stephen Suryaputra <ssuryaextr@gmail.com> | 2019-03-20 10:29:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-03-20 19:29:37 -0400 |
commit | 0b03a5ca8b14321366eec4a903922d2b46d585ff (patch) | |
tree | dd57f1bdfad2cdd949bde6d02fafa392fd374001 /net/ipv6/icmp.c | |
parent | a534ea30e70fc51c4cef31c0683955dd8a568a11 (diff) |
ipv6: Add icmp_echo_ignore_anycast for ICMPv6
In addition to icmp_echo_ignore_multicast, there is a need to also
prevent responding to pings to anycast addresses for security.
Signed-off-by: Stephen Suryaputra <ssuryaextr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/icmp.c')
-rw-r--r-- | net/ipv6/icmp.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 0907bcede5e5..cc14b9998941 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -683,6 +683,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
683 | struct dst_entry *dst; | 683 | struct dst_entry *dst; |
684 | struct ipcm6_cookie ipc6; | 684 | struct ipcm6_cookie ipc6; |
685 | u32 mark = IP6_REPLY_MARK(net, skb->mark); | 685 | u32 mark = IP6_REPLY_MARK(net, skb->mark); |
686 | bool acast; | ||
686 | 687 | ||
687 | if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) && | 688 | if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) && |
688 | net->ipv6.sysctl.icmpv6_echo_ignore_multicast) | 689 | net->ipv6.sysctl.icmpv6_echo_ignore_multicast) |
@@ -690,9 +691,12 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
690 | 691 | ||
691 | saddr = &ipv6_hdr(skb)->daddr; | 692 | saddr = &ipv6_hdr(skb)->daddr; |
692 | 693 | ||
694 | acast = ipv6_anycast_destination(skb_dst(skb), saddr); | ||
695 | if (acast && net->ipv6.sysctl.icmpv6_echo_ignore_anycast) | ||
696 | return; | ||
697 | |||
693 | if (!ipv6_unicast_destination(skb) && | 698 | if (!ipv6_unicast_destination(skb) && |
694 | !(net->ipv6.sysctl.anycast_src_echo_reply && | 699 | !(net->ipv6.sysctl.anycast_src_echo_reply && acast)) |
695 | ipv6_anycast_destination(skb_dst(skb), saddr))) | ||
696 | saddr = NULL; | 700 | saddr = NULL; |
697 | 701 | ||
698 | memcpy(&tmp_hdr, icmph, sizeof(tmp_hdr)); | 702 | memcpy(&tmp_hdr, icmph, sizeof(tmp_hdr)); |
@@ -1126,6 +1130,13 @@ static struct ctl_table ipv6_icmp_table_template[] = { | |||
1126 | .mode = 0644, | 1130 | .mode = 0644, |
1127 | .proc_handler = proc_dointvec, | 1131 | .proc_handler = proc_dointvec, |
1128 | }, | 1132 | }, |
1133 | { | ||
1134 | .procname = "echo_ignore_anycast", | ||
1135 | .data = &init_net.ipv6.sysctl.icmpv6_echo_ignore_anycast, | ||
1136 | .maxlen = sizeof(int), | ||
1137 | .mode = 0644, | ||
1138 | .proc_handler = proc_dointvec, | ||
1139 | }, | ||
1129 | { }, | 1140 | { }, |
1130 | }; | 1141 | }; |
1131 | 1142 | ||
@@ -1141,6 +1152,7 @@ struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net) | |||
1141 | table[0].data = &net->ipv6.sysctl.icmpv6_time; | 1152 | table[0].data = &net->ipv6.sysctl.icmpv6_time; |
1142 | table[1].data = &net->ipv6.sysctl.icmpv6_echo_ignore_all; | 1153 | table[1].data = &net->ipv6.sysctl.icmpv6_echo_ignore_all; |
1143 | table[2].data = &net->ipv6.sysctl.icmpv6_echo_ignore_multicast; | 1154 | table[2].data = &net->ipv6.sysctl.icmpv6_echo_ignore_multicast; |
1155 | table[3].data = &net->ipv6.sysctl.icmpv6_echo_ignore_anycast; | ||
1144 | } | 1156 | } |
1145 | return table; | 1157 | return table; |
1146 | } | 1158 | } |