Skip to content

Instantly share code, notes, and snippets.

@srikanth007m
srikanth007m / Compilation_2
Created January 27, 2023 05:24
Memleak eBPF compilation issue
python3 memleak.py
/virtual/main.c:217:1: warning: declaration of 'struct tracepoint__kmem__kmalloc' will not be visible outside of this function [-Wvisibility]
TRACEPOINT_PROBE(kmem, kmalloc) {
^
/virtual/include/bcc/helpers.h:874:46: note: expanded from macro 'TRACEPOINT_PROBE'
int tracepoint__##category##__##event(struct tracepoint__##category##__##event *args)
^
<scratch space>:63:1: note: expanded from here
tracepoint__kmem__kmalloc
^
@srikanth007m
srikanth007m / double free in release_user_cpus_ptr
Created October 27, 2022 11:01
32bit tasks which is being freed p->user_cpus_ptr which has been freed.
Dmesg log Call stack: object(user_mask) has been freed which in slab’s page->freelist. Sourcecode: user_mask has been freed.And user_mask is got from p->user_cpus_ptr
[71053.256528][ T535] ------------[ cut here ]------------
[71053.256537][ T535] kernel BUG at mm/slub.c:363!
[71053.261534][ T535] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[71053.268068][ T535] Skip md ftrace buffer dump for: 0xa00f50
[71053.834135][ T535] CPU: 5 PID: 535 Comm: default_npth_th Tainted: G S W OE 5.15.41 #1
[71053.843167][ T535] Hardware name: Qualcomm Technologies, Inc. 8550 socrates (DT)
[71053.850855][ T535] pstate: 62400005 (nZCv daif +PAN -UAO +TCO -DIT -SSBS BTYPE=--)
python run_all.py -f /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_finder_out -o /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_post_processing -n auto -m 0
[+] Creating your out directory for you
[+] About to run on 31 ioctl info file(s)
[+] Running on file /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/lineevent_ioctl.txt
[+] ioctl name: lineevent_ioctl
[!] Skipping lineevent_ioctl. No commands found
[+] Running on file /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/tty_ioctl.txt
[+] ioctl name: tty_ioctl
[@] Setting up a new out file: tty_io
./c2xml /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/drivers/tty/tty_io.preprocessed > /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_post_processing/tty_ioctl/xml/tty_io.xml
/local/mnt2/workspace/research_whitepaper/helper_scripts/post_processing$ python run_all.py -f /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_finder_out -o /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_post_processing -n hybrid -m 1
[+] Creating your out directory for you
[+] About to run on 31 ioctl info file(s)
[+] Running on file /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/lineevent_ioctl.txt
[+] ioctl name: lineevent_ioctl
[!] Skipping lineevent_ioctl. No commands found
[+] Running on file /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/tty_ioctl.txt
[+] ioctl name: tty_ioctl
[!] Skipping tty_ioctl. No commands found
[+] Running on file /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/linehandle_ioctl.txt
[*] Trying to Run Component: BearLLVMBuild
[+] Setup for component: BearLLVMBuild complete
[*] Writing all compilation commands to /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_build.sh
[*] Got 1634 compilation commands.
[*] Running compilation commands in multiprocessing modea.
[+] Finished running compilation commands.
[*] Writing all linker commands to /local/mnt2/workspace/kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_link_cmds.sh
[*] Got 597 regular linker commands.
[*] Running linker commands in multiprocessing mode.
[+] Finished running linker commands.
[+] About to run on 64 ioctl info file(s)
[+] Running on file kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/compat_mtp_ioctl.txt
[+] ioctl name: discovered a new reachable node %0
[!] Skipping discovered a new reachable node %0. No commands found
[+] Running on file kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/dvb_ca_en50221_io_ioctl.txt
[+] ioctl name: discovered a new reachable node %1
[!] Skipping discovered a new reachable node %1. No commands found
[+] Running on file kernel-msm-4.14/msm-4.14/out/ioctl_finder_out/linehandle_ioctl.txt
[+] ioctl name: discovered a new reachable node %0
[!] Skipping discovered a new reachable node %0. No commands found
smuppand@smuppand-linux:research_whitepaper/helper_scripts$ sudo python run_all.py -isclang -clangp llvm-6.0/bin/clang -llvmlinkp llvm-6.0/bin/llvm-link -l kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out -a 2 -c kernel-msm-4.14/msm-4.14/compile_commands.json -n 2 -k kernel-msm-4.14/msm-4.14 -f kernel-msm-4.14/msm-4.14/out/ioctl_finder_out -o kernel-msm-4.14/msm-4.14/out
[*] Trying to Run Component: BearLLVMBuild
[+] Setup for component: BearLLVMBuild complete
[*] Writing all compilation commands to kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_build.sh
[*] Got 1634 compilation commands.
[*] Running compilation commands in multiprocessing modea.
[+] Finished running compilation commands.
[*] Writing all linker commands to kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_link_cmds.sh
[*] Got 594 regular linker commands.
[*] Running linker commands in multiprocessing mode.
python run_all.py -isclang -clangp llvm-6.0/bin/clang -llvmlinkp llvm-6.0/bin/llvm-link -l kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out -a 2 -c kernel-msm-4.14/msm-4.14/compile_commands.json -n 2 -k kernel-msm-4.14/msm-4.14 -f kernel-msm-4.14/msm-4.14/out/ioctl_finder_out -o kernel-msm-4.14/msm-4.14/out
[*] Trying to Run Component: BearLLVMBuild
[+] Setup for component: BearLLVMBuild complete
[*] Writing all compilation commands to kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_build.sh
[*] Got 1634 compilation commands.
[*] Running compilation commands in multiprocessing modea.
[+] Finished running compilation commands.
[*] Writing all linker commands to kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_link_cmds.sh
[*] Got 597 regular linker commands.
[*] Running linker commands in multiprocessing mode.
sudo python run_all.py -isclang -clangp llvm/release/arm/6.0/bin/clang -llvmlinkp llvm/release/arm/6.0/bin/llvm-link -l /kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out -a 2 -c /kernel-msm-4.14/msm-4.14/compile_commands.json -n 2 -k /kernel-msm-4.14/msm-4.14 -f /kernel-msm-4.14/msm-4.14/out/ioctl_finder_out -o /kernel-msm-4.14/msm-4.14/out
[*] Trying to Run Component: BearLLVMBuild
[+] Setup for component: BearLLVMBuild complete
[*] Writing all compilation commands to /kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_build.sh
[*] Got 1634 compilation commands.
[*] Running compilation commands in multiprocessing modea.
[+] Finished running compilation commands.
[*] Writing all linker commands to /kernel-msm-4.14/msm-4.14/out/llvm_bitcode_out/llvm_link_cmds.sh
[*] Got 594 regular linker commands.
[*] Running linker commands in multiprocessing mode.
root@c2961f005ea8:/difuze/repo/helper_scripts# python run_all.py -l /androidkernels/msmkernel/out/llvm_bitcode_out -a 2 -c /androidkernels/msmkernel/compile_commands.json -g aarch64-linux-android-gcc -n 2 -k /androidkernels/msmkernel/ -f /androidkernels/msmkernel/out/ioctl_finder_out -o /androidkernels/msmkernel/out
[*] Trying to Run Component: BearLLVMBuild
[+] Setup for component: BearLLVMBuild complete
[*] Writing all compilation commands to /androidkernels/msmkernel/out/llvm_bitcode_out/llvm_build.sh
[*] Got 1349 compilation commands.
[*] Running compilation commands in multiprocessing modea.
../drivers/soc/qcom/scm.c:197:22: error: unknown register name 'r0' in asm
register u32 r0 asm("r0") = 1;
^
../drivers/soc/qcom/scm.c:198:22: error: unknown register name 'r1' in asm