summaryrefslogtreecommitdiffstats
path: root/debian/patches/debian/android-enable-building-ashmem-and-binder-as-modules.patch
blob: 2df107cfb83aca231941af691cdb30f004115c2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
From: Ben Hutchings <ben@decadent.org.uk>
Date: Fri, 22 Jun 2018 17:27:00 +0100
Subject: android: Enable building ashmem and binder as modules
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
---
 drivers/android/Kconfig          | 2 +-
 drivers/android/Makefile         | 7 ++++---
 drivers/android/binder_alloc.c   | 2 +-
 drivers/staging/android/Kconfig  | 2 +-
 drivers/staging/android/Makefile | 3 ++-
 drivers/staging/android/ashmem.c | 3 +++
 6 files changed, 12 insertions(+), 7 deletions(-)

Index: debian-kernel/drivers/android/Kconfig
===================================================================
--- debian-kernel.orig/drivers/android/Kconfig
+++ debian-kernel/drivers/android/Kconfig
@@ -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: debian-kernel/drivers/android/Makefile
===================================================================
--- debian-kernel.orig/drivers/android/Makefile
+++ debian-kernel/drivers/android/Makefile
@@ -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: debian-kernel/drivers/android/binder_alloc.c
===================================================================
--- debian-kernel.orig/drivers/android/binder_alloc.c
+++ debian-kernel/drivers/android/binder_alloc.c
@@ -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: debian-kernel/drivers/staging/android/Kconfig
===================================================================
--- debian-kernel.orig/drivers/staging/android/Kconfig
+++ debian-kernel/drivers/staging/android/Kconfig
@@ -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: debian-kernel/drivers/staging/android/Makefile
===================================================================
--- debian-kernel.orig/drivers/staging/android/Makefile
+++ debian-kernel/drivers/staging/android/Makefile
@@ -3,4 +3,5 @@ ccflags-y += -I$(src)			# needed for tra
 
 obj-y					+= ion/
 
-obj-$(CONFIG_ASHMEM)			+= ashmem.o
+obj-$(CONFIG_ASHMEM)			+= ashmem_linux.o
+ashmem_linux-y				+= ashmem.o
Index: debian-kernel/drivers/staging/android/ashmem.c
===================================================================
--- debian-kernel.orig/drivers/staging/android/ashmem.c
+++ debian-kernel/drivers/staging/android/ashmem.c
@@ -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/"
@@ -953,3 +954,5 @@ out:
 	return ret;
 }
 device_initcall(ashmem_init);
+
+MODULE_LICENSE("GPL v2");