Skip to content
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
wants to merge 186 commits into
base: dm-cpi-memory-perm
Choose a base branch
from

Conversation

ryoqun
Copy link
Owner

@ryoqun ryoqun commented Aug 1, 2023

Problem

Summary of Changes

Fixes #

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 _),
);
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

here 1/2

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;
Copy link
Owner Author

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant