提交 4844bacf 编写于 作者: A Alexander Aring 提交者: Zheng Zengkai

net: ieee802154: handle iftypes as u32

stable inclusion
from stable-v5.10.83
commit 8730a679c3cbfb65f1e65562473dec612a826407
bugzilla: 185879 https://gitee.com/openeuler/kernel/issues/I4QUVG

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8730a679c3cbfb65f1e65562473dec612a826407

--------------------------------

[ Upstream commit 451dc48c ]

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: f3ea5e44 ("ieee802154: add new interface command")
Signed-off-by: NAlexander Aring <aahringo@redhat.com>
Link: https://lore.kernel.org/r/20211112030916.685793-1-aahringo@redhat.comSigned-off-by: NStefan Schmidt <stefan@datenfreihafen.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 4d6dd9e6
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* *
*/ */
#include <linux/types.h>
#define NL802154_GENL_NAME "nl802154" #define NL802154_GENL_NAME "nl802154"
enum nl802154_commands { enum nl802154_commands {
...@@ -150,10 +152,9 @@ enum nl802154_attrs { ...@@ -150,10 +152,9 @@ enum nl802154_attrs {
}; };
enum nl802154_iftype { enum nl802154_iftype {
/* for backwards compatibility TODO */ NL802154_IFTYPE_UNSPEC = (~(__u32)0),
NL802154_IFTYPE_UNSPEC = -1,
NL802154_IFTYPE_NODE, NL802154_IFTYPE_NODE = 0,
NL802154_IFTYPE_MONITOR, NL802154_IFTYPE_MONITOR,
NL802154_IFTYPE_COORD, NL802154_IFTYPE_COORD,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册