<div dir="ltr">Hi Everyone,<br><br>I wanted some help in better understanding the workflow of file system auditing(watch rules) vs Syscall Auditing(syscall rules). I know in general file system auditing does not have the same performance impact as syscall auditing, even though both make use of syscall exits for their evaluation.<div><br></div><div><br></div><div><font face="arial, sans-serif">From the manpage - "<span style="color:rgb(68,68,68)">Unlike most syscall auditing rules, watches do not impact performance based on the number of rules sent to the kernel."</span></font></div><div><font face="arial, sans-serif"><span style="color:rgb(68,68,68)"><br></span></font></div><div><font face="arial, sans-serif"><span style="color:rgb(68,68,68)">From a previous thread, I found this excerpt regarding file watch rules vs sycall rules - <br></span></font><span style="color:rgb(66,66,66);font-size:12.8px;white-space:pre-wrap"><font face="Roboto Mono, monospace">
</font><font face="arial, sans-serif">"The reason it doesn't have performance impact like normal syscall rules is </font></span></div><span style="color:rgb(66,66,66);font-size:12.8px;white-space:pre-wrap"><font face="arial, sans-serif">because it gets moved to a list that is not evaluated every syscall. A normal 
syscall rule will get evaluated for every syscall because it has to see if the 
syscall number is of interest and then it checks the next rule."</font></span><div><font color="#424242" face="arial, sans-serif"><span style="font-size:12.8px;white-space:pre-wrap"><br></span></font></div><div><font color="#424242" face="arial, sans-serif"><span style="font-size:12.8px;white-space:pre-wrap">Based on this I had a couple of questions:</span></font></div><div><font color="#424242" face="arial, sans-serif"><span style="font-size:12.8px;white-space:pre-wrap"><br></span></font></div><div><font color="#424242" face="arial, sans-serif"><span style="font-size:12.8px;white-space:pre-wrap"> For normal syscall rules, the evaluation happens as </span></font><a href="https://elixir.bootlin.com/linux/v6.1.10/C/ident/__audit_syscall_exit" style="font-family:"Ubuntu Mono",monospace;font-size:0.9em;background:linear-gradient(rgba(0,0,0,0) 10%,rgb(244,246,255) 10%,rgb(244,246,255) 90%,rgba(0,0,0,0) 90%);box-sizing:inherit;color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">__audit_syscall_exit</a> calls audit_filter_syscall<br>(<a href="https://elixir.bootlin.com/linux/v6.1.10/source/kernel/auditsc.c#L841">https://elixir.bootlin.com/linux/v6.1.10/source/kernel/auditsc.c#L841</a>)<br><br>Here, we check if the syscall is of interest or not in the <a href="https://elixir.bootlin.com/linux/v6.1.10/C/ident/audit_in_mask" style="font-family:"Ubuntu Mono",monospace;font-size:0.9em;background:linear-gradient(rgba(0,0,0,0) 10%,rgb(244,246,255) 10%,rgb(244,246,255) 90%,rgba(0,0,0,0) 90%);box-sizing:inherit;color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">audit_in_mask</a> function. Only if the syscall is of interest do we proceed with examining the task and return on the first rule match.</div><div><br></div><div>1. What is the process or code path for watch rules? <a href="https://elixir.bootlin.com/linux/v6.1.10/C/ident/audit_filter_syscall" style="font-family:"Ubuntu Mono",monospace;font-size:0.9em;background:linear-gradient(rgba(0,0,0,0) 10%,rgb(244,246,255) 10%,rgb(244,246,255) 90%,rgba(0,0,0,0) 90%);box-sizing:inherit;color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em;border-bottom:1px dotted rgb(0,0,0)">audit_filter_syscall</a> is called for watch rules as well. Then how is it that these are not called for every syscall? Could you point me to the code where the evaluation happens only once?<br><br>2. Also, do file watches only involve the open system call family (open, openat etc). The man page implies the same, so just wanted to confirm.<br><br>I assume -w /etc -p wa is the same as -a always,exit -S open -S openat -F dir=/etc?</div><div><br></div><div>Please correct any wrong assumption I may have as well.<br><br>Regards<br><br><br><br><div><br></div></div></div>