adapt binder for kernel 6.6.0
This commit is contained in:
parent
00f9bedc6e
commit
d0581125c1
@ -1,22 +1,22 @@
|
||||
From 94b7c10aba2a0c79b88a2b37598adefd206f3e5b Mon Sep 17 00:00:00 2001
|
||||
From: heppen <hepeng68@huawei.com>
|
||||
Date: Mon, 26 Jun 2023 17:11:55 +0800
|
||||
Subject: [PATCH] Adapt binder as a kernel module
|
||||
From 9a2376b00d8ea7cf635241f8ab9cc78101019776 Mon Sep 17 00:00:00 2001
|
||||
From: heppen <heppen@qq.com>
|
||||
Date: Tue, 5 Mar 2024 16:50:29 +0800
|
||||
Subject: [PATCH] Adapt binder as a kernel module on kernel 6.6.0-10
|
||||
|
||||
---
|
||||
Makefile | 21 ++++++++---
|
||||
binder.c | 26 +++++++++++--
|
||||
binder_alloc.c | 2 +-
|
||||
external_symbols.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 131 insertions(+), 9 deletions(-)
|
||||
Makefile | 18 ++++++--
|
||||
binder.c | 22 +++++++++-
|
||||
binder_alloc.c | 2 +-
|
||||
external_symbols.c | 102 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 138 insertions(+), 6 deletions(-)
|
||||
create mode 100644 external_symbols.c
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index c9d3d0c..5d07f84 100644
|
||||
index c9d3d0c..385bcaf 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -1,6 +1,17 @@
|
||||
-# SPDX-License-Identifier: GPL-2.0-only
|
||||
@@ -1,6 +1,16 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
-ccflags-y += -I$(src) # needed for trace events
|
||||
+CONFIG_MODULE_SIG=n
|
||||
+ccflags-y += -I$(src) -Wno-int-conversion -Wno-implicit-function-declaration -DCONFIG_ANDROID_BINDER_DEVICES=\"binder\"
|
||||
@ -24,14 +24,12 @@ index c9d3d0c..5d07f84 100644
|
||||
-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
|
||||
+# only support openEuler-22.03-LTS-SP2 kernel.
|
||||
+ifneq ($(KERNELRELEASE),)
|
||||
+obj-m := binder_linux.o
|
||||
+binder_linux-y := external_symbols.o binder.o binder_alloc.o
|
||||
+else
|
||||
+KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
|
||||
+
|
||||
+
|
||||
+all:
|
||||
+ $(MAKE) -C $(KERNEL_SRC) V=0 M=$$PWD
|
||||
+
|
||||
@ -39,21 +37,10 @@ index c9d3d0c..5d07f84 100644
|
||||
+ $(MAKE) -C $(KERNEL_SRC) M=$$PWD clean
|
||||
+endif
|
||||
diff --git a/binder.c b/binder.c
|
||||
index b403c7f..35384d8 100644
|
||||
index 92128aa..25f1a30 100644
|
||||
--- a/binder.c
|
||||
+++ b/binder.c
|
||||
@@ -2039,8 +2039,8 @@ static size_t binder_get_object(struct binder_proc *proc,
|
||||
return 0;
|
||||
} else {
|
||||
if (binder_alloc_copy_from_buffer(&proc->alloc, object, buffer,
|
||||
- offset, read_size))
|
||||
- return 0;
|
||||
+ offset, read_size))
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/* Ok, now see if we read a complete object. */
|
||||
@@ -6531,7 +6531,27 @@ err_alloc_device_names_failed:
|
||||
@@ -6622,7 +6622,27 @@ err_alloc_device_names_failed:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -83,7 +70,7 @@ index b403c7f..35384d8 100644
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include "binder_trace.h"
|
||||
diff --git a/binder_alloc.c b/binder_alloc.c
|
||||
index a77ed66..1f5446c 100644
|
||||
index e3db829..eef695e 100644
|
||||
--- a/binder_alloc.c
|
||||
+++ b/binder_alloc.c
|
||||
@@ -38,7 +38,7 @@ enum {
|
||||
@ -97,10 +84,10 @@ index a77ed66..1f5446c 100644
|
||||
#define binder_alloc_debug(mask, x...) \
|
||||
diff --git a/external_symbols.c b/external_symbols.c
|
||||
new file mode 100644
|
||||
index 0000000..4ee95e7
|
||||
index 0000000..3e7bf7c
|
||||
--- /dev/null
|
||||
+++ b/external_symbols.c
|
||||
@@ -0,0 +1,91 @@
|
||||
@@ -0,0 +1,102 @@
|
||||
+#include <linux/sched.h>
|
||||
+#include <linux/file.h>
|
||||
+#include <linux/fdtable.h>
|
||||
@ -110,6 +97,13 @@ index 0000000..4ee95e7
|
||||
+#include <linux/spinlock.h>
|
||||
+#include <linux/kprobes.h>
|
||||
+
|
||||
+enum task_work_notify_mode {
|
||||
+ TWA_NONE,
|
||||
+ TWA_RESUME,
|
||||
+ TWA_SIGNAL,
|
||||
+ TWA_SIGNAL_NO_IPI,
|
||||
+};
|
||||
+
|
||||
+static struct kprobe kp = {
|
||||
+ .symbol_name = "kallsyms_lookup_name"
|
||||
+};
|
||||
@ -126,7 +120,7 @@ index 0000000..4ee95e7
|
||||
+ return kallsyms_lookup_name_ptr;
|
||||
+}
|
||||
+
|
||||
+static void (*zap_page_range_ptr)(struct vm_area_struct *, unsigned long, unsigned long) = NULL;
|
||||
+// static void (*zap_page_range_ptr)(struct vm_area_struct *, unsigned long, unsigned long) = NULL;
|
||||
+static int (*can_nice_ptr)(const struct task_struct *, const int) = NULL;
|
||||
+static int (*security_binder_set_context_mgr_ptr)(struct task_struct *mgr) = NULL;
|
||||
+static int (*security_binder_transaction_ptr)(struct task_struct *from, struct task_struct *to) = NULL;
|
||||
@ -136,62 +130,66 @@ index 0000000..4ee95e7
|
||||
+ enum task_work_notify_mode mode) = NULL;
|
||||
+static void (*__wake_up_pollfree_ptr)(wait_queue_head_t *wq_head) = NULL;
|
||||
+
|
||||
+static int (*close_fd_get_file_ptr)(unsigned int fd, struct file **res) = NULL;
|
||||
+static struct file* (*close_fd_get_file_ptr)(unsigned int fd) = NULL;
|
||||
+
|
||||
+void zap_page_range(struct vm_area_struct *vma, unsigned long address, unsigned long size)
|
||||
+static void (*zap_page_range_single_ptr)(struct vm_area_struct *vma, unsigned long address,
|
||||
+ unsigned long size, struct zap_details *details) = NULL;
|
||||
+
|
||||
+void zap_page_range_single(struct vm_area_struct *vma, unsigned long address, // yes
|
||||
+ unsigned long size, struct zap_details *details)
|
||||
+{
|
||||
+ zap_page_range_ptr = get_lookup()("zap_page_range");
|
||||
+ zap_page_range_ptr(vma, address, size);
|
||||
+ zap_page_range_single_ptr = get_lookup()("zap_page_range_single");
|
||||
+ zap_page_range_single_ptr(vma, address, size, details);
|
||||
+}
|
||||
+
|
||||
+int can_nice(const struct task_struct *p, const int nice)
|
||||
+int can_nice(const struct task_struct *p, const int nice) // yes
|
||||
+{
|
||||
+ can_nice_ptr = get_lookup()("can_nice");
|
||||
+ return can_nice_ptr(p, nice);
|
||||
+}
|
||||
+
|
||||
+int security_binder_set_context_mgr(struct task_struct *mgr)
|
||||
+int security_binder_set_context_mgr(struct task_struct *mgr) // yes
|
||||
+{
|
||||
+ security_binder_set_context_mgr_ptr = get_lookup()("security_binder_set_context_mgr");
|
||||
+ return security_binder_set_context_mgr_ptr(mgr);
|
||||
+}
|
||||
+
|
||||
+int security_binder_transaction(struct task_struct *from, struct task_struct *to)
|
||||
+int security_binder_transaction(struct task_struct *from, struct task_struct *to) // yes
|
||||
+{
|
||||
+ security_binder_transaction_ptr = get_lookup()("security_binder_transaction");
|
||||
+ return security_binder_transaction_ptr(from, to);
|
||||
+}
|
||||
+
|
||||
+int security_binder_transfer_binder(struct task_struct *from, struct task_struct *to)
|
||||
+int security_binder_transfer_binder(struct task_struct *from, struct task_struct *to) // yes
|
||||
+{
|
||||
+ security_binder_transfer_binder_ptr = get_lookup()("security_binder_transfer_binder");
|
||||
+ return security_binder_transfer_binder_ptr(from, to);
|
||||
+}
|
||||
+
|
||||
+int security_binder_transfer_file(struct task_struct *from, struct task_struct *to, struct file *file)
|
||||
+int security_binder_transfer_file(struct task_struct *from, struct task_struct *to, struct file *file) // yes
|
||||
+{
|
||||
+ security_binder_transfer_file_ptr = get_lookup()("security_binder_transfer_file");
|
||||
+ return security_binder_transfer_file_ptr(from, to, file);
|
||||
+}
|
||||
+
|
||||
+int task_work_add(struct task_struct *task, struct callback_head *twork,
|
||||
+int task_work_add(struct task_struct *task, struct callback_head *twork, // yes
|
||||
+ enum task_work_notify_mode mode)
|
||||
+{
|
||||
+ task_work_add_ptr = get_lookup()("task_work_add");
|
||||
+ return task_work_add_ptr(task, twork, mode);
|
||||
+}
|
||||
+
|
||||
+int close_fd_get_file(unsigned int fd, struct file **res)
|
||||
+struct file *close_fd_get_file(unsigned int fd)
|
||||
+{
|
||||
+ close_fd_get_file_ptr = get_lookup()("close_fd_get_file");
|
||||
+ return close_fd_get_file_ptr(fd, res);
|
||||
+ return close_fd_get_file_ptr(fd);
|
||||
+}
|
||||
+
|
||||
+void __wake_up_pollfree(wait_queue_head_t *wq_head)
|
||||
+void __wake_up_pollfree(wait_queue_head_t *wq_head) // yes
|
||||
+{
|
||||
+ __wake_up_pollfree_ptr = get_lookup()("__wake_up_pollfree");
|
||||
+ return __wake_up_pollfree_ptr(wq_head);
|
||||
+}
|
||||
--
|
||||
2.33.0
|
||||
2.43.0
|
||||
|
||||
BIN
binder-6.6.0.tar.gz
Normal file
BIN
binder-6.6.0.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
@ -7,7 +7,7 @@
|
||||
%global binder_dest_path /usr/lib/modules/%(uname -r)/binder
|
||||
%global ashmem_dest_path /usr/lib/modules/%(uname -r)/ashmem
|
||||
|
||||
%define with_ashmem 1
|
||||
%define with_ashmem 0
|
||||
%define with_install_ko 0
|
||||
|
||||
Name: communication_ipc
|
||||
@ -21,7 +21,7 @@ Source2: https://gitee.com/openharmony/communication_dsoftbus/repository/
|
||||
Source3: https://gitee.com/openharmony/third_party_sqlite/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/third_party_sqlite-OpenHarmony-v3.2-Release.tar.gz
|
||||
Source4: https://gitee.com/openharmony/third_party_libcoap/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/third_party_libcoap-OpenHarmony-v3.2-Release.tar.gz
|
||||
Source5: https://gitee.com/openharmony/third_party_mbedtls/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/third_party_mbedtls-OpenHarmony-v3.2-Release.tar.gz
|
||||
Source6: https://gitee.com/openeuler/kernel/binder-%{oe_version}.tar.gz
|
||||
Source6: https://gitee.com/openeuler/kernel/binder-6.6.0.tar.gz
|
||||
Source7: ipc.bundle.json
|
||||
Source8: ipc.BUILD.gn
|
||||
Source9: ipc_core.BUILD.gn
|
||||
@ -36,7 +36,7 @@ Source17: binder.pp
|
||||
|
||||
Patch1: 0001-remove-dependence-on-access-token-and-hitrace.patch
|
||||
Patch2: 0002-fix-build-error-from-header-include.patch
|
||||
Patch3: 0003-adapt-binder-as-a-kernel-module.patch
|
||||
Patch3: 0003-Adapt-binder-as-a-kernel-module-on-kernel-6.6.0-10.patch
|
||||
Patch4: 0004-adapt-compilation-for-softbus_client.patch
|
||||
|
||||
BuildRequires: gcc, make, hilog, kernel-devel, uname-build-checks
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user