Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

PVF worker: random fixes #7649

Merged
merged 5 commits into from
Aug 21, 2023
Merged

Conversation

mrcnski
Copy link
Contributor

@mrcnski mrcnski commented Aug 21, 2023

  • Fixes possible panic due to non-UTF-8 env vars (see here)
  • In case of a key or value that would cause env::remove_var to panic, we first log a warning and then proceed to attempt to remove the env var.
  • Very small refactor of some duplicated code

I didn't address keeping PATH as it's not needed for the workers to function. @vstakhov is there any reason to keep it?

- Fixes possible panic due to non-UTF-8 env vars
  (#7330 (comment))
- Very small refactor of some duplicated code
@mrcnski mrcnski added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. labels Aug 21, 2023
@mrcnski mrcnski self-assigned this Aug 21, 2023
@vstakhov
Copy link
Contributor

didn't address keeping PATH as it's not needed for the workers to function. @vstakhov is there any reason to keep it?

If we don't use anything like execvp[e]/system then it is not needed I suppose.

// TODO: *theoretically* the value (or mere presence) of `RUST_LOG` can be a source of
// randomness for malicious code. In the future we can remove it also and log in the host;
// see <https://github.com/paritytech/polkadot/issues/7117>.
if key != "RUST_LOG" {
if key.to_str() != Some("RUST_LOG") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to_str here? As far as I see, we can directly compare OsStr and str, even if OsStr variable has some unsafe unicode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, looks like you're right.

@vstakhov
Copy link
Contributor

It seems that we need to filter = and \0 explicitly:

thread 'main' panicked at 'failed to remove environment variable `"fo=o"`: Invalid argument (os error 22)', library/std/src/env.rs:388:29
thread 'main' panicked at 'failed to remove environment variable `"fo\0o"`: file name contained an unexpected NUL byte', library/std/src/env.rs:388:29

In case of a key or value that would cause env::remove_var to panic, we first
log a warning and then proceed to attempt to remove the env var.
@mrcnski
Copy link
Contributor Author

mrcnski commented Aug 21, 2023

Thanks @vstakhov, pushed a commit. Got to use is_some_and for the first time, awesome. 👍

@mrcnski
Copy link
Contributor Author

mrcnski commented Aug 21, 2023

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot paritytech-processbot bot merged commit 0bbe0a7 into master Aug 21, 2023
3 checks passed
@paritytech-processbot paritytech-processbot bot deleted the mrcnski/pvf-worker-random-fixes branch August 21, 2023 17:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants