From owner-p4-projects@FreeBSD.ORG Wed Jul 16 22:42:37 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D497D106568F; Wed, 16 Jul 2008 22:42:36 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F7121065689 for ; Wed, 16 Jul 2008 22:42:36 +0000 (UTC) (envelope-from diego@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 6AD3F8FC26 for ; Wed, 16 Jul 2008 22:42:36 +0000 (UTC) (envelope-from diego@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m6GMgaXg032056 for ; Wed, 16 Jul 2008 22:42:36 GMT (envelope-from diego@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6GMga5x032054 for perforce@freebsd.org; Wed, 16 Jul 2008 22:42:36 GMT (envelope-from diego@FreeBSD.org) Date: Wed, 16 Jul 2008 22:42:36 GMT Message-Id: <200807162242.m6GMga5x032054@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to diego@FreeBSD.org using -f From: Diego Giagio To: Perforce Change Reviews Cc: Subject: PERFORCE change 145348 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jul 2008 22:42:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=145348 Change 145348 by diego@diego_black on 2008/07/16 22:42:24 Finish audit support for pf admin events. Affected files ... .. //depot/projects/soc2008/diego-audit/src/sys/contrib/pf/net/pf_ioctl.c#7 edit .. //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit.h#10 edit .. //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit_pfil.c#8 edit Differences ... ==== //depot/projects/soc2008/diego-audit/src/sys/contrib/pf/net/pf_ioctl.c#7 (text+ko) ==== @@ -2933,6 +2933,8 @@ error = pfr_add_addrs(&io->pfrio_table, io->pfrio_buffer, io->pfrio_size, &io->pfrio_nadd, io->pfrio_flags | PFR_FLAG_USERIOCTL); + AUDIT_CALL(audit_pf_addtable(io->pfrio_table.pfrt_anchor, + io->pfrio_table.pfrt_name, io->pfrio_nadd, error)); break; } @@ -2946,6 +2948,8 @@ error = pfr_del_addrs(&io->pfrio_table, io->pfrio_buffer, io->pfrio_size, &io->pfrio_ndel, io->pfrio_flags | PFR_FLAG_USERIOCTL); + AUDIT_CALL(audit_pf_deltable(io->pfrio_table.pfrt_anchor, + io->pfrio_table.pfrt_name, io->pfrio_ndel, error)); break; } @@ -2960,6 +2964,12 @@ io->pfrio_size, &io->pfrio_size2, &io->pfrio_nadd, &io->pfrio_ndel, &io->pfrio_nchange, io->pfrio_flags | PFR_FLAG_USERIOCTL, 0); + AUDIT_CALL(audit_pf_deltable(io->pfrio_table.pfrt_anchor, + io->pfrio_table.pfrt_name, io->pfrio_ndel + + io->pfrio_nchange, error)); + AUDIT_CALL(audit_pf_addtable(io->pfrio_table.pfrt_anchor, + io->pfrio_table.pfrt_name, io->pfrio_nadd + + io->pfrio_nchange, error)); break; } ==== //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit.h#10 (text) ==== @@ -140,6 +140,8 @@ void audit_pf_addrule(char *anchor, int nrules, int error); void audit_pf_delrule(char *anchor, int error); void audit_pf_flush(char *anchor, int nrules, int error); +void audit_pf_addtable(char *anchor, char *table, int nadd, int error); +void audit_pf_deltable(char *anchor, char *table, int ndel, int error); /* * The remaining kernel functions are conditionally compiled in as they are ==== //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit_pfil.c#8 (text+ko) ==== @@ -274,3 +274,49 @@ audit_commit(ar, error, 0); } +static void +pf_table_to_text(char *anchor, char *table, int nentries, struct sbuf *sb) +{ + sbuf_printf(sb, "pf: "); + if (anchor != NULL) + sbuf_printf(sb, "anchor=%s, ", anchor); + if (table != NULL) + sbuf_printf(sb, "table=%s, ", table); + sbuf_printf(sb, "nentries=%u", nentries); + sbuf_finish(sb); +} + +void +audit_pf_addtable(char *anchor, char *table, int nadd, int error) +{ + struct kaudit_record *ar; + struct sbuf sb; + + ar = audit_begin(AUE_PFIL_POLICY_ADDTABLE, curthread); + if (ar == NULL) + return; + + sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND); + pf_table_to_text(anchor, table, nadd, &sb); + audit_record_arg_text(ar, sbuf_data(&sb)); + sbuf_delete(&sb); + audit_commit(ar, error, 0); +} + +void +audit_pf_deltable(char *anchor, char *table, int ndel, int error) +{ + struct kaudit_record *ar; + struct sbuf sb; + + ar = audit_begin(AUE_PFIL_POLICY_DELTABLE, curthread); + if (ar == NULL) + return; + + sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND); + pf_table_to_text(anchor, table, ndel, &sb); + audit_record_arg_text(ar, sbuf_data(&sb)); + sbuf_delete(&sb); + audit_commit(ar, error, 0); +} +