net: fix shift-out-of-bounds in nl802154_new_interface
Subsystems (3)
PATCH 1/1 net: fix shift-out-of-bounds in nl802154_new_interface
syzbot reported shift-out-of-bounds in nl802154_new_interface. The problem was in signed representation of enum nl802154_iftype
enum nl802154_iftype {
/* for backwards compatibility TODO */
NL802154_IFTYPE_UNSPEC = -1,...
Since, enum has negative value in it, objects of this type will be represented as signed integer.
type = nla_get_u32(info->attrs[NL802154_ATTR_IFTYPE]);
u32 will be casted to signed, which can cause negative value type.
--- net/ieee802154/nl802154.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ieee802154/nl802154.c +1 -1
@@ -910,7 +910,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)if (info->attrs[NL802154_ATTR_IFTYPE ]) { type =nla_get_u32 (info->attrs[NL802154_ATTR_IFTYPE ]); -if (type >NL802154_IFTYPE_MAX || +if (type >NL802154_IFTYPE_MAX || type <0 || !(rdev->wpan_phy.supported.iftypes &BIT (type)))return -EINVAL ; }
Signature · 1 line
2.30.2
Alexander Aring
maintainerHi,
Quoted 12 lines · Pavel Skripkin
syzbot reported shift-out-of-bounds in
nl802154_new_interface. The problem was in signed representation of enumnl802154_iftypeenum nl802154_iftype { /* for backwards compatibility TODO */ NL802154_IFTYPE_UNSPEC = -1,...
Since, enum has negative value in it, objects of this type will be represented as signed integer.
Quoted 6 lines
type = nla_get_u32(info->attrs[NL802154_ATTR_IFTYPE]);u32 will be casted to signed, which can cause negative value type.
Reported-by [email protected]Signed-off-by Pavel Skripkin <[email protected]>
Yes, this patch will fix the issue but we discussed that the problem is deeper than such a fix. The real problem is that we are using a -1 value which doesn't fit into the u32 netlink value and it gets converted back and forward which we should avoid.
- Alex
Quoted 20 lines · Alexander Aring
Hi,
Quoted 16 lines · Pavel Skripkin
syzbot reported shift-out-of-bounds in
nl802154_new_interface. The problem was in signed representation of enumnl802154_iftypeenum
nl802154_iftype{
/* for backwards compatibility TODO */
NL802154_IFTYPE_UNSPEC= -1,
...Since, enum has negative value in it, objects of this type will be represented as signed integer.
type =
nla_get_u32(info->attrs[NL802154_ATTR_IFTYPE]);u32 will be casted to signed, which can cause negative value type.
Quoted 8 lines
Quoted 2 lines
Reported-by [email protected]Signed-off-by Pavel Skripkin <[email protected]>Yes, this patch will fix the issue but we discussed that the problem is deeper than such a fix. The real problem is that we are using a -1 value which doesn't fit into the u32 netlink value and it gets converted back and forward which we should avoid.
OK, thanks for feedback!
Quoted 2 lines
- Alex
With regards,
Pavel Skripkin