UBUNTU: SAUCE: binder: turn into module
The Android binder driver needs to become a module for the sake of shipping Anbox. To do this we need to export the following functions since binder is currently still using them: - security_binder_set_context_mgr() - security_binder_transaction() - security_binder_transfer_binder() - security_binder_transfer_file() - can_nice() - __close_fd_get_file() - mmput_async() - task_work_add() - map_kernel_range_noflush() - get_vm_area() - zap_page_range() - put_ipc_ns() - get_ipc_ns_exported() - show_init_ipc_ns() Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> [ saf: fix additional reference to init_ipc_ns from 5.0-rc6 ] Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
This commit is contained in:
parent
7670e0531b
commit
ceaf03b459
|
@ -9,7 +9,7 @@ config ANDROID
|
|||
if ANDROID
|
||||
|
||||
config ANDROID_BINDER_IPC
|
||||
bool "Android Binder IPC Driver"
|
||||
tristate "Android Binder IPC Driver"
|
||||
depends on MMU
|
||||
default n
|
||||
---help---
|
||||
|
@ -21,8 +21,8 @@ config ANDROID_BINDER_IPC
|
|||
between said processes.
|
||||
|
||||
config ANDROID_BINDERFS
|
||||
bool "Android Binderfs filesystem"
|
||||
depends on ANDROID_BINDER_IPC
|
||||
tristate "Android Binderfs filesystem"
|
||||
depends on (ANDROID_BINDER_IPC=y) || (ANDROID_BINDER_IPC=m && m)
|
||||
default n
|
||||
---help---
|
||||
Binderfs is a pseudo-filesystem for the Android Binder IPC driver
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
ccflags-y += -I$(src) # needed for trace events
|
||||
|
||||
obj-$(CONFIG_ANDROID_BINDERFS) += binderfs.o
|
||||
obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o
|
||||
obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
|
||||
binder_linux-y := binder.o binder_alloc.o
|
||||
obj-$(CONFIG_ANDROID_BINDER_IPC) += binder_linux.o
|
||||
binder_linux-$(CONFIG_ANDROID_BINDERFS) += binderfs.o
|
||||
binder_linux-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
|
||||
|
||||
# binder-$(CONFIG_ANDROID_BINDER_IPC) := binder.o binder_alloc.o
|
||||
# binder-$(CONFIG_ANDROID_BINDERFS) += binderfs.o
|
||||
|
|
|
@ -6182,9 +6182,20 @@ err_alloc_device_names_failed:
|
|||
return ret;
|
||||
}
|
||||
|
||||
device_initcall(binder_init);
|
||||
module_init(binder_init);
|
||||
/*
|
||||
* binder will have no exit function since binderfs instances can be mounted
|
||||
* multiple times and also in user namespaces finding and destroying them all
|
||||
* is not feasible without introducing insane locking. Just ignoring existing
|
||||
* instances on module unload also wouldn't work since we would loose track of
|
||||
* what major numer was dynamically allocated and also what minor numbers are
|
||||
* already given out. So this would get us into all kinds of issues with device
|
||||
* number reuse. So simply don't allow unloading unless we are forced to do so.
|
||||
*/
|
||||
|
||||
MODULE_AUTHOR("Google, Inc.");
|
||||
MODULE_DESCRIPTION("Driver for Android binder device");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include "binder_trace.h"
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef _LINUX_BINDER_ALLOC_H
|
||||
#define _LINUX_BINDER_ALLOC_H
|
||||
|
||||
#include <linux/kconfig.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/mm.h>
|
||||
|
@ -105,7 +106,7 @@ struct binder_alloc {
|
|||
size_t pages_high;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ANDROID_BINDER_IPC_SELFTEST
|
||||
#if IS_ENABLED(CONFIG_ANDROID_BINDER_IPC_SELFTEST)
|
||||
void binder_selftest_alloc(struct binder_alloc *alloc);
|
||||
#else
|
||||
static inline void binder_selftest_alloc(struct binder_alloc *alloc) {}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <linux/export.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/kconfig.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/mutex.h>
|
||||
|
@ -73,7 +74,7 @@ extern const struct file_operations binder_fops;
|
|||
|
||||
extern char *binder_devices_param;
|
||||
|
||||
#ifdef CONFIG_ANDROID_BINDERFS
|
||||
#if IS_ENABLED(CONFIG_ANDROID_BINDERFS)
|
||||
extern bool is_binderfs_device(const struct inode *inode);
|
||||
extern struct dentry *binderfs_create_file(struct dentry *dir, const char *name,
|
||||
const struct file_operations *fops,
|
||||
|
@ -94,7 +95,7 @@ static inline struct dentry *binderfs_create_file(struct dentry *dir,
|
|||
static inline void binderfs_remove_file(struct dentry *dentry) {}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ANDROID_BINDERFS
|
||||
#if IS_ENABLED(CONFIG_ANDROID_BINDERFS)
|
||||
extern int __init init_binderfs(void);
|
||||
#else
|
||||
static inline int __init init_binderfs(void)
|
||||
|
|
|
@ -109,7 +109,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
|
|||
struct super_block *sb = ref_inode->i_sb;
|
||||
struct binderfs_info *info = sb->s_fs_info;
|
||||
#if defined(CONFIG_IPC_NS)
|
||||
bool use_reserve = (info->ipc_ns == &init_ipc_ns);
|
||||
bool use_reserve = (info->ipc_ns == show_init_ipc_ns());
|
||||
#else
|
||||
bool use_reserve = true;
|
||||
#endif
|
||||
|
@ -405,7 +405,7 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
|
|||
struct dentry *root = sb->s_root;
|
||||
struct binderfs_info *info = sb->s_fs_info;
|
||||
#if defined(CONFIG_IPC_NS)
|
||||
bool use_reserve = (info->ipc_ns == &init_ipc_ns);
|
||||
bool use_reserve = (info->ipc_ns == show_init_ipc_ns());
|
||||
#else
|
||||
bool use_reserve = true;
|
||||
#endif
|
||||
|
@ -683,7 +683,7 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
|
|||
return -ENOMEM;
|
||||
info = sb->s_fs_info;
|
||||
|
||||
info->ipc_ns = get_ipc_ns(current->nsproxy->ipc_ns);
|
||||
info->ipc_ns = get_ipc_ns_exported(current->nsproxy->ipc_ns);
|
||||
|
||||
ret = binderfs_parse_mount_opts(data, &info->mount_opts);
|
||||
if (ret)
|
||||
|
|
|
@ -669,6 +669,7 @@ out_unlock:
|
|||
*res = NULL;
|
||||
return -ENOENT;
|
||||
}
|
||||
EXPORT_SYMBOL(__close_fd_get_file);
|
||||
|
||||
void do_close_on_exec(struct files_struct *files)
|
||||
{
|
||||
|
|
|
@ -119,6 +119,9 @@ extern int mq_init_ns(struct ipc_namespace *ns);
|
|||
static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; }
|
||||
#endif
|
||||
|
||||
extern struct ipc_namespace *get_ipc_ns_exported(struct ipc_namespace *ns);
|
||||
extern struct ipc_namespace *show_init_ipc_ns(void);
|
||||
|
||||
#if defined(CONFIG_IPC_NS)
|
||||
extern struct ipc_namespace *copy_ipcs(unsigned long flags,
|
||||
struct user_namespace *user_ns, struct ipc_namespace *ns);
|
||||
|
|
|
@ -152,6 +152,23 @@ void put_ipc_ns(struct ipc_namespace *ns)
|
|||
free_ipc_ns(ns);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(put_ipc_ns);
|
||||
|
||||
struct ipc_namespace *get_ipc_ns_exported(struct ipc_namespace *ns)
|
||||
{
|
||||
return get_ipc_ns(ns);
|
||||
}
|
||||
EXPORT_SYMBOL(get_ipc_ns_exported);
|
||||
|
||||
struct ipc_namespace *show_init_ipc_ns(void)
|
||||
{
|
||||
#if defined(CONFIG_IPC_NS)
|
||||
return &init_ipc_ns;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(show_init_ipc_ns);
|
||||
|
||||
static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns)
|
||||
{
|
||||
|
|
|
@ -1122,6 +1122,7 @@ void mmput_async(struct mm_struct *mm)
|
|||
schedule_work(&mm->async_put_work);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(mmput_async);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -4559,6 +4559,7 @@ int can_nice(const struct task_struct *p, const int nice)
|
|||
return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
|
||||
capable(CAP_SYS_NICE));
|
||||
}
|
||||
EXPORT_SYMBOL(can_nice);
|
||||
|
||||
#ifdef __ARCH_WANT_SYS_NICE
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ task_work_add(struct task_struct *task, struct callback_head *work, bool notify)
|
|||
set_notify_resume(task);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(task_work_add);
|
||||
|
||||
/**
|
||||
* task_work_cancel - cancel a pending work added by task_work_add()
|
||||
|
|
|
@ -1340,6 +1340,7 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start,
|
|||
mmu_notifier_invalidate_range_end(&range);
|
||||
tlb_finish_mmu(&tlb, start, range.end);
|
||||
}
|
||||
EXPORT_SYMBOL(zap_page_range);
|
||||
|
||||
/**
|
||||
* zap_page_range_single - remove user pages in a given range
|
||||
|
|
|
@ -1963,6 +1963,7 @@ int map_kernel_range_noflush(unsigned long addr, unsigned long size,
|
|||
{
|
||||
return vmap_page_range_noflush(addr, addr + size, prot, pages);
|
||||
}
|
||||
EXPORT_SYMBOL(map_kernel_range_noflush);
|
||||
|
||||
/**
|
||||
* unmap_kernel_range_noflush - unmap kernel VM area
|
||||
|
@ -2104,6 +2105,7 @@ struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
|
|||
NUMA_NO_NODE, GFP_KERNEL,
|
||||
__builtin_return_address(0));
|
||||
}
|
||||
EXPORT_SYMBOL(get_vm_area);
|
||||
|
||||
struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags,
|
||||
const void *caller)
|
||||
|
|
|
@ -674,24 +674,28 @@ int security_binder_set_context_mgr(struct task_struct *mgr)
|
|||
{
|
||||
return call_int_hook(binder_set_context_mgr, 0, mgr);
|
||||
}
|
||||
EXPORT_SYMBOL(security_binder_set_context_mgr);
|
||||
|
||||
int security_binder_transaction(struct task_struct *from,
|
||||
struct task_struct *to)
|
||||
{
|
||||
return call_int_hook(binder_transaction, 0, from, to);
|
||||
}
|
||||
EXPORT_SYMBOL(security_binder_transaction);
|
||||
|
||||
int security_binder_transfer_binder(struct task_struct *from,
|
||||
struct task_struct *to)
|
||||
{
|
||||
return call_int_hook(binder_transfer_binder, 0, from, to);
|
||||
}
|
||||
EXPORT_SYMBOL(security_binder_transfer_binder);
|
||||
|
||||
int security_binder_transfer_file(struct task_struct *from,
|
||||
struct task_struct *to, struct file *file)
|
||||
{
|
||||
return call_int_hook(binder_transfer_file, 0, from, to, file);
|
||||
}
|
||||
EXPORT_SYMBOL(security_binder_transfer_file);
|
||||
|
||||
int security_ptrace_access_check(struct task_struct *child, unsigned int mode)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue