Get the sys_call_num within an LKM

MySprtlty·2024년 2월 1일
0

LKM

목록 보기
5/10

🏷️Get the sys_call_num within an LKM

📌Check the sys_call_num

  • sys_call_num depends on the architecture of the system.
  • gcc 전처리 옵션을 사용하여 매크로 확장이 어떻게 이루어 지는지 확인할 수 있다.
printf SYS_read | gcc -include sys/syscall.h -E -

# 0 "<stdin>"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "/usr/include/sys/syscall.h" 1 3 4
# 24 "/usr/include/sys/syscall.h" 3 4
# 1 "/usr/include/asm/unistd.h" 1 3 4
# 20 "/usr/include/asm/unistd.h" 3 4
# 1 "/usr/include/asm/unistd_64.h" 1 3 4
# 21 "/usr/include/asm/unistd.h" 2 3 4
# 25 "/usr/include/sys/syscall.h" 2 3 4

# 1 "/usr/include/bits/syscall.h" 1 3 4
# 30 "/usr/include/sys/syscall.h" 2 3 4
# 0 "<command-line>" 2
# 1 "<stdin>"

# 1 "<stdin>" 3 4
0
  • 마지막으로 출력된 번호가 SYS_read의 sys_call_num

📌Get the sys_call_num

  • x86_64 system calls in /usr/include/asm/unistd_64.h
  • sys_read번호는 __NR_read 매크로로 정의되어 있기 때문에, lkm에서 위 매크로를 사용하면 된다.
profile
2Co 4:7

0개의 댓글