#416·rust

Misaligned pointer exposure in `<String as TensorType>::unpack`

Author: shinmaoCreated Sep 27, 2023Updated Mar 13, 2024
Labelsbug

The source of unsoundness

Hi, we found an unsound implementation in unpack which could create a misaligned pointer: https://github.com/tensorflow/rust/blob/62a3019cfa0720c9744b4bd5f97db953bf4066cf/src/lib.rs#L900-L903 At line 902, the u8 pointer would cast to TF_TString which had stronger alignment requirements. The misaligned pointer passed to slice::from_raw_parts would break the safety guarantee. Please check and happy to have a discussion:)