ipa: Use FileDescriptor instead of int in layers above IPC payload
Regarding (de)serialization in isolated IPA calls, we have four layers: - struct - byte vector + fd vector - IPCMessage - IPC payload The proxy handles the upper three layers (with help from the IPADataSerializer), and passes an IPCMessage to the IPC mechanism (implemented as an IPCPipe), which sends an IPC payload to its worker counterpart. When a FileDescriptor is involved, previously it was only a FileDescriptor in the first layer; in the lower three it was an int. To reduce the risk of potential fd leaks in the future, keep the FileDescriptor as-is throughout the upper three layers. Only the IPC mechanism will deal with ints, if it so wishes, when it does the actual IPC. IPCPipeUnixSocket does deal with ints for sending fds, so the conversion between IPCMessage and IPCUnixSocket::Payload converts between FileDescriptor and int. Additionally, change the data portion of the serialized form of FileDescriptor to a 32-bit unsigned integer, for alightnment purposes and in preparation for conversion to an index into the fd array. Also update the deserializer of FrameBuffer::Plane accordingly. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
This commit is contained in:
parent
e35cae0679
commit
31078711d6
9 changed files with 108 additions and 93 deletions
|
@ -53,7 +53,7 @@ template<typename T>
|
|||
int testPodSerdes(T in)
|
||||
{
|
||||
std::vector<uint8_t> buf;
|
||||
std::vector<int32_t> fds;
|
||||
std::vector<FileDescriptor> fds;
|
||||
|
||||
std::tie(buf, fds) = IPADataSerializer<T>::serialize(in);
|
||||
T out = IPADataSerializer<T>::deserialize(buf, fds);
|
||||
|
@ -72,7 +72,7 @@ int testVectorSerdes(const std::vector<T> &in,
|
|||
ControlSerializer *cs = nullptr)
|
||||
{
|
||||
std::vector<uint8_t> buf;
|
||||
std::vector<int32_t> fds;
|
||||
std::vector<FileDescriptor> fds;
|
||||
|
||||
std::tie(buf, fds) = IPADataSerializer<std::vector<T>>::serialize(in, cs);
|
||||
std::vector<T> out = IPADataSerializer<std::vector<T>>::deserialize(buf, fds, cs);
|
||||
|
@ -92,7 +92,7 @@ int testMapSerdes(const std::map<K, V> &in,
|
|||
ControlSerializer *cs = nullptr)
|
||||
{
|
||||
std::vector<uint8_t> buf;
|
||||
std::vector<int32_t> fds;
|
||||
std::vector<FileDescriptor> fds;
|
||||
|
||||
std::tie(buf, fds) = IPADataSerializer<std::map<K, V>>::serialize(in, cs);
|
||||
std::map<K, V> out = IPADataSerializer<std::map<K, V>>::deserialize(buf, fds, cs);
|
||||
|
@ -219,7 +219,7 @@ private:
|
|||
};
|
||||
|
||||
std::vector<uint8_t> buf;
|
||||
std::vector<int32_t> fds;
|
||||
std::vector<FileDescriptor> fds;
|
||||
|
||||
if (testVectorSerdes(vecUint8) != TestPass)
|
||||
return TestFail;
|
||||
|
@ -291,7 +291,7 @@ private:
|
|||
{ { "a", { 1, 2, 3 } }, { "b", { 4, 5, 6 } }, { "c", { 7, 8, 9 } } };
|
||||
|
||||
std::vector<uint8_t> buf;
|
||||
std::vector<int32_t> fds;
|
||||
std::vector<FileDescriptor> fds;
|
||||
|
||||
if (testMapSerdes(mapUintStr) != TestPass)
|
||||
return TestFail;
|
||||
|
@ -359,7 +359,7 @@ private:
|
|||
std::string strEmpty = "";
|
||||
|
||||
std::vector<uint8_t> buf;
|
||||
std::vector<int32_t> fds;
|
||||
std::vector<FileDescriptor> fds;
|
||||
|
||||
if (testPodSerdes(u32min) != TestPass)
|
||||
return TestFail;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue