diff mbox series

[2/2] net: ieee802154: fix null deref in parse key id

Message ID 20210423040214.15438-3-dan@dlrobertson.com (mailing list archive)
State Not Applicable
Headers show
Series net: ieee802154: fix logic errors | expand

Commit Message

Dan Robertson April 23, 2021, 4:02 a.m. UTC
Fix a logic error that could result in a null deref if the user does not
set the PAN ID but does set the address.

Signed-off-by: Dan Robertson <dan@dlrobertson.com>
---
 net/ieee802154/nl-mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Aring April 23, 2021, 1:28 p.m. UTC | #1
Hi,

On Fri, 23 Apr 2021 at 00:03, Dan Robertson <dan@dlrobertson.com> wrote:
>
> Fix a logic error that could result in a null deref if the user does not
> set the PAN ID but does set the address.

That should already be fixed by commit 6f7f657f2440 ("net: ieee802154:
nl-mac: fix check on panid").

Thanks.

- Alex
Dan Robertson April 23, 2021, 2:35 p.m. UTC | #2
On Fri, Apr 23, 2021 at 09:28:48AM -0400, Alexander Aring wrote:
> Hi,
> 
> On Fri, 23 Apr 2021 at 00:03, Dan Robertson <dan@dlrobertson.com> wrote:
> >
> > Fix a logic error that could result in a null deref if the user does not
> > set the PAN ID but does set the address.
> 
> That should already be fixed by commit 6f7f657f2440 ("net: ieee802154:
> nl-mac: fix check on panid").

Ah right. I didn't look hard enough for an existing patch :) Thanks!

 - Dan
Stefan Schmidt April 23, 2021, 2:59 p.m. UTC | #3
Hello.

On 23.04.21 16:35, Dan Robertson wrote:
> On Fri, Apr 23, 2021 at 09:28:48AM -0400, Alexander Aring wrote:
>> Hi,
>>
>> On Fri, 23 Apr 2021 at 00:03, Dan Robertson <dan@dlrobertson.com> wrote:
>>>
>>> Fix a logic error that could result in a null deref if the user does not
>>> set the PAN ID but does set the address.
>>
>> That should already be fixed by commit 6f7f657f2440 ("net: ieee802154:
>> nl-mac: fix check on panid").
> 
> Ah right. I didn't look hard enough for an existing patch :) Thanks!
> 
>   - Dan
> 

Dropped from my patchwork queue.

regards
Stefan Schmidt
diff mbox series

Patch

diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index 9c640d670ffe..66983c5d4d85 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -551,7 +551,7 @@  ieee802154_llsec_parse_key_id(struct genl_info *info,
 	desc->mode = nla_get_u8(info->attrs[IEEE802154_ATTR_LLSEC_KEY_MODE]);
 
 	if (desc->mode == IEEE802154_SCF_KEY_IMPLICIT) {
-		if (!info->attrs[IEEE802154_ATTR_PAN_ID] &&
+		if (!info->attrs[IEEE802154_ATTR_PAN_ID] ||
 		    !(info->attrs[IEEE802154_ATTR_SHORT_ADDR] ||
 		      info->attrs[IEEE802154_ATTR_HW_ADDR]))
 			return -EINVAL;