Article 5SVJY Writing a kernel module in order to catch a SIGSEGV

Writing a kernel module in order to catch a SIGSEGV

by
F0rgh1
from LinuxQuestions.org on (#5SVJY)
I need some help to understand how linux detect programs crash and to write a kernel module in order to catch a SIGSEGV. I have been working on OPTEE-OS (see the image at the bottom) and when a program, which is running on the RICH OS (in my case linux), crashes for some reason i need to forward the crash detected to the OPTEE Trustzone. I do not need to forward crash details or core dump file to the TrustZone but only that the process with pid XXXXXX crashed.
I know SIGSEGV is caught by the MMU causing an interrupt and that interrupt is handled by the kernel, which sends a SIGSEGFAULT signal to the process. So i was wondering how can i detect the SIGSEGV of the given program by using a kernel module ?

By reading some online forums I stumbled across sys_rt_sigaction system call, however it seems not to be a good practice to use sys_* family of functions in kernel space.

For instance by starting with a simple .c code

Code:void foo(int *p) {
*p = 1;
}
int main(int argc, char **argv) {
int *p = NULL;
foo(p);
}which returns a Segmentation Fault my questions are:
  • Which linux kernel module detect the SIGSEGV fault ?
  • Is there any example from which i can start in order to write my own kernel module?
https://www.google.com/search?q=opte...wRJtSpeX-FPCnMlatest?d=yIl2AUoC8zA latest?i=ARCJHkzYHuw:7-luWkAx5GU:F7zBnMy latest?i=ARCJHkzYHuw:7-luWkAx5GU:V_sGLiP latest?d=qj6IDK7rITs latest?i=ARCJHkzYHuw:7-luWkAx5GU:gIN9vFw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments