Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialisation Fixes #61

Closed
wants to merge 7 commits into from
Closed

Conversation

danielbarry
Copy link

Some fixes around possible uninitialized variables that could lead to undesired behaviour. They are unlikely to be seen in the wild as they would mostly require misconfiguration.

I've tried to make sure they are initialized to sane defaults and throw a compiler error where that's not really possible (neither IPv4 or IPv6 set).

@danielbarry
Copy link
Author

I'm not entirely sure why there are extra commits in there... I forked from master, then branched, made changes and then am looking to merge? Not sure what I messed up?

@danielbarry danielbarry changed the title Initialisation FixesGeneral fixes Initialisation Fixes Nov 1, 2020
@gamelaster
Copy link
Member

Hello,
hmm, strange, but merging isn't problematic. I will recheck if it's OK

@Avamander
Copy link

I'm not entirely sure why there are extra commits in there... I forked from master, then branched, made changes and then am looking to merge? Not sure what I messed up?

@danielbarry Try fetching latest master and rebase your branch on top of it and then force push. Be attentive.

@danielbarry
Copy link
Author

@gamelaster @Avamander I think that's now done?

@Avamander
Copy link

Looks correct(er) now.

@Avamander
Copy link

Does MbedTLS have these changes upstream?

@danielbarry
Copy link
Author

@Avamander I hadn't checked... But:

  • ecjpake.c sets ret to MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED which would fix this bug [1]
  • ssl_cli.c doesn't zero hashlen, so it's possible to end up with some random hash length if the compiler doesn't zero out the memory (and the right precompiler conditions are met) [2]
  • ssl_cli.c doesn't zero n or i, it seems to use a different process at first glance [3]
  • ssl_tls.c doesn't NULL (and therefore check) mac_enc or mac_dec [4], meaning it's possible for the memcpy to point to some random location in memory [5]

[1] https://github.com/ARMmbed/mbedtls/blob/development/library/ecjpake.c#L108

[2] https://github.com/ARMmbed/mbedtls/blob/development/library/ssl_cli.c#L3257

[3] https://github.com/ARMmbed/mbedtls/blob/development/library/ssl_cli.c#L3674

[4] https://github.com/ARMmbed/mbedtls/blob/development/library/ssl_tls.c#L858

[5] https://github.com/ARMmbed/mbedtls/blob/development/library/ssl_tls.c#L1149

@Avamander
Copy link

It sounds to me like MbedTLS should just be updated, turned into a submodule. What do you think?

@danielbarry
Copy link
Author

@Avamander That sounds sensible, otherwise you're always going to miss out on upstream patches. Would probably make sense to point it at their latest release branch rather than the development branch :)

https://github.com/ARMmbed/mbedtls/tree/v2.24.0

@danielbarry
Copy link
Author

Perhaps it would make sense to fork your own version - that way you can apply patches over the top until the next release is ready?

@v3l0c1r4pt0r
Copy link

It sounds to me like MbedTLS should just be updated, turned into a submodule. What do you think?

@Avamander That's exactly what I thought about, when I've read your previous comment. Maybe as a first step, mbedtls should be turned into submodule at exactly same state of repo that was originally in SDK. This could be merged immediately. This would preserve history, so we will know, where we started.

Then another pull request could try updating the submodule to latest release.

@danielbarry
Copy link
Author

Good thinking, seems the commit version is here: https://github.com/bouffalolab/bl_iot_sdk/blob/ee4a10b1a1e3609243bd5e7b3a45f02d768f6c14/components/security/mbedtls/version

Do you want me to make a PR?

@danielbarry danielbarry mentioned this pull request Nov 2, 2020
@Avamander
Copy link

Maybe as a first step, mbedtls should be turned into submodule at exactly same state of repo that was originally in SDK.

Yes, one commit to delete the folder, one to set it to current repo equivalent.

@gamelaster
Copy link
Member

Closing in favor of #64

@gamelaster gamelaster closed this Nov 19, 2020
@danielbarry
Copy link
Author

@gamelaster I think there are still some points here, but I'll open a new PR for those. Apparently the PineCone will arrive at some time so I could even test it for real :)

@gamelaster
Copy link
Member

Okay, thank you @danielbarry 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants