Closed raffaem closed 2 years ago
Hey @raffaem, @choff has got this working up to 5.13 on his fork: https://github.com/choff/anbox-modules
I solved with this -> https://github.com/xcellerator/linux_kernel_hacking/issues/3#issue-782815541 I created this script to solve this automatically:
#!/bin/bash
cd /var/lib/dkms/;
cat > patch.c <<EOF
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kprobes.h>
#include "patch.h"
#define KPROBE_PRE_HANDLER(fname) static int __kprobes fname(struct kprobe *p, struct pt_regs *regs)
long unsigned int kln_addr = 0;
unsigned long (*kln_pointer)(const char* name) = NULL;
static struct kprobe kp0, kp1;
KPROBE_PRE_HANDLER(handler_pre0) {
kln_addr = (--regs->ip);
return 0;
}
KPROBE_PRE_HANDLER(handler_pre1) {
return 0;
}
static int do_register_kprobe(struct kprobe* kp, char* symbol_name, void* handler) {
int ret;
kp->symbol_name = symbol_name;
kp->pre_handler = handler;
ret = register_kprobe(kp);
if (ret < 0) {
pr_err("do_register_kprobe: failed to register for symbol %s, returning %d\n", symbol_name, ret);
return ret;
}
pr_info("Planted krpobe for symbol %s at %p\n", symbol_name, kp->addr);
return ret;
}
// this is the function that I have modified, as the name suggests it returns a pointer to the extracted kallsyms_lookup_name function
kln_p get_kln_p(void) {
int status;
status = do_register_kprobe(&kp0, "kallsyms_lookup_name", handler_pre0);
if (status < 0) return NULL;
status = do_register_kprobe(&kp1, "kallsyms_lookup_name", handler_pre1);
if (status < 0) {
// cleaning initial krpobe
unregister_kprobe(&kp0);
return NULL;
}
unregister_kprobe(&kp0);
unregister_kprobe(&kp1);
pr_info("kallsyms_lookup_name address = 0x%lx\n", kln_addr);
kln_pointer = (unsigned long (*)(const char* name)) kln_addr;
return kln_pointer;
}
EOF
cat > patch.h <<EOF
#ifndef PATCH_H
#define PATCH_H
typedef unsigned long (*kln_p)(const char*);
kln_p get_kln_p(void);
#endif
EOF
for path in /var/lib/dkms/anbox/{ashmem,binder}/1/source/ /var/lib/dkms/anbox-{ashmem,binder}/1/source/
do
[ ! -d ${path} ] && continue
cp patch.* ${path}
if [ -f ${path}deps.c ]; then
sed -i '0,/#include/s//#include "patch.h" \n#include/' ${path}deps.c
sed -i 's/kallsyms_lookup_name/\(\(kln_p\)get_kln_p\(\)\)/g' ${path}deps.c
fi
if [[ "$(echo ${path} | grep ashmem)" != "" ]]; then
mod=ashmem
else
mod=binder
[ -f ${path}binder.c ] && sed -i 's/mmap_sem/mmap_lock/g' ${path}binder.c
fi
[ -f ${path}Makefile ] && sed -i "0,/${mod}_linux-y :=/s//${mod}_linux-y := patch.o/" ${path}Makefile
done
rm patch.*
dkms install anbox-ashmem/1
dkms install anbox-binder/1
This fork works in 5.14 https://github.com/choff/anbox-modules
AUR too https://aur.archlinux.org/packages/anbox-modules-dkms/
Hi there - half a year later and I'm having the same problem on Pop!_OS 21.10, running kernel 5.16.11-76051611-generic
.
This fork works in 5.14 https://github.com/choff/anbox-modules
Is there a PR for this anywhere?
Hi there - half a year later and I'm having the same problem on Pop!_OS 21.10, running kernel
5.16.11-76051611-generic
.This fork works in 5.14 https://github.com/choff/anbox-modules
Is there a PR for this anywhere?
I also have this issue on Pop!_ 21.10
@raffaem did you get this fixed on your setup somehow?
I am trying to follow these instructions to get Anbox running on a Fedora 34 Workstation.
However I get errors when I try to build the kernel modules. In particular:
and that log file contains: