Skip to content

Conversation

@practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Sep 17, 2018

Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...).

Background reading: memcpy (and friends) with NULL pointers

Steps to reproduce:

./configure --with-sanitizers=undefined && make check && ./test/functional/test_runner.py

@practicalswift
Copy link
Contributor Author

practicalswift commented Sep 17, 2018

Introduced in PR #11372 (119b0f8). Friendly ping @sipa – would you mind reviewing? :-)

@maflcko
Copy link
Member

maflcko commented Sep 17, 2018

Shouldn't memory_cleanse be more robust in handling zero-length data?

@practicalswift
Copy link
Contributor Author

@MarcoFalke Sure! Added a commit. Please re-review :-)

@promag
Copy link
Contributor

promag commented Sep 18, 2018

Shouldn't memory_cleanse be more robust in handling zero-length data?

@MarcoFalke the same for memset?

-0 ae17de5 because it changes memory_cleanse invariant.

IMO should avoid the call to memory_cleanse.

@practicalswift
Copy link
Contributor Author

@MarcoFalke I think @promag has a good point. Now reverted to the original version.

@practicalswift
Copy link
Contributor Author

@promag Thanks for reviewing. Now updated. Please re-review :-)

maflcko pushed a commit that referenced this pull request Nov 5, 2018
…defined behaviour sanitizer (UBSan)

9f49db7 Enable functional tests in UBSAN job. Enable -fsanitize=integer (part of UBSAN). Merge UBSAN Travis job with no depends. (practicalswift)

Pull request description:

  Run functional tests and benchmarks under the undefined behaviour sanitizer (UBSan).

  This will make Travis automatically detect issues such as:
  * #14242: Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`
  * #14239: Avoid dividing by zero (undefined behaviour) in `EstimateMedianVal` (policy)/`ConnectTip` (validation)/`CreateTransaction` (wallet)
  * #13546: wallet: Avoid potential use of uninitialized value `bnb_used` in `CWallet::CreateTransaction(...)`

  Addresses issue #14059.

Tree-SHA512: 285e1542b36c582516c47938ce8d999fd89ba6c867bc0976e7306e7c949b8b84ffbfa43dbc679dd97ae639b086092e7d799d8e1c903c66a37d529ce61d5c64b4
@maflcko
Copy link
Member

maflcko commented Nov 5, 2018

Could remove the suppression from the file in contrib?

@bitcoin bitcoin deleted a comment from DrahtBot Nov 5, 2018
@practicalswift
Copy link
Contributor Author

@MarcoFalke Good point! Added commit 1cab4bb7e09c9d68e104460b67e5804848cd3c2e which removes UBSan suppression.

Please re-review :-)

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 8, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #14239 (Avoid dividing by zero (undefined behaviour) in EstimateMedianVal (policy)/ConnectTip (validation)/CreateTransaction (wallet) by practicalswift)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@practicalswift
Copy link
Contributor Author

Rebased!

@practicalswift
Copy link
Contributor Author

@luke-jr @promag @MarcoFalke Would you mind re-reviewing? :-)

@practicalswift
Copy link
Contributor Author

@MarcoFalke Could this one get a release milestone? :-)

@maflcko maflcko added this to the 0.18.0 milestone Jan 15, 2019
@promag
Copy link
Contributor

promag commented Feb 7, 2019

Agree with @laanwj, also (nit) could squash.

utACK 524a876 otherwise.

…an invalid string is passed to DecodeSecret(...)
@practicalswift
Copy link
Contributor Author

@laanwj @promag Good points. Fixed and squashed. Please re-review :-)

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK d855e4c.

@laanwj laanwj merged commit d855e4c into bitcoin:master Feb 8, 2019
laanwj added a commit that referenced this pull request Feb 8, 2019
…tr, 0, 0)) if an invalid string is passed to DecodeSecret(...)

d855e4c Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...) (practicalswift)

Pull request description:

  Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`.

  Background reading: [memcpy (and friends) with NULL pointers](https://www.imperialviolet.org/2016/06/26/nonnull.html)

  Steps to reproduce:

  ```
  ./configure --with-sanitizers=undefined && make check && ./test/functional/test_runner.py
  ```

Tree-SHA512: b8325ced4f724d9c03065e0747af56b1f297a90d9fb09a24d46c3231a90dce3df6299f2c41f863b5cec18eaeded7b46ee4b93d9a52adc2541eb4c44d2c0965d9
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 13, 2019
…an invalid string is passed to DecodeSecret(...)

Summary:
Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`.

Backport of Bitcoin Core PR14242
bitcoin/bitcoin#14242

Test Plan:
```
make check
```

Reviewers: Fabien, #bitcoin_abc, deadalnix, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D4017
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jan 8, 2021
…t(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...)

d855e4c Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...) (practicalswift)

Pull request description:

  Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`.

  Background reading: [memcpy (and friends) with NULL pointers](https://www.imperialviolet.org/2016/06/26/nonnull.html)

  Steps to reproduce:

  ```
  ./configure --with-sanitizers=undefined && make check && ./test/functional/test_runner.py
  ```

Tree-SHA512: b8325ced4f724d9c03065e0747af56b1f297a90d9fb09a24d46c3231a90dce3df6299f2c41f863b5cec18eaeded7b46ee4b93d9a52adc2541eb4c44d2c0965d9
@practicalswift practicalswift deleted the ub-in-DecodeSecret branch April 10, 2021 19:37
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 16, 2021
… the undefined behaviour sanitizer (UBSan)

9f49db7 Enable functional tests in UBSAN job. Enable -fsanitize=integer (part of UBSAN). Merge UBSAN Travis job with no depends. (practicalswift)

Pull request description:

  Run functional tests and benchmarks under the undefined behaviour sanitizer (UBSan).

  This will make Travis automatically detect issues such as:
  * bitcoin#14242: Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`
  * bitcoin#14239: Avoid dividing by zero (undefined behaviour) in `EstimateMedianVal` (policy)/`ConnectTip` (validation)/`CreateTransaction` (wallet)
  * bitcoin#13546: wallet: Avoid potential use of uninitialized value `bnb_used` in `CWallet::CreateTransaction(...)`

  Addresses issue bitcoin#14059.

Tree-SHA512: 285e1542b36c582516c47938ce8d999fd89ba6c867bc0976e7306e7c949b8b84ffbfa43dbc679dd97ae639b086092e7d799d8e1c903c66a37d529ce61d5c64b4
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 18, 2021
… the undefined behaviour sanitizer (UBSan)

9f49db7 Enable functional tests in UBSAN job. Enable -fsanitize=integer (part of UBSAN). Merge UBSAN Travis job with no depends. (practicalswift)

Pull request description:

  Run functional tests and benchmarks under the undefined behaviour sanitizer (UBSan).

  This will make Travis automatically detect issues such as:
  * bitcoin#14242: Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`
  * bitcoin#14239: Avoid dividing by zero (undefined behaviour) in `EstimateMedianVal` (policy)/`ConnectTip` (validation)/`CreateTransaction` (wallet)
  * bitcoin#13546: wallet: Avoid potential use of uninitialized value `bnb_used` in `CWallet::CreateTransaction(...)`

  Addresses issue bitcoin#14059.

Tree-SHA512: 285e1542b36c582516c47938ce8d999fd89ba6c867bc0976e7306e7c949b8b84ffbfa43dbc679dd97ae639b086092e7d799d8e1c903c66a37d529ce61d5c64b4

continued 14252

Co-authored-by: UdjinM6 <[email protected]>
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Aug 19, 2021
…t(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...)

d855e4c Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...) (practicalswift)

Pull request description:

  Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`.

  Background reading: [memcpy (and friends) with NULL pointers](https://www.imperialviolet.org/2016/06/26/nonnull.html)

  Steps to reproduce:

  ```
  ./configure --with-sanitizers=undefined && make check && ./test/functional/test_runner.py
  ```

Tree-SHA512: b8325ced4f724d9c03065e0747af56b1f297a90d9fb09a24d46c3231a90dce3df6299f2c41f863b5cec18eaeded7b46ee4b93d9a52adc2541eb4c44d2c0965d9
PastaPastaPasta added a commit to dashpay/dash that referenced this pull request Aug 21, 2021
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Apr 1, 2022
…t(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...)

d855e4c Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...) (practicalswift)

Pull request description:

  Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`.

  Background reading: [memcpy (and friends) with NULL pointers](https://www.imperialviolet.org/2016/06/26/nonnull.html)

  Steps to reproduce:

  ```
  ./configure --with-sanitizers=undefined && make check && ./test/functional/test_runner.py
  ```

Tree-SHA512: b8325ced4f724d9c03065e0747af56b1f297a90d9fb09a24d46c3231a90dce3df6299f2c41f863b5cec18eaeded7b46ee4b93d9a52adc2541eb4c44d2c0965d9
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Apr 20, 2022
… the undefined behaviour sanitizer (UBSan)

9f49db7 Enable functional tests in UBSAN job. Enable -fsanitize=integer (part of UBSAN). Merge UBSAN Travis job with no depends. (practicalswift)

Pull request description:

  Run functional tests and benchmarks under the undefined behaviour sanitizer (UBSan).

  This will make Travis automatically detect issues such as:
  * bitcoin#14242: Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`
  * bitcoin#14239: Avoid dividing by zero (undefined behaviour) in `EstimateMedianVal` (policy)/`ConnectTip` (validation)/`CreateTransaction` (wallet)
  * bitcoin#13546: wallet: Avoid potential use of uninitialized value `bnb_used` in `CWallet::CreateTransaction(...)`

  Addresses issue bitcoin#14059.

Tree-SHA512: 285e1542b36c582516c47938ce8d999fd89ba6c867bc0976e7306e7c949b8b84ffbfa43dbc679dd97ae639b086092e7d799d8e1c903c66a37d529ce61d5c64b4

continued 14252

Co-authored-by: UdjinM6 <[email protected]>
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants