Skip to content

Commit 451dc48

Browse files
Alexander AringStefan-Schmidt
authored andcommitted
net: ieee802154: handle iftypes as u32
This patch fixes an issue that an u32 netlink value is handled as a signed enum value which doesn't fit into the range of u32 netlink type. If it's handled as -1 value some BIT() evaluation ends in a shift-out-of-bounds issue. To solve the issue we set the to u32 max which is s32 "-1" value to keep backwards compatibility and let the followed enum values start counting at 0. This brings the compiler to never handle the enum as signed and a check if the value is above NL802154_IFTYPE_MAX should filter -1 out. Fixes: f3ea5e4 ("ieee802154: add new interface command") Signed-off-by: Alexander Aring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]>
1 parent 848e5d6 commit 451dc48

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/net/nl802154.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*
2020
*/
2121

22+
#include <linux/types.h>
23+
2224
#define NL802154_GENL_NAME "nl802154"
2325

2426
enum nl802154_commands {
@@ -150,10 +152,9 @@ enum nl802154_attrs {
150152
};
151153

152154
enum nl802154_iftype {
153-
/* for backwards compatibility TODO */
154-
NL802154_IFTYPE_UNSPEC = -1,
155+
NL802154_IFTYPE_UNSPEC = (~(__u32)0),
155156

156-
NL802154_IFTYPE_NODE,
157+
NL802154_IFTYPE_NODE = 0,
157158
NL802154_IFTYPE_MONITOR,
158159
NL802154_IFTYPE_COORD,
159160

0 commit comments

Comments
 (0)