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

Fix audit rule removal upon osquery exit #7221

Merged
merged 1 commit into from
Aug 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions osquery/events/linux/auditdnetlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,14 @@ bool AuditdNetlinkReader::configureAuditService() noexcept {
LOG(ERROR) << "Failed to install the audit rule due to one or more "
<< "syscalls with error " << audit_errno_to_name(rule_add_error)
<< ", Audit-based tables may not function as expected";

} else if (FLAGS_audit_debug) {
VLOG(1) << "Audit rule installed for all queued syscalls";
}

if (FLAGS_audit_force_unconfigure) {
if (FLAGS_audit_force_unconfigure || rule_add_error >= 0) {
// keep a track of the rule even if installing it failed when asked to
// forcefully unconfigure.
installed_rule_list_.push_back(rule);
}

Expand Down Expand Up @@ -578,8 +581,12 @@ void AuditdNetlinkReader::restoreAuditServiceConfiguration() noexcept {
VLOG(1) << "Uninstalling the audit rules we have installed";

for (auto& rule : installed_rule_list_) {
audit_delete_rule_data(
int rule_delete_error = audit_delete_rule_data(
audit_netlink_handle_, &rule, AUDIT_FILTER_EXIT, AUDIT_ALWAYS);
if (FLAGS_audit_debug && rule_delete_error < 0) {
VLOG(1) << "Error code returned by delete rule "
<< audit_errno_to_name(rule_delete_error);
}
}

installed_rule_list_.clear();
Expand Down