android: Enable building ashmem and binder as modules
authorBen Hutchings <ben@decadent.org.uk>
Fri, 22 Jun 2018 16:27:00 +0000 (17:27 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Tue, 29 Mar 2022 20:46:53 +0000 (21:46 +0100)
Bug-Debian: https://bugs.debian.org/901492

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

Gbp-Pq: Topic debian
Gbp-Pq: Name android-enable-building-ashmem-and-binder-as-modules.patch

drivers/android/Kconfig
drivers/android/Makefile
drivers/android/binder_alloc.c
drivers/staging/android/Kconfig
drivers/staging/android/Makefile
drivers/staging/android/ashmem.c

index 53b22e26266c3ea2eca4be14447b97d89de46c21..f3c50236e8d167bec9d47504513153adec05fd0a 100644 (file)
@@ -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
index c9d3d0c99c25717a4bf6867c10732e5eb9022ad1..55411d9a9c2a1f9baecebe99bbf95812ec0cd6a3 100644 (file)
@@ -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
index 47bc74a8c7b6fa5e6c5b60fe232edd216d3fc42f..49ff7504646e01c64db05c8690146e0971b6b0e0 100644 (file)
@@ -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...) \
index 70498adb157599c8e47263b127adeaf926be1308..5c35653ed36d06ab5f779010729623e15c8f519d 100644 (file)
@@ -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
index e9a55a5e65291b105c9948a3e9c0e44e713b8c8d..60cb8eacc7931f47873bcde92a57dd36294cefb8 100644 (file)
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 ccflags-y += -I$(src)                  # needed for trace events
 
-obj-$(CONFIG_ASHMEM)                   += ashmem.o
+obj-$(CONFIG_ASHMEM)                   += ashmem_linux.o
+ashmem_linux-y                         += ashmem.o
index ddbde3f8430e9b1f1722a4aaf057d6e64c325ff2..2a92b0a7482f524e52efc04045f0644fcb501554 100644 (file)
@@ -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/"
@@ -968,3 +969,5 @@ out:
        return ret;
 }
 device_initcall(ashmem_init);
+
+MODULE_LICENSE("GPL v2");