提交 daf4e2c8 编写于 作者: L Lennert Buytenhek 提交者: Marcel Holtmann

ieee802154: Fix EUI-64 station address validation.

Refuse to allow setting an EUI-64 group address as an interface
address, as those are not valid station addresses.
Signed-off-by: NLennert Buytenhek <buytenh@wantstofly.org>
Acked-by: NAlexander Aring <alex.aring@gmail.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 3b369bd2
...@@ -225,15 +225,13 @@ static inline bool ieee802154_is_valid_psdu_len(const u8 len) ...@@ -225,15 +225,13 @@ static inline bool ieee802154_is_valid_psdu_len(const u8 len)
* ieee802154_is_valid_psdu_len - check if extended addr is valid * ieee802154_is_valid_psdu_len - check if extended addr is valid
* @addr: extended addr to check * @addr: extended addr to check
*/ */
static inline bool ieee802154_is_valid_extended_addr(const __le64 addr) static inline bool ieee802154_is_valid_extended_unicast_addr(const __le64 addr)
{ {
/* These EUI-64 addresses are reserved by IEEE. 0xffffffffffffffff /* Bail out if the address is all zero, or if the group
* is used internally as extended to short address broadcast mapping. * address bit is set.
* This is currently a workaround because neighbor discovery can't
* deal with short addresses types right now.
*/ */
return ((addr != cpu_to_le64(0x0000000000000000ULL)) && return ((addr != cpu_to_le64(0x0000000000000000ULL)) &&
(addr != cpu_to_le64(0xffffffffffffffffULL))); !(addr & cpu_to_le64(0x0100000000000000ULL)));
} }
/** /**
......
...@@ -126,7 +126,7 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p) ...@@ -126,7 +126,7 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)
return -EBUSY; return -EBUSY;
ieee802154_be64_to_le64(&extended_addr, addr->sa_data); ieee802154_be64_to_le64(&extended_addr, addr->sa_data);
if (!ieee802154_is_valid_extended_addr(extended_addr)) if (!ieee802154_is_valid_extended_unicast_addr(extended_addr))
return -EINVAL; return -EINVAL;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
...@@ -539,7 +539,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name, ...@@ -539,7 +539,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
switch (type) { switch (type) {
case NL802154_IFTYPE_NODE: case NL802154_IFTYPE_NODE:
ndev->type = ARPHRD_IEEE802154; ndev->type = ARPHRD_IEEE802154;
if (ieee802154_is_valid_extended_addr(extended_addr)) if (ieee802154_is_valid_extended_unicast_addr(extended_addr))
ieee802154_le64_to_be64(ndev->dev_addr, &extended_addr); ieee802154_le64_to_be64(ndev->dev_addr, &extended_addr);
else else
memcpy(ndev->dev_addr, ndev->perm_addr, memcpy(ndev->dev_addr, ndev->perm_addr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册