Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21772684ybl; Mon, 6 Jan 2020 10:58:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzDTTwrE9RCGDlDzDtKp+i97BhO8kk36/5JA7GNLIxY0+t+vyneWlSfC+jYyVkheDe4P/Di X-Received: by 2002:a9d:4817:: with SMTP id c23mr16990071otf.59.1578337080328; Mon, 06 Jan 2020 10:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578337080; cv=none; d=google.com; s=arc-20160816; b=1FQOZMyUv1QtNQDMPlOhA+HHOpW3xZYJOmc7wOF9HcfwP1toVESQXZOy7bPU3WFFrK QceI5WGBHKwHbU9KzUkoRtvKPjTltGr3HGcXxwz+KVrh3q8jlvLC4wvQWKk2mU4oQq4C HHSu8uI1NI1FBJXF1kbqYpVqkLsT8g60fnUdNUU/j/Xg4g+BVJV1WX5gWFmK98BtqUlm IYV6QPlmY8O5/3qGTXnELiXkosgo4wDs+lDtFtE7LsAj8R3WCstLs0LEJjueiEPo/aBF 8HlVKcGpNg+LMmZqLDDwTgENdt+5MHGf9iG803+VCxAh6cUreqrgsNl1uEaM+cH6eEN9 wKPQ== 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=mOTsYra7hwKjPKyO6CGxOhNHLDXcto4fmRUDWd5T7qE=; b=KoBPOqVAfaTXfvtLcauGv+2kas8kUEDHxzYFNQl/OZqVxZEkVMfCAT6lEvTctHUJLu XQ+knBR96hNmlX2vpargn/CHGV/SaKfP0AGwEqY1U9KnNlJDYaSmpZvr/VIgOST3hQqA HFRhTz/tqEvIMUUZYhnPbeX7l3gMhFKscObOvTU9jQG0c57Y/5mObaxDggkNvu9o1E6W 4MkJr38vhBwld+rzF8xZohaZTjO7W+Kp7nx41OCqwBVGKObYa3NZiXoc6/TNmU6rWe3k AAlsYZxHMO4g2Epg7iMBhXHDyP7mzP/cDF2OjNyZHtMe9pSSAeSl/3ZTkxpUEnZp33rt vvDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XPVtjVJQ; 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 y140si31411939oia.49.2020.01.06.10.57.48; Mon, 06 Jan 2020 10:58:00 -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=XPVtjVJQ; 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 S1726939AbgAFSz2 (ORCPT + 99 others); Mon, 6 Jan 2020 13:55:28 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:42600 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726823AbgAFSz2 (ORCPT ); Mon, 6 Jan 2020 13:55:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578336926; 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=mOTsYra7hwKjPKyO6CGxOhNHLDXcto4fmRUDWd5T7qE=; b=XPVtjVJQ0XyUEOHNr27p+KfLKUNM4fdMzGl+f39sFIBFmBz8r69Bffai8HfAIpJIHe4LZ5 V1YYJez+ixlpNm0p2exIUK8JuDp0/Fy0Lki3hJjgqGs54q16PxiebYFt3HRuCHBAlaT16v t0s26F3HfIFfufVLsQQTYsKzyWtarS0= 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-104-NikjEjsuPyu8SpU23id_Lw-1; Mon, 06 Jan 2020 13:55:25 -0500 X-MC-Unique: NikjEjsuPyu8SpU23id_Lw-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 264458EB6C0; Mon, 6 Jan 2020 18:55:24 +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 890FD5DA81; Mon, 6 Jan 2020 18:54:59 +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 4/9] audit: record nfcfg params Date: Mon, 6 Jan 2020 13:54:05 -0500 Message-Id: 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 Record the auditable parameters of any non-empty netfilter table configuration change. See: https://github.com/linux-audit/audit-kernel/issues/25 Signed-off-by: Richard Guy Briggs --- include/linux/audit.h | 11 +++++++++++ kernel/auditsc.c | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/linux/audit.h b/include/linux/audit.h index f9ceae57ca8d..96cabb095eed 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -379,6 +379,7 @@ extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, extern void __audit_fanotify(unsigned int response); extern void __audit_tk_injoffset(struct timespec64 offset); extern void __audit_ntp_log(const struct audit_ntp_data *ad); +extern void __audit_nf_cfg(const char *name, u8 af, int nentries); static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) { @@ -514,6 +515,12 @@ static inline void audit_ntp_log(const struct audit_ntp_data *ad) __audit_ntp_log(ad); } +static inline void audit_nf_cfg(const char *name, u8 af, int nentries) +{ + if (!audit_dummy_context()) + __audit_nf_cfg(name, af, nentries); +} + extern int audit_n_rules; extern int audit_signals; #else /* CONFIG_AUDITSYSCALL */ @@ -646,6 +653,10 @@ static inline void audit_ntp_log(const struct audit_ntp_data *ad) static inline void audit_ptrace(struct task_struct *t) { } + +static inline void audit_nf_cfg(const char *name, u8 af, int nentries) +{ } + #define audit_n_rules 0 #define audit_signals 0 #endif /* CONFIG_AUDITSYSCALL */ diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 4effe01ebbe2..4e1df4233cd3 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2545,6 +2545,22 @@ void __audit_ntp_log(const struct audit_ntp_data *ad) audit_log_ntp_val(ad, "adjust", AUDIT_NTP_ADJUST); } +void __audit_nf_cfg(const char *name, u8 af, int nentries) +{ + struct audit_buffer *ab; + struct audit_context *context = audit_context(); + + if (!nentries) + return; + ab = audit_log_start(context, GFP_KERNEL, AUDIT_NETFILTER_CFG); + if (!ab) + return; /* audit_panic or being filtered */ + audit_log_format(ab, "table=%s family=%u entries=%u", + name, af, nentries); + audit_log_end(ab); +} +EXPORT_SYMBOL_GPL(__audit_nf_cfg); + static void audit_log_task(struct audit_buffer *ab) { kuid_t auid, uid; -- 1.8.3.1