Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audit.log did not print when --seccomp-error-action is EPERM #3498

Closed
sfc-gh-hyu opened this issue Jul 6, 2020 · 5 comments
Closed

audit.log did not print when --seccomp-error-action is EPERM #3498

sfc-gh-hyu opened this issue Jul 6, 2020 · 5 comments

Comments

@sfc-gh-hyu
Copy link
Contributor

When a system call is violated, and error action is kill, I can see audit.log has an entry indicating the error

sudo ausearch -m SECCOMP --interpret

and

type=SECCOMP msg=audit(07/06/2020 20:17:03.365:18387) : auid=hyu uid=hyu gid=hyu ses=1 pid=9120 comm=<program> sig=SIGSYS arch=x86_64 syscall=stat compat=0 ip=0x7f420b9db5b5 code=kill

However, when the --seccomp-error-action=EPERM, the audit.log did not have an entry.

I also checked

[hyu@DEVVM-hyu trunk]$ cat /proc/sys/kernel/seccomp/actions_logged 
kill trap errno trace

And it seems that errno should be logged. Maybe there is a flag that should be added when configuring seccomp?

@rusty-snake
Copy link
Collaborator

This is expected AFAIK.
I wonder for what it is useful. For debugging you can still set it to kill. Are there any drawback when it is not logged?

PR for the kill-> EPERM change: #3301

@sfc-gh-hyu
Copy link
Contributor Author

I want to use EPERM in production but keep audit logging for audit purpose. Is that possible? Our production environment has some utility which allow me to easily query audit log on each host, so I think it would be nice to have seccomp logging.

@rusty-snake
Copy link
Collaborator

Is that possible?

I'm no expert, but I would think it's possible. @topimiettinen can say more.

I want to use EPERM in production but keep audit logging for audit purpose. … Our production environment has some utility which allow me to easily query audit log on each host, so I think it would be nice to have seccomp logging.

I see your point. However, keep in mind that the reason for the change (kill->EPERM) was to block syscalls while allowing the application to continue to work. i.e. audit-logs can be "false-positives", which don't need to be allowed. Which in turn can result in a lot of audit-spam.

@sfc-gh-hyu
Copy link
Contributor Author

I think this is fine. My usecase is running untrusted user code inside firejail. And need to return a nice user error back when seccomp rule is violated. So application continues runnning just to report error back and stop, which won't spam the audit.log. If you don't want audit logging to be default behavior, is it possible to add an option for that?

@topimiettinen
Copy link
Collaborator

You may need to edit auditd configuration to enable logging for failed system calls. Something like this (taken from /etc/audit/rules.d/30-nispom.rules) would log every time open etc. fail with EACCES or EPERM:

-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F exit=-EACCES -F key=open
-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F exit=-EACCES -F key=open
-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F exit=-EPERM -F key=open
-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F exit=-EPERM -F key=open

But this also means that it also logs every time an unrelated program gets these errors, so logs may fill up quickly.

Maybe you could use instead a rare error code like ENAVAIL ("No XENIX semaphores available", lol) like --seccomp-error-action=ENAVAIL and match that with audit rules instead of EPERM. Though this may confuse applications which may not expect such weird error codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants