Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] ieee802154: hwsim: fix possible null-pointer dereference in mac802154_hwsim.c
@ 2021-08-11 2:36 Tuo Li
2021-08-11 20:08 ` Stefan Schmidt
0 siblings, 1 reply; 2+ messages in thread
From: Tuo Li @ 2021-08-11 2:36 UTC (permalink / raw)
To: alex.aring, stefan, davem, kuba
Cc: linux-wpan, netdev, linux-kernel, baijiaju1990, Tuo Li, TOTE Robot
In hwsim_new_edge_nl() and hwsim_set_edge_lqi(), if only one of the two
info->attrs is NULL, the functions will not return.
if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] &&
!info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])
return -EINVAL;
However, both of them may be dereferenced in the function
nla_parse_nested_deprecated(), causing a null-pointer dereference.
To fix this possible null-pointer dereference, the function returns
-EINVAL if any info_attr is NULL.
Similarly, in hwsim_set_edge_lqi(), if only one of the two edge_attrs is
NULL, both nla_get_u32() and nla_get_u8() will be called, causing a
null-pointer dereference.
Also, to fix this possible null-pointer dereference, the function returns
-EINVAL if any edge_attr is NULL.
Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
---
drivers/net/ieee802154/mac802154_hwsim.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index ebc976b7fcc2..8caa61ec718f 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -418,7 +418,7 @@ static int hwsim_new_edge_nl(struct sk_buff *msg, struct genl_info *info)
struct hwsim_edge *e;
u32 v0, v1;
- if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] &&
+ if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] ||
!info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])
return -EINVAL;
@@ -528,14 +528,14 @@ static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info)
u32 v0, v1;
u8 lqi;
- if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] &&
+ if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] ||
!info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])
return -EINVAL;
if (nla_parse_nested_deprecated(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX, info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE], hwsim_edge_policy, NULL))
return -EINVAL;
- if (!edge_attrs[MAC802154_HWSIM_EDGE_ATTR_ENDPOINT_ID] &&
+ if (!edge_attrs[MAC802154_HWSIM_EDGE_ATTR_ENDPOINT_ID] ||
!edge_attrs[MAC802154_HWSIM_EDGE_ATTR_LQI])
return -EINVAL;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ieee802154: hwsim: fix possible null-pointer dereference in mac802154_hwsim.c
2021-08-11 2:36 [PATCH] ieee802154: hwsim: fix possible null-pointer dereference in mac802154_hwsim.c Tuo Li
@ 2021-08-11 20:08 ` Stefan Schmidt
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Schmidt @ 2021-08-11 20:08 UTC (permalink / raw)
To: Tuo Li, alex.aring, davem, kuba
Cc: linux-wpan, netdev, linux-kernel, baijiaju1990, TOTE Robot
Hello.
On 11.08.21 04:36, Tuo Li wrote:
> In hwsim_new_edge_nl() and hwsim_set_edge_lqi(), if only one of the two
> info->attrs is NULL, the functions will not return.
> if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] &&
> !info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])
> return -EINVAL;
>
> However, both of them may be dereferenced in the function
> nla_parse_nested_deprecated(), causing a null-pointer dereference.
> To fix this possible null-pointer dereference, the function returns
> -EINVAL if any info_attr is NULL.
>
> Similarly, in hwsim_set_edge_lqi(), if only one of the two edge_attrs is
> NULL, both nla_get_u32() and nla_get_u8() will be called, causing a
> null-pointer dereference.
> Also, to fix this possible null-pointer dereference, the function returns
> -EINVAL if any edge_attr is NULL.
>
> Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Tuo Li <islituo@gmail.com>
Thanks for your patch. This has already been fixed with patches in the
wpan tree.
https://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan.git/
I just sent a pull request including them to get pulled into net.
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-11 20:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 2:36 [PATCH] ieee802154: hwsim: fix possible null-pointer dereference in mac802154_hwsim.c Tuo Li
2021-08-11 20:08 ` Stefan Schmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).