0002-android-Enable-building-ashmem-and-binder-as-modules.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From e2a9a34af4fd99de652638bfc0365aba284b95f8 Mon Sep 17 00:00:00 2001
  2. From: Ben Hutchings <ben@decadent.org.uk>
  3. Date: Fri, 22 Jun 2018 17:27:00 +0100
  4. Subject: [PATCH 2/2] android: Enable building ashmem and binder as modules
  5. We want to enable use of the Android ashmem and binder drivers to
  6. support Anbox, but they should not be built-in as that would waste
  7. resources and increase security attack surface on systems that don't
  8. need them.
  9. - Add a MODULE_LICENSE declaration to ashmem
  10. - Change the Makefiles to build each driver as an object with the
  11. "_linux" suffix (which is what Anbox expects)
  12. - Change config symbol types to tristate
  13. ---
  14. drivers/android/Kconfig | 2 +-
  15. drivers/android/Makefile | 7 ++++---
  16. drivers/android/binder_alloc.c | 2 +-
  17. drivers/staging/android/Kconfig | 2 +-
  18. drivers/staging/android/Makefile | 3 ++-
  19. drivers/staging/android/ashmem.c | 3 +++
  20. 6 files changed, 12 insertions(+), 7 deletions(-)
  21. diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig
  22. index 53b22e26266c..f3c50236e8d1 100644
  23. --- a/drivers/android/Kconfig
  24. +++ b/drivers/android/Kconfig
  25. @@ -9,7 +9,7 @@ config ANDROID
  26. if ANDROID
  27. config ANDROID_BINDER_IPC
  28. - bool "Android Binder IPC Driver"
  29. + tristate "Android Binder IPC Driver"
  30. depends on MMU
  31. default n
  32. help
  33. diff --git a/drivers/android/Makefile b/drivers/android/Makefile
  34. index c9d3d0c99c25..55411d9a9c2a 100644
  35. --- a/drivers/android/Makefile
  36. +++ b/drivers/android/Makefile
  37. @@ -1,6 +1,7 @@
  38. # SPDX-License-Identifier: GPL-2.0-only
  39. ccflags-y += -I$(src) # needed for trace events
  40. -obj-$(CONFIG_ANDROID_BINDERFS) += binderfs.o
  41. -obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o
  42. -obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
  43. +obj-$(CONFIG_ANDROID_BINDER_IPC) += binder_linux.o
  44. +binder_linux-y := binder.o binder_alloc.o
  45. +binder_linux-$(CONFIG_ANDROID_BINDERFS) += binderfs.o
  46. +binder_linux-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
  47. diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
  48. index 7caf74ad2405..9202a44bd55d 100644
  49. --- a/drivers/android/binder_alloc.c
  50. +++ b/drivers/android/binder_alloc.c
  51. @@ -38,7 +38,7 @@ enum {
  52. };
  53. static uint32_t binder_alloc_debug_mask = BINDER_DEBUG_USER_ERROR;
  54. -module_param_named(debug_mask, binder_alloc_debug_mask,
  55. +module_param_named(alloc_debug_mask, binder_alloc_debug_mask,
  56. uint, 0644);
  57. #define binder_alloc_debug(mask, x...) \
  58. diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
  59. index 70498adb1575..5c35653ed36d 100644
  60. --- a/drivers/staging/android/Kconfig
  61. +++ b/drivers/staging/android/Kconfig
  62. @@ -4,7 +4,7 @@ menu "Android"
  63. if ANDROID
  64. config ASHMEM
  65. - bool "Enable the Anonymous Shared Memory Subsystem"
  66. + tristate "Enable the Anonymous Shared Memory Subsystem"
  67. depends on SHMEM
  68. help
  69. The ashmem subsystem is a new shared memory allocator, similar to
  70. diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
  71. index e9a55a5e6529..60cb8eacc793 100644
  72. --- a/drivers/staging/android/Makefile
  73. +++ b/drivers/staging/android/Makefile
  74. @@ -1,4 +1,5 @@
  75. # SPDX-License-Identifier: GPL-2.0
  76. ccflags-y += -I$(src) # needed for trace events
  77. -obj-$(CONFIG_ASHMEM) += ashmem.o
  78. +obj-$(CONFIG_ASHMEM) += ashmem_linux.o
  79. +ashmem_linux-y += ashmem.o
  80. diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
  81. index 4789d36ddfd3..f86efd3da373 100644
  82. --- a/drivers/staging/android/ashmem.c
  83. +++ b/drivers/staging/android/ashmem.c
  84. @@ -24,6 +24,7 @@
  85. #include <linux/bitops.h>
  86. #include <linux/mutex.h>
  87. #include <linux/shmem_fs.h>
  88. +#include <linux/module.h>
  89. #include "ashmem.h"
  90. #define ASHMEM_NAME_PREFIX "dev/ashmem/"
  91. @@ -965,3 +966,5 @@ static int __init ashmem_init(void)
  92. return ret;
  93. }
  94. device_initcall(ashmem_init);
  95. +
  96. +MODULE_LICENSE("GPL v2");
  97. --
  98. 2.30.1