diff --git a/drivers/android/binder.c b/drivers/android/binder.c index e58dd44eee3db8c58bf13a58aa4f9e5e0e15638b..73d228c343e57da7234df519c598edfe91dd4b42 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -4455,10 +4455,6 @@ static int binder_thread_read(struct binder_proc *proc, trd->code = t->code; trd->flags = t->flags; trd->sender_euid = from_kuid(current_user_ns(), t->sender_euid); -#ifdef CONFIG_ACCESS_TOKENID - trd->sender_tokenid = t->sender_tokenid; - trd->first_tokenid = t->first_tokenid; -#endif /* CONFIG_ACCESS_TOKENID */ t_from = binder_get_txn_from(t); if (t_from) { @@ -5137,6 +5133,36 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } break; } + case BINDER_GET_ADDITION_TRANS_DATA: { + struct addition_trans_data __user *addition_data = ubuf; + if (size != sizeof(struct addition_trans_data)) { + ret = -EINVAL; + goto err; + } +#ifdef CONFIG_ACCESS_TOKENID + binder_inner_proc_lock(proc); + if (thread->transaction_stack == NULL) { + ret = -EFAULT; + binder_inner_proc_unlock(proc); + goto err; + } + u64 token = thread->transaction_stack->sender_tokenid; + u64 ftoken = thread->transaction_stack->first_tokenid; + binder_inner_proc_unlock(proc); +#else + u64 token = 0; + u64 ftoken = 0; +#endif /* CONFIG_ACCESS_TOKENID */ + if (put_user(token, &addition_data->sender_tokenid)) { + ret = -EINVAL; + goto err; + } + if (put_user(ftoken, &addition_data->first_tokenid)) { + ret = -EINVAL; + goto err; + } + break; + } default: ret = -EINVAL; goto err; diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h index 1b75626269a36f6d345a214ea4decee31ffe9efd..ee12d9c9f3af0c7be3fee504a7c060b580cc44b2 100644 --- a/include/uapi/linux/android/binder.h +++ b/include/uapi/linux/android/binder.h @@ -226,6 +226,12 @@ struct binder_node_info_for_ref { __u32 reserved3; }; +struct addition_trans_data { + __u64 sender_tokenid; + __u64 first_tokenid; + __u64 reserved[6]; +}; + #define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) #define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) #define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) @@ -237,6 +243,8 @@ struct binder_node_info_for_ref { #define BINDER_GET_NODE_INFO_FOR_REF _IOWR('b', 12, struct binder_node_info_for_ref) #define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object) +#define BINDER_GET_ADDITION_TRANS_DATA _IOW('b', 21, struct addition_trans_data) + /* * NOTE: Two special error codes you should check for when calling * in to the driver are: @@ -293,10 +301,6 @@ struct binder_transaction_data { } ptr; __u8 buf[8]; } data; -#ifdef CONFIG_ACCESS_TOKENID - __u64 sender_tokenid; - __u64 first_tokenid; -#endif /* CONFIG_ACCESS_TOKENID */ }; struct binder_transaction_data_secctx {