From 94e63e1a682514d9129e34adb4014c4dcd012c58 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 5 Dec 2023 20:29:50 +0000 Subject: libbinder: restrict non-Android kernel binder use Bringing this up in new environments, we need to make sure they use different headers, so we never copy transactions from one environment or another by accident. Bug: 313702213 Test: build Change-Id: I0cae4a149267862092030c00d239e93155f70143 --- libs/binder/Parcel.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libs/binder/Parcel.cpp') diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 47e3f91ac2..a1f164c5c7 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -845,6 +845,9 @@ void Parcel::updateWorkSourceRequestHeaderPosition() const { } #ifdef BINDER_WITH_KERNEL_IPC + +#if defined(__ANDROID__) + #if defined(__ANDROID_VNDK__) constexpr int32_t kHeader = B_PACK_CHARS('V', 'N', 'D', 'R'); #elif defined(__ANDROID_RECOVERY__) @@ -852,6 +855,14 @@ constexpr int32_t kHeader = B_PACK_CHARS('R', 'E', 'C', 'O'); #else constexpr int32_t kHeader = B_PACK_CHARS('S', 'Y', 'S', 'T'); #endif + +#else // ANDROID not defined + +// If kernel binder is used in new environments, we need to make sure it's separated +// out and has a separate header. +constexpr int32_t kHeader = B_PACK_CHARS('U', 'N', 'K', 'N'); +#endif + #endif // BINDER_WITH_KERNEL_IPC // Write RPC headers. (previously just the interface token) -- cgit v1.2.3-59-g8ed1b