Skip to content

Commit 77d30b0

Browse files
Steven MorelandAndroid (Google) Code Review
authored andcommitted
Merge "getCallingPid: document when to use it" into main
2 parents 12f7727 + 35a2644 commit 77d30b0

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

libs/binder/include/binder/IPCThreadState.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ class IPCThreadState {
6464
* Returns the PID of the process which has made the current binder
6565
* call. If not in a binder call, this will return getpid.
6666
*
67-
* Warning: oneway transactions do not receive PID. Even if you expect
67+
* Warning do not use this as a security identifier! PID is unreliable
68+
* as it may be re-used. This should mostly be used for debugging.
69+
*
70+
* oneway transactions do not receive PID. Even if you expect
6871
* a transaction to be synchronous, a misbehaving client could send it
6972
* as an asynchronous call and result in a 0 PID here. Additionally, if
7073
* there is a race and the calling process dies, the PID may still be

libs/binder/ndk/include_ndk/android/binder_ibinder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ binder_status_t AIBinder_unlinkToDeath(AIBinder* binder, AIBinder_DeathRecipient
419419
* This can be used with higher-level system services to determine the caller's identity and check
420420
* permissions.
421421
*
422+
* Warning do not use this as a security identifier! PID is unreliable as it may be re-used. This
423+
* should mostly be used for debugging.
424+
*
422425
* Available since API level 29.
423426
*
424427
* \return calling uid or the current process's UID if this thread isn't processing a transaction.

libs/binder/rust/src/state.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ impl ThreadState {
101101
/// dies and is replaced with another process with elevated permissions and
102102
/// the same PID.
103103
///
104-
/// Warning: oneway transactions do not receive PID. Even if you expect
104+
/// Warning: do not use this as a security identifier! PID is unreliable
105+
/// as it may be re-used. This should mostly be used for debugging.
106+
///
107+
/// oneway transactions do not receive PID. Even if you expect
105108
/// a transaction to be synchronous, a misbehaving client could send it
106109
/// as a synchronous call and result in a 0 PID here. Additionally, if
107110
/// there is a race and the calling process dies, the PID may still be

0 commit comments

Comments
 (0)