Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: passthrough: Add MockCFileHandleWrapper
Previously, CFileHandle uses a *mut libc::c_char to transfer data between user space and kernel space. The system call "name_to_handle_at" will return the data with "copy_to_user". This may cause a bug because the memory layout of CFileHandle fields may be noncontinuous with the dynamically-sized array's. Therefore, the "copy_to_user" may destroy the stack. This is reproduced on aarch64 only when using "opt-level=3" to compile. This commit adds three structs: __IncompleteArrayField, MockCFileHandle and MockCFileHandleWrapper. We construct a dynamically-sized array with continous memory address by using FamStruct trait, called MockCFileHandleWrapper. It will manage the array automatically and provide useful interfaces to help operate on array. We can thransfer data during system call safely to protect the user stack. Besides, we reuse the struct CFileHandle to save the information in Rust version and provide four useful methods to be operated with MockCFileHandleWrapper. Fix clippy warning and update the unit test. Signed-off-by: xuejun-xj <[email protected]>
- Loading branch information