Skip to content

Commit

Permalink
android: Enable building ashmem and binder as modules
Browse files Browse the repository at this point in the history
We want to enable use of the Android ashmem and binder drivers to
support Anbox, but they should not be built-in as that would waste
resources and increase security attack surface on systems that don't
need them.

- Add a MODULE_LICENSE declaration to ashmem
- Change the Makefiles to build each driver as an object with the
  "_linux" suffix (which is what Anbox expects)
- Change config symbol types to tristate
  • Loading branch information
bwhacks authored and xanmod committed Oct 16, 2020
1 parent 1a421e2 commit a3a4618
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion drivers/android/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions drivers/android/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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
obj-$(CONFIG_ANDROID_BINDER_IPC) += binder_linux.o
binder_linux-y := binder.o binder_alloc.o
binder_linux-$(CONFIG_ANDROID_BINDERFS) += binderfs.o
binder_linux-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
2 changes: 1 addition & 1 deletion drivers/android/binder_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum {
};
static uint32_t binder_alloc_debug_mask = BINDER_DEBUG_USER_ERROR;

module_param_named(debug_mask, binder_alloc_debug_mask,
module_param_named(alloc_debug_mask, binder_alloc_debug_mask,
uint, 0644);

#define binder_alloc_debug(mask, x...) \
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/android/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ menu "Android"
if ANDROID

config ASHMEM
bool "Enable the Anonymous Shared Memory Subsystem"
tristate "Enable the Anonymous Shared Memory Subsystem"
depends on SHMEM
help
The ashmem subsystem is a new shared memory allocator, similar to
Expand Down
3 changes: 2 additions & 1 deletion drivers/staging/android/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ ccflags-y += -I$(src) # needed for trace events

obj-y += ion/

obj-$(CONFIG_ASHMEM) += ashmem.o
obj-$(CONFIG_ASHMEM) += ashmem_linux.o
ashmem_linux-y += ashmem.o
3 changes: 3 additions & 0 deletions drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/shmem_fs.h>
#include <linux/module.h>
#include "ashmem.h"

#define ASHMEM_NAME_PREFIX "dev/ashmem/"
Expand Down Expand Up @@ -965,3 +966,5 @@ static int __init ashmem_init(void)
return ret;
}
device_initcall(ashmem_init);

MODULE_LICENSE("GPL v2");

0 comments on commit a3a4618

Please sign in to comment.