Skip to content

Commit

Permalink
[SIMD-0137]: Return SyscallError::InvalidAttribute on invalid curve…
Browse files Browse the repository at this point in the history
… or op id on curve25519 syscalls (#412)
  • Loading branch information
samkim-crypto authored Apr 29, 2024
1 parent f8067ea commit 5b3390b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 6 deletions.
57 changes: 51 additions & 6 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use {
feature_set::bpf_account_data_direct_mapping,
feature_set::FeatureSet,
feature_set::{
self, blake3_syscall_enabled, curve25519_syscall_enabled,
self, abort_on_invalid_curve, blake3_syscall_enabled, curve25519_syscall_enabled,
disable_deploy_of_alloc_free_syscall, disable_fees_sysvar,
enable_alt_bn128_compression_syscall, enable_alt_bn128_syscall,
enable_big_mod_exp_syscall, enable_partitioned_epoch_reward, enable_poseidon_syscall,
Expand Down Expand Up @@ -916,7 +916,16 @@ declare_builtin_function!(
Ok(1)
}
}
_ => Ok(1),
_ => {
if invoke_context
.feature_set
.is_active(&abort_on_invalid_curve::id())
{
Err(SyscallError::InvalidAttribute.into())
} else {
Ok(1)
}
}
}
}
);
Expand Down Expand Up @@ -1024,7 +1033,16 @@ declare_builtin_function!(
Ok(1)
}
}
_ => Ok(1),
_ => {
if invoke_context
.feature_set
.is_active(&abort_on_invalid_curve::id())
{
Err(SyscallError::InvalidAttribute.into())
} else {
Ok(1)
}
}
},

CURVE25519_RISTRETTO => match group_op {
Expand Down Expand Up @@ -1114,10 +1132,28 @@ declare_builtin_function!(
Ok(1)
}
}
_ => Ok(1),
_ => {
if invoke_context
.feature_set
.is_active(&abort_on_invalid_curve::id())
{
Err(SyscallError::InvalidAttribute.into())
} else {
Ok(1)
}
}
},

_ => Ok(1),
_ => {
if invoke_context
.feature_set
.is_active(&abort_on_invalid_curve::id())
{
Err(SyscallError::InvalidAttribute.into())
} else {
Ok(1)
}
}
}
}
);
Expand Down Expand Up @@ -1223,7 +1259,16 @@ declare_builtin_function!(
}
}

_ => Ok(1),
_ => {
if invoke_context
.feature_set
.is_active(&abort_on_invalid_curve::id())
{
Err(SyscallError::InvalidAttribute.into())
} else {
Ok(1)
}
}
}
}
);
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ pub mod reward_full_priority_fee {
solana_sdk::declare_id!("3opE3EzAKnUftUDURkzMgwpNgimBAypW1mNDYH4x4Zg7");
}

pub mod abort_on_invalid_curve {
solana_sdk::declare_id!("FuS3FPfJDKSNot99ECLXtp3rueq36hMNStJkPJwWodLh");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -991,6 +995,7 @@ lazy_static! {
(enable_tower_sync_ix::id(), "Enable tower sync vote instruction"),
(chained_merkle_conflict_duplicate_proofs::id(), "generate duplicate proofs for chained merkle root conflicts"),
(reward_full_priority_fee::id(), "Reward full priority fee to validators #34731"),
(abort_on_invalid_curve::id(), "Abort when elliptic curve syscalls invoked on invalid curve id SIMD-0137")
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down

0 comments on commit 5b3390b

Please sign in to comment.