diff options
| author | Tim Murray <timmurray@google.com> | 2017-03-22 22:02:20 -0700 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-09-16 17:47:00 +0200 |
| commit | df5ac75816efe7f58c56826957bfb09eb2127098 (patch) | |
| tree | 7223a9a69aa111a127826538ccc4a7a87fbcb777 /drivers/android | |
| parent | 7755159b1ba50c59c1c05fa8069a884fae526d66 (diff) | |
binder: make FIFO inheritance a per-context option
Add a new ioctl to binder to control whether FIFO inheritance should happen.
In particular, hwbinder should inherit FIFO priority from callers, but standard
binder threads should not.
Test: boots
bug 36516194
Signed-off-by: Tim Murray <timmurray@google.com>
Change-Id: I8100c4364b7d15d1bf00a8ca5c286e4d4b23ce85
Diffstat (limited to 'drivers/android')
| -rw-r--r-- | drivers/android/binder.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index a078fcc22..06555e841 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -271,6 +271,7 @@ struct binder_context { kuid_t binder_context_mgr_uid; const char *name; + bool inherit_fifo_prio; }; struct binder_device { @@ -1186,6 +1187,7 @@ static void binder_transaction_priority(struct task_struct *task, struct binder_priority node_prio, bool inherit_rt) { + bool inherit_fifo = t->buffer->target_node->proc->context->inherit_fifo_prio; struct binder_priority desired_prio; if (t->set_priority_called) @@ -1195,7 +1197,7 @@ static void binder_transaction_priority(struct task_struct *task, t->saved_priority.sched_policy = task->policy; t->saved_priority.prio = task->normal_prio; - if (!inherit_rt && is_rt_policy(desired_prio.sched_policy)) { + if (!inherit_rt && is_rt_policy(desired_prio.sched_policy) && !inherit_fifo) { desired_prio.prio = NICE_TO_PRIO(0); desired_prio.sched_policy = SCHED_NORMAL; } else { @@ -4499,6 +4501,33 @@ out: return ret; } +static int binder_ioctl_set_inherit_fifo_prio(struct file *filp) +{ + int ret = 0; + struct binder_proc *proc = filp->private_data; + struct binder_context *context = proc->context; + + kuid_t curr_euid = current_euid(); + mutex_lock(&context->context_mgr_node_lock); + + if (uid_valid(context->binder_context_mgr_uid)) { + if (!uid_eq(context->binder_context_mgr_uid, curr_euid)) { + pr_err("BINDER_SET_INHERIT_FIFO_PRIO bad uid %d != %d\n", + from_kuid(&init_user_ns, curr_euid), + from_kuid(&init_user_ns, + context->binder_context_mgr_uid)); + ret = -EPERM; + goto out; + } + } + + context->inherit_fifo_prio = true; + + out: + mutex_unlock(&context->context_mgr_node_lock); + return ret; +} + static int binder_ioctl_set_ctx_mgr(struct file *filp) { int ret = 0; @@ -4617,6 +4646,11 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (ret) goto err; break; + case BINDER_SET_INHERIT_FIFO_PRIO: + ret = binder_ioctl_set_inherit_fifo_prio(filp); + if (ret) + goto err; + break; case BINDER_THREAD_EXIT: binder_debug(BINDER_DEBUG_THREADS, "%d:%d exit\n", proc->pid, thread->pid); @@ -5388,6 +5422,7 @@ static void print_binder_proc_stats(struct seq_file *m, seq_printf(m, "proc %d\n", proc->pid); seq_printf(m, "context %s\n", proc->context->name); + seq_printf(m, "context FIFO: %d\n", proc->context->inherit_fifo_prio); count = 0; ready_threads = 0; binder_inner_proc_lock(proc); |
