This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 230
Compatibility with kernels >= 5.7 #76
Open
choff
wants to merge
26
commits into
anbox:master
Choose a base branch
from
choff:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 443f984
Compile fixes for kernel >= 5.8
choff 6ddae19
Another compile fix for kernel >= 5.8
choff 0338a34
Update binder to the latest version
choff 516144c
Compile fixes for kernels 5.11, 5.12 & 5.13
choff b0c3c5a
compilation fix for kernel 5.15.2
modscleo4 8148a16
sync with android binder.c
modscleo4 2699623
patches for 5.18 kernel
Etaash-mathamsetty 6844495
Patches for kernel 5.19
Thesola10 2325d6f
Fixed page fault by matching in-tree binder behavior
Thesola10 cd66055
Fix build on 6.0 kernel
arenekosreal 42335c6
Fix build on 6.1 kernel
arenekosreal ab8278c
Add TASK_FREEZABLE
arenekosreal a961389
fix for kernel 6.1
munix9 ae26ba2
Create UNINSTALL.sh script and update README.md
SonarBeserk 44dc351
Update README.md
Krishnakumar59 abead1d
Fixes for kernel 6.3+
Thesola10 205c803
Fix build for kernel 6.6
arenekosreal 41fe6db
Fix build for 6.6
084d199
Added conditional matching for kernels >= 6.3.0
13a93a4
Fix for kernel 6.7+
ssfdust 44e5ba7
Fixes for kernel 6.8
ssfdust b558310
removed obsolete name="%k", added binder symlink (#1)
PuspenduBanerjee dcd52bf
Added packaging guide and compat fix
PuspenduBanerjee 2c06452
updated doc to update changelog from git commits
PuspenduBanerjee ee4c25f
fix creation of all 3 anbox modules symlinks: anbox-binder anbox-hwbi…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
.