Compatibility with kernels >= 5.7 by choff · Pull Request #76 · anbox/anbox-modules

added 3 commits

March 8, 2021 20:19
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 binder 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.
With the commit 64fe66e8a95e in the Linux kernel, the member "mmap_sem" in the
struct mm_struct was renamed to "mmap_lock". This patch fixes the resulting
compile errors.
With kernel 5.8, the return value of map_kernel_range_noflush()
was changed. This function now returns 0 on success (instead of
the number of successfully mapped pages).

This commit adjusts binder accordingly.

@choff choff mentioned this pull request

Mar 8, 2021

@choff

Over the last years, many fixes and changes have been applied to
Binder in the Linux kernel, but these fixes were never backported
to anbox-modules. The meant that the version of Binder in anbox-modules
was very outdated.

With this commit, Binder has been update to the latest state from
the Linux kernel. This should also fix the compile on kernel 5.12
and later.

@choff

Linux 5.15.2 updated security.h  security_binder_* functions (like security_binder_transfer_binder(), so it uses struct cred* instead of struct task_struct*)

@modscleo4 @choff

@arenekosreal @choff

@arenekosreal @choff

@arenekosreal @choff

@munix9 @choff

@SonarBeserk @choff

@Krishnakumar59 @choff

@Thesola10 @choff

@arenekosreal @choff

@choff

@choff

* Use shrinker pointer instead of shrink struct for 6.7+, due to the `shrinker_alloc` function always return the pointer.
* Most of the codes are stolen from drivers/android/binder_alloc.c

@ssfdust @choff

* removed obsolete name="%k", added binder symlink

* removed obsolete name="%k", added binder symlink
Added packaging guide and compat fix

@PuspenduBanerjee @choff

@choff

@llyyr @choff

@llyyr @choff

@llyyr @choff

@munix9 @choff