Skip to content

ausearch fails to load symlinked config file #484

@LordGrimmauld

Description

@LordGrimmauld

I started running the audit-testsuite against the NixOS auditd module to try and make stuff work properly. Currently, our audit runs but is broken in a couple subtle ways. Particularly, it does load the config at /etc/audit/auditd.conf, despite it being a symlink! Edit: we do pass -l, this is intended.

One thing i found:

vm-test-run-auditd> machine # Error opening config file (Too many levels of symbolic links)
vm-test-run-auditd> machine # NOTE - using built-in end_of_event_timeout: 2
vm-test-run-auditd> machine # NOTE - using built-in logs: /var/log/audit/audit.log

I suspect part of the issue is in here:

mode = O_RDONLY;
rc = open(file, mode);

if (fstat(fd, &st) < 0) {

if (!S_ISREG(st.st_mode)) {

There is no O_NOFOLLOW, and the stat syscall is fstat, not lstat, which means it doesn't actually check whether the config file is a symlink.

However, the error code (Too many levels of symbolic links) comes from the kernel:
https://github.com/linux-audit/audit-kernel/blob/729b4babd69517766ae39e21902caa810625e247/net/9p/error.c#L80

This suggests something is actually using O_NOFOLLOW, see the open manual page:

O_NOFOLLOW If path names a symbolic link, fail and set errno to [ELOOP].

I'll either have to patch the kernel module, or patch the userspace audit daemon to pass an absolute path to the kernel. Not sure which of the two options would be better.
Edit: Needs set_allow_links in the ausearch tool to correctly load config, or else O_NOFOLLOW is added.

After #467, plugins from symlinks works. Config from symlinks not working is a little surprising, because until i ran the kernel test suite this never actually complained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions