Skip to content
New issue

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

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

Already on GitHub? # to your account

catch additional panics #574

Merged
merged 2 commits into from
May 18, 2022
Merged

catch additional panics #574

merged 2 commits into from
May 18, 2022

Conversation

Stebalien
Copy link
Member

  1. Catch panics when decoding cbor from actors.
  2. Catch panics when verifying proofs, etc.

The only strictly necessary change is the window post one, as a panic there could make a proof indisputable. But there's no real issue with being careful and turning all of these panics into "illegal argument" errors as they're all well isolated.

Stebalien added 2 commits May 17, 2022 11:37
CBOR decoding is complex. While we catch panics at the "invoke" level
anyways, catching them lower may help us avoid unintended
side-effects (e.g., lock poisoning).
These tend to do lots of complex math/parsing. In most cases, a fatal
error would be "safe", but:

- It's definitely not safe for window post. A panic in window post
verification would prevent disputes.
- Catching panics and turning them into "illegal argument" errors is
relatively safe as these methods are "pure".
@Stebalien Stebalien requested a review from raulk May 17, 2022 16:12
};
use filecoin_proofs_api::update::verify_empty_sector_update_proof;
use filecoin_proofs_api::{self as proofs, post, seal, ProverId, PublicReplicaInfo, SectorId};
use filecoin_proofs_api::{self as proofs, ProverId, PublicReplicaInfo, SectorId};
Copy link
Member Author

Choose a reason for hiding this comment

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

I started qualifying these calls because distinguishing between "our functions" and "not our functions" was getting difficult.

@@ -990,3 +869,168 @@ fn verify_seal(vi: &SealVerifyInfo) -> Result<bool> {
// Worst case, _some_ node falls out of sync. Better than the network halting.
.context("failed to verify seal proof")
}

fn verify_post(verify_info: &WindowPoStVerifyInfo) -> Result<bool> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied from above.

.or_illegal_argument()
}

fn verify_aggregate_seals(aggregate: &AggregateSealVerifyProofAndInfos) -> Result<bool> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied from above.

.or_illegal_argument()
}

fn verify_replica_update(replica: &ReplicaUpdateInfo) -> Result<bool> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied from above.

.or_illegal_argument()
}

fn compute_unsealed_sector_cid(
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied from above.

Ok(v) => v,
Err(e) => {
log::error!("panic when decoding cbor from actor: {:?}", e);
Err(syscall_error!(IllegalArgument; "panic when decoding cbor from actor").into())
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest ErrorNumber::Serialization here, but read_cbor is only used for parsing syscall parameters, so ErrorNumber::IllegalArgument is probably a safe assumption to make.

@raulk raulk merged commit c4b01e2 into master May 18, 2022
@raulk raulk deleted the fix/catch-other-panics branch May 18, 2022 11:19
@raulk raulk mentioned this pull request May 18, 2022
48 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants