summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2023-12-05 20:29:50 +0000
committer Steven Moreland <smoreland@google.com> 2023-12-05 23:00:57 +0000
commit94e63e1a682514d9129e34adb4014c4dcd012c58 (patch)
treee3d755694303483e808e179c0511f4dd7fd975f4 /libs/binder/Parcel.cpp
parentaa627355e44f15f22703515253adae994e6aafe6 (diff)
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
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp11
1 files changed, 11 insertions, 0 deletions
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)