forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Dev utils tokyo 5 dm perms #13
Open
ryoqun
wants to merge
186
commits into
dm-cpi-memory-perm
Choose a base branch
from
dev-utils-tokyo-5-dm-perms
base: dm-cpi-memory-perm
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ryoqun
commented
Aug 1, 2023
Comment on lines
869
to
922
let rc_box_addr = | ||
target_account.data.borrow_mut().as_mut_ptr() as *mut RcBox<RefCell<&mut [u8]>>; | ||
let rc_box_size = mem::size_of::<RcBox<RefCell<&mut [u8]>>>(); | ||
account.data.borrow_mut().as_mut_ptr() as *mut RcBox<RefCell<&mut [u8]>>; | ||
let rc_box = RcBox { | ||
strong: 1, | ||
weak: 0, | ||
// The difference with | ||
// TEST_FORBID_LEN_UPDATE_AFTER_OWNERSHIP_CHANGE_MOVING_DATA_POINTER | ||
// is that we don't move the data pointer past the | ||
// RcBox. This is needed to avoid the "Invalid account | ||
// info pointer" check when direct mapping is enabled. | ||
// This also means we don't need to update the | ||
// serialized len like we do in the other test. | ||
value: unsafe { RefCell::new(slice::from_raw_parts_mut( | ||
target_account.data.borrow_mut().as_mut_ptr(), | ||
target_len, | ||
)) }, | ||
}; | ||
unsafe { | ||
std::ptr::write( | ||
rc_box_addr, | ||
RcBox { | ||
strong: 1, | ||
weak: 0, | ||
// The difference with | ||
// TEST_FORBID_LEN_UPDATE_AFTER_OWNERSHIP_CHANGE_MOVING_DATA_POINTER | ||
// is that we don't move the data pointer past the | ||
// RcBox. This is needed to avoid the "Invalid account | ||
// info pointer" check when direct mapping is enabled. | ||
// This also means we don't need to update the | ||
// serialized len like we do in the other test. | ||
value: RefCell::new(slice::from_raw_parts_mut( | ||
account.data.borrow_mut().as_mut_ptr(), | ||
0, | ||
)), | ||
}, | ||
); | ||
} | ||
rc_box, | ||
) | ||
}; | ||
|
||
let rc_box2 = RcBox { | ||
strong: 1, | ||
weak: 0, | ||
// The difference with | ||
// TEST_FORBID_LEN_UPDATE_AFTER_OWNERSHIP_CHANGE_MOVING_DATA_POINTER | ||
// is that we don't move the data pointer past the | ||
// RcBox. This is needed to avoid the "Invalid account | ||
// info pointer" check when direct mapping is enabled. | ||
// This also means we don't need to update the | ||
// serialized len like we do in the other test. | ||
value: unsafe { RefCell::new(slice::from_raw_parts_mut( | ||
target_account.data.borrow_mut().as_mut_ptr(), | ||
target_len, | ||
)) }, | ||
}; | ||
let rc_box_size = mem::size_of::<RcBox<RefCell<&mut [u8]>>>(); | ||
|
||
let serialized_len_ptr = | ||
unsafe { account.data.borrow_mut().as_mut_ptr().offset(-8) as *mut u64 }; | ||
let serialized_len_ptr2 = | ||
unsafe { target_account.data.borrow_mut().as_mut_ptr().offset(-8) as *mut u64 }; | ||
// Place a RcBox<RefCell<&mut [u8]>> in the account data. This | ||
// allows us to test having CallerAccount::ref_to_len_in_vm in an | ||
// account region. | ||
unsafe { | ||
std::ptr::write( | ||
&account.data as *const _ as usize as *mut Rc<RefCell<&mut [u8]>>, | ||
&target_account.data as *const _ as usize as *mut Rc<RefCell<&mut [u8]>>, | ||
Rc::from_raw(((rc_box_addr as usize) + mem::size_of::<usize>() * 2) as *mut _), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here 1/2
ryoqun
commented
Aug 1, 2023
let account = &accounts[0]; | ||
//msg!("self-cpi-pre: {:02x?}", unsafe { slice::from_raw_parts(account.data.borrow().as_ptr(), 100) }); | ||
//account.data.borrow_mut()[32] = 0x99; | ||
account.data.borrow_mut()[32] = 0x5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here 2/2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Summary of Changes
Fixes #