Skip to content

Commit 895fe07

Browse files
jmberg-intelniclimcy
authored andcommitted
ipv6: add option to drop unicast encapsulated in L2 multicast
In order to solve a problem with 802.11, the so-called hole-196 attack, add an option (sysctl) called "drop_unicast_in_l2_multicast" which, if enabled, causes the stack to drop IPv6 unicast packets encapsulated in link-layer multi- or broadcast frames. Such frames can (as an attack) be created by any member of the same wireless network and transmitted as valid encrypted frames since the symmetric key for broadcast frames is shared between all stations. Reviewed-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit dede82143bf1bbf92ea73a519bb0298b19c56cb9) Change-Id: I76c8f84b53e95c40ad3c2b5adac0ec4964cc920c Signed-off-by: Albert I <kras@raphielgang.org>
1 parent 0cc8b98 commit 895fe07

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

Documentation/networking/ip-sysctl.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,12 @@ mldv2_unsolicited_report_interval - INTEGER
14021402
MLDv2 report retransmit will take place.
14031403
Default: 1000 (1 second)
14041404

1405+
drop_unicast_in_l2_multicast - BOOLEAN
1406+
Drop any unicast IPv6 packets that are received in link-layer
1407+
multicast (or broadcast) frames.
1408+
1409+
By default this is turned off.
1410+
14051411
icmp/*:
14061412
ratelimit - INTEGER
14071413
Limit the maximal rates for sending ICMPv6 packets.

include/linux/ipv6.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct ipv6_devconf {
4949
__s32 mc_forwarding;
5050
#endif
5151
__s32 disable_ipv6;
52+
__s32 drop_unicast_in_l2_multicast;
5253
__s32 accept_dad;
5354
__s32 force_tllao;
5455
__s32 ndisc_notify;

net/ipv6/addrconf.c

+8
Original file line numberDiff line numberDiff line change
@@ -4399,6 +4399,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
43994399
array[DEVCONF_NDISC_NOTIFY] = cnf->ndisc_notify;
44004400
array[DEVCONF_ACCEPT_RA_MTU] = cnf->accept_ra_mtu;
44014401
array[DEVCONF_USE_OIF_ADDRS_ONLY] = cnf->use_oif_addrs_only;
4402+
array[DEVCONF_DROP_UNICAST_IN_L2_MULTICAST] = cnf->drop_unicast_in_l2_multicast;
44024403
}
44034404

44044405
static inline size_t inet6_ifla6_size(void)
@@ -5228,6 +5229,13 @@ static struct addrconf_sysctl_table
52285229
.proc_handler = proc_dointvec,
52295230

52305231
},
5232+
{
5233+
.procname = "drop_unicast_in_l2_multicast",
5234+
.data = &ipv6_devconf.drop_unicast_in_l2_multicast,
5235+
.maxlen = sizeof(int),
5236+
.mode = 0644,
5237+
.proc_handler = proc_dointvec,
5238+
},
52315239
{
52325240
/* sentinel */
52335241
}

net/ipv6/ip6_input.c

+10
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
130130
IPV6_ADDR_MC_SCOPE(&hdr->daddr) == 1)
131131
goto err;
132132

133+
/* If enabled, drop unicast packets that were encapsulated in link-layer
134+
* multicast or broadcast to protected against the so-called "hole-196"
135+
* attack in 802.11 wireless.
136+
*/
137+
if (!ipv6_addr_is_multicast(&hdr->daddr) &&
138+
(skb->pkt_type == PACKET_BROADCAST ||
139+
skb->pkt_type == PACKET_MULTICAST) &&
140+
idev->cnf.drop_unicast_in_l2_multicast)
141+
goto err;
142+
133143
/* RFC4291 2.7
134144
* Nodes must not originate a packet to a multicast address whose scope
135145
* field contains the reserved value 0; if such a packet is received, it

0 commit comments

Comments
 (0)