Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

434
Views
¿Cómo interceptar correctamente las llamadas al sistema en el kernel de Linux 5.*?

Existía la necesidad de escribir un módulo kernel, con un enlace para exec. Encontré una manera con sys_calls_table y lsm . Según tengo entendido, sys_calls_table es más un truco que una solución correcta, y no encontré ejemplos normales para lsm .

¿Cómo interceptar correctamente una llamada al sistema en versiones modernas del kernel? Estaré muy contento con los ejemplos.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No hay una manera correcta de hacer esto.

LSM (Módulos de seguridad de Linux) no admite la interceptación de llamadas del sistema, con LSM necesita implementar algunas de las funciones enumeradas en lsm_hooks_defs.h .

Hay dos formas alternativas de interceptar llamadas al sistema que conozco:

  1. Enganche la sys_call_table que se puede obtener y sobrescriba los punteros con su nueva función:

     unsigned long *sys_call_table_ptr = kallsyms_lookup_name("sys_call_table"); unsigned long cr0 = read_cr0(); write_cr0(cr0 & ~x86_CR0_WP); sys_call_table_ptr[__NR_getpid] = new_getpid; write_cr0(cr0);
  2. Uso de kprobe: el nombre de las funciones de Syscall se expande con el prefijo __do_sys_ (consulte __SYSCALL_DEFINEx ). Por ejemplo, kprobe en __do_sys_finit_module (o cualquier otra llamada al sistema que desee) de la siguiente manera:

     static struct kprobe kp = { .symbol_name = "__do_sys_finit_module", }; static int handler_pre(struct kprobe *p, struct pt_regs *regs) { // do your logic // obtain function arguments using register (calling convetion) } static int __init kprobe_init(void) { kp.pre_handler = handler_pre; ret = register_kprobe(&kp); if (ret < 0) { printk(KERN_INFO "register_kprobe failed, returned %d\n", ret); return ret; } printk(KERN_INFO "Planted kprobe at %p\n", kp.addr); return 0; } static void __exit kprobe_exit(void) { unregister_kprobe(&kp); printk(KERN_INFO "kprobe at %p unregistered\n", kp.addr); }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!