Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Compatibility with kernels >= 5.7 #76

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4af9d5d
Fix compilation of binder and ashmem on kernel 5.7 and later
choff Mar 8, 2021
443f984
Compile fixes for kernel >= 5.8
choff Mar 8, 2021
6ddae19
Another compile fix for kernel >= 5.8
choff Mar 8, 2021
0338a34
Update binder to the latest version
choff Sep 26, 2021
516144c
Compile fixes for kernels 5.11, 5.12 & 5.13
choff Oct 29, 2021
b0c3c5a
compilation fix for kernel 5.15.2
modscleo4 Nov 13, 2021
8148a16
sync with android binder.c
modscleo4 Nov 23, 2021
2699623
patches for 5.18 kernel
Etaash-mathamsetty May 25, 2022
6844495
Patches for kernel 5.19
Thesola10 Aug 8, 2022
2325d6f
Fixed page fault by matching in-tree binder behavior
Thesola10 Aug 9, 2022
cd66055
Fix build on 6.0 kernel
arenekosreal Oct 15, 2022
42335c6
Fix build on 6.1 kernel
arenekosreal Dec 24, 2022
ab8278c
Add TASK_FREEZABLE
arenekosreal Jan 29, 2023
a961389
fix for kernel 6.1
munix9 Jan 30, 2023
ae26ba2
Create UNINSTALL.sh script and update README.md
SonarBeserk Oct 30, 2022
44dc351
Update README.md
Krishnakumar59 Apr 18, 2023
abead1d
Fixes for kernel 6.3+
Thesola10 May 5, 2023
205c803
Fix build for kernel 6.6
arenekosreal Nov 1, 2023
41fe6db
Fix build for 6.6
Nov 23, 2023
084d199
Added conditional matching for kernels >= 6.3.0
Dec 3, 2023
13a93a4
Fix for kernel 6.7+
ssfdust Jan 6, 2024
44e5ba7
Fixes for kernel 6.8
ssfdust Jan 24, 2024
b558310
removed obsolete name="%k", added binder symlink (#1)
PuspenduBanerjee Apr 1, 2024
dcd52bf
Added packaging guide and compat fix
PuspenduBanerjee Apr 2, 2024
2c06452
updated doc to update changelog from git commits
PuspenduBanerjee Apr 2, 2024
ee4c25f
fix creation of all 3 anbox modules symlinks: anbox-binder anbox-hwbi…
May 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.ko
*.mod
*.mod.c
*.o
*.order
*.symvers
*.swp
.*.cmd
.tmp_versions
60 changes: 59 additions & 1 deletion ashmem/deps.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,69 @@
#include <linux/mm.h>
#include <linux/kallsyms.h>
#include <linux/kprobes.h>
#include <linux/version.h>

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,7,0))

#ifndef CONFIG_KPROBES
# error "Your kernel does not support KProbes, but this is required to compile ashmem as a kernel module on kernel 5.7 and later"
#endif

typedef unsigned long (*kallsyms_lookup_name_t)(const char *name);

static int dummy_kprobe_handler(struct kprobe *p, struct pt_regs *regs)
{
return 0;
}

Comment on lines +14 to +18

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not need, just delete the initialization of pre_handler.

static kallsyms_lookup_name_t get_kallsyms_lookup_name_ptr(void)
{
struct kprobe probe;
int ret;
kallsyms_lookup_name_t addr;

memset(&probe, 0, sizeof(probe));
probe.pre_handler = dummy_kprobe_handler;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

probe.symbol_name = "kallsyms_lookup_name";
ret = register_kprobe(&probe);
if (ret)
return NULL;
addr = (kallsyms_lookup_name_t) probe.addr;
unregister_kprobe(&probe);

return addr;
}
#endif

/*
* On kernel 5.7 and later, kallsyms_lookup_name() can no longer be called from a kernel
* module for reasons described here: https://lwn.net/Articles/813350/
* As ashmem really needs to use kallsysms_lookup_name() to access some kernel
* functions that otherwise wouldn't be accessible, KProbes are used on later
* kernels to get the address of kallsysms_lookup_name(). The function is
* afterwards used just as before. This is a very dirty hack though and the much
* better solution would be if all the functions that are currently resolved
* with kallsysms_lookup_name() would get an EXPORT_SYMBOL() annotation to
* make them directly accessible to kernel modules.
*/
static unsigned long kallsyms_lookup_name_wrapper(const char *name)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,7,0))
static kallsyms_lookup_name_t func_ptr = NULL;
if (!func_ptr)
func_ptr = get_kallsyms_lookup_name_ptr();

return func_ptr(name);
#else
return kallsyms_lookup_name(name);
#endif
}

static int (*shmem_zero_setup_ptr)(struct vm_area_struct *) = NULL;

int shmem_zero_setup(struct vm_area_struct *vma)
{
if (!shmem_zero_setup_ptr)
shmem_zero_setup_ptr = kallsyms_lookup_name("shmem_zero_setup");
shmem_zero_setup_ptr = kallsyms_lookup_name_wrapper("shmem_zero_setup");
return shmem_zero_setup_ptr(vma);
}
6 changes: 3 additions & 3 deletions binder/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ccflags-y += -I$(src) -Wno-int-conversion -DCONFIG_ANDROID_BINDER_DEVICES="\"binder\""
ccflags-y += -I$(src) -Wno-int-conversion -DCONFIG_ANDROID_BINDER_DEVICES="\"binder\"" -DCONFIG_ANDROID_BINDERFS="y"
obj-m := binder_linux.o
binder_linux-y := deps.o binder.o
binder_linux-y := deps.o binder.o binder_alloc.o binderfs.o

KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build

Expand All @@ -11,4 +11,4 @@ install:
cp binder_linux.ko $(DESTDIR)/

clean:
rm -rf deps.h *.o *.ko *.mod.c *.symvers *.order .*.cmd .tmp_versions
rm -rf *.o *.ko *.mod.c *.symvers *.order .*.cmd .tmp_versions
Loading