<div>Hi Greg,</div><div> </div><div>Thank you for a prompt reply. My intention is to build some euristics for Intrusion detection of embedded based on sequence of syscalls.</div><div>I am collecting syscall events and send then with netlink to my monitor.</div><div>Since platform may use SELinux or other LSM, I thought the hook of syscall is the only point I can use to catch syscalls.</div><div> </div><div>Is it wrong direction ?</div><div> </div><div>I was googling and reading kernel git logs trying find out the why execve, clone, fork use assembly glue code instead of calling sys_execve like others syscalls.</div><div>Can you give me some point where to look?</div><div> </div><div>Regards.</div><div>Lev.</div><div><br /></div><div><br /></div><div>07.03.2017, 22:23, "Greg KH" &lt;greg@kroah.com&gt;:</div><blockquote type="cite"><p>On Mon, Mar 06, 2017 at 10:18:26AM +0300, Lev Olshvang wrote:<br /></p><blockquote> Hello all,<br /><br />  In kernels 3.X up to 4.2 execve(|) system call was  for x86_64 architecture the the system call was made through some <br /> magic ( I can't say I understand it ) assembly stub in arch/x86/kernel/entry_64.S<br /> so up to kernel 4.2 it was possble to patch this assembly to install the hook, ex. see <br /> <a href="http://stackoverflow.com/questions/8372912/hooking-sys-execve-on-linux-3-x/9672512#9672512">http://stackoverflow.com/questions/8372912/hooking-sys-execve-on-linux-3-x/9672512#9672512</a><br /><br /> But this hook still can't access  in a proper way filename argument, althouth I tried to do it with in the same way as <br /> fs/exec.c does : using  kernel's getname() function (which I was need to find through kallsyms_lookup_name() <br /><br /> In kernels 4.2 and up, the arch/x86/kernel/entry_64.S is gone, and I still dont' have a clue what to do to get filename as a char string.<br /></blockquote><p><br />Why do you want to hook a syscall?  that's a very complex, and broken,<br />and ill-advised thing to do.  Please don't do that.<br /><br />What problem are you trying to solve here that led you to think that<br />putting a syscall hook in is a good solution?<br /><br />thanks,<br /><br />greg k-h<br /><br />_______________________________________________<br />Kernelnewbies mailing list<br /><a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br /><a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br /></p></blockquote>