lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210811023654.2971-1-islituo@gmail.com>
Date:   Tue, 10 Aug 2021 19:36:54 -0700
From:   Tuo Li <islituo@...il.com>
To:     alex.aring@...il.com, stefan@...enfreihafen.org,
        davem@...emloft.net, kuba@...nel.org
Cc:     linux-wpan@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, baijiaju1990@...il.com,
        Tuo Li <islituo@...il.com>, TOTE Robot <oslab@...nghua.edu.cn>
Subject: [PATCH] ieee802154: hwsim: fix possible null-pointer dereference in mac802154_hwsim.c

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@...nghua.edu.cn>
Signed-off-by: Tuo Li <islituo@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ