Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21772581ybl; Mon, 6 Jan 2020 10:57:49 -0800 (PST) X-Google-Smtp-Source: APXvYqzHCty8JFaEuajILabO2xPJ++424Iq3KIrTIur3U7unRRbgXF2sobR1KwjRVaagtb3KSauZ X-Received: by 2002:a9d:67c1:: with SMTP id c1mr82717790otn.161.1578337069834; Mon, 06 Jan 2020 10:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578337069; cv=none; d=google.com; s=arc-20160816; b=IM/Ygpw+hvdGH3a5u2tQWYzVN20iPvqM29uE0cUMtsBBNZALTRjl3Ln3nyRNXDU2tt gYiUuR7dQxB0N63lbhPo01jBI3i1S+y2ZVQfU9fnrDp3F5zlG8vGDZ3JEx/VSje8r3On AyNViTr7sko0/zxFswu/xVo0G3nTpEyX3n39rgHYjXYugfVrUXShLvgvN45OmFYa0SZy hzgL+mibOeZPmL5lCLh28pAI5xkVL8xlLQAzY9J2NkC/qaiIOUocGJcKBsGRpHa4aZnf JHaCljgGP+i+gNnh9ZBKr661nOQvdnW1EMI9AMGacvB2R8q1XastJnj8j/+PzFVQ9Bwa a0hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=DWXFKSOUzkRcgpCgfN3PkqlzQm42xZwQFxY49CXWt+A=; b=eNpaRVJj+mpKaw6i6w33Miji5KzW24bLg50cVBhCeFuSLe7XoBjcQXdFWmS4gSW22y orQKAnBnEvtaOlckDfLOcU7UNBGGNeQEItubXLGhl1/p1wumQl1F9khCjUFiRhxO2cmX 6zPU7GQtO8YBO07AKzbrzspo15FYoi6WtByNkwr0yXwp1fSSdkhFqieZiQpWrmspLUrk /KIypKceng/mQmEsTMcqFsO2M07148b4C9/AQt+5JOZk5JgJ8hNoR23n1vMzVnv+jyy4 byYcBqHp5gghz7GphYH45fvBKXgWLsbHVLeCo6QFDwKvIMt64qvlzy4kv2WEZgbb5yAL oCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YFQfg+kE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 88si33248325otr.81.2020.01.06.10.57.37; Mon, 06 Jan 2020 10:57:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YFQfg+kE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbgAFS41 (ORCPT + 99 others); Mon, 6 Jan 2020 13:56:27 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22592 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726793AbgAFS40 (ORCPT ); Mon, 6 Jan 2020 13:56:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578336985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:in-reply-to: references:references:references; bh=DWXFKSOUzkRcgpCgfN3PkqlzQm42xZwQFxY49CXWt+A=; b=YFQfg+kEJ8RJMkegNWz+dx8KVvQ8m1HXy89wtzuebOwuiNiTnY0jKX5vkLE4bPjT3he4Pm g3LUH4LcJ4SQ5/aTkh4L4sLEKQBvio39GPM1RJLyWroix0juZyueaOifd7nvRKjdgtC7Md JCc2swZV/QdY+bm2MKw/H8R9waLdJsk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-g7QKIePsM42r8CFLX5OFyg-1; Mon, 06 Jan 2020 13:56:22 -0500 X-MC-Unique: g7QKIePsM42r8CFLX5OFyg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CEE9B102C867; Mon, 6 Jan 2020 18:56:20 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-34.phx2.redhat.com [10.3.112.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7B165D9E1; Mon, 6 Jan 2020 18:56:15 +0000 (UTC) From: Richard Guy Briggs To: Linux-Audit Mailing List , LKML , netfilter-devel@vger.kernel.org Cc: Paul Moore , sgrubb@redhat.com, omosnace@redhat.com, fw@strlen.de, twoerner@redhat.com, eparis@parisplace.org, ebiederm@xmission.com, tgraf@infradead.org, Richard Guy Briggs Subject: [PATCH ghak25 v2 9/9] netfilter: audit table unregister actions Date: Mon, 6 Jan 2020 13:54:10 -0500 Message-Id: <65974a7254dffe53b5084bedfd60c95a29a41e08.1577830902.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Audit the action of unregistering ebtables and x_tables. See: https://github.com/linux-audit/audit-kernel/issues/44 Signed-off-by: Richard Guy Briggs --- kernel/auditsc.c | 3 ++- net/bridge/netfilter/ebtables.c | 3 +++ net/netfilter/x_tables.c | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 999ac184246b..2644130a9e66 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2557,7 +2557,8 @@ void __audit_nf_cfg(const char *name, u8 af, int nentries, int op) return; /* audit_panic or being filtered */ audit_log_format(ab, "table=%s family=%u entries=%u op=%s", name, af, nentries, - op ? "replace" : "register"); + op == 1 ? "replace" : + (op ? "unregister" : "register")); audit_log_end(ab); } EXPORT_SYMBOL_GPL(__audit_nf_cfg); diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index baff2f05af43..3dd4eb5b13fd 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1126,6 +1126,9 @@ static void __ebt_unregister_table(struct net *net, struct ebt_table *table) mutex_lock(&ebt_mutex); list_del(&table->list); mutex_unlock(&ebt_mutex); + if (audit_enabled) + audit_nf_cfg(table->name, AF_BRIDGE, table->private->nentries, + 2); EBT_ENTRY_ITERATE(table->private->entries, table->private->entries_size, ebt_cleanup_entry, net, NULL); if (table->private->nentries) diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 4ae4f7bf8946..e4852a0cb62f 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1403,7 +1403,7 @@ struct xt_table_info *xt_replace_table(struct xt_table *table, if (audit_enabled) audit_nf_cfg(table->name, table->af, private->number, - private->number); + !!private->number); return private; } @@ -1466,6 +1466,8 @@ void *xt_unregister_table(struct xt_table *table) private = table->private; list_del(&table->list); mutex_unlock(&xt[table->af].mutex); + if (audit_enabled) + audit_nf_cfg(table->name, table->af, private->number, 2); kfree(table); return private; -- 1.8.3.1