|
12 | 12 | #include <linux/netlink.h>
|
13 | 13 | #include <linux/vmalloc.h>
|
14 | 14 | #include <linux/rhashtable.h>
|
| 15 | +#include <linux/audit.h> |
15 | 16 | #include <linux/netfilter.h>
|
16 | 17 | #include <linux/netfilter/nfnetlink.h>
|
17 | 18 | #include <linux/netfilter/nf_tables.h>
|
@@ -693,6 +694,16 @@ static void nf_tables_table_notify(const struct nft_ctx *ctx, int event)
|
693 | 694 | {
|
694 | 695 | struct sk_buff *skb;
|
695 | 696 | int err;
|
| 697 | + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;?:0", |
| 698 | + ctx->table->name, ctx->table->handle); |
| 699 | + |
| 700 | + audit_log_nfcfg(buf, |
| 701 | + ctx->family, |
| 702 | + ctx->table->use, |
| 703 | + event == NFT_MSG_NEWTABLE ? |
| 704 | + AUDIT_NFT_OP_TABLE_REGISTER : |
| 705 | + AUDIT_NFT_OP_TABLE_UNREGISTER); |
| 706 | + kfree(buf); |
696 | 707 |
|
697 | 708 | if (!ctx->report &&
|
698 | 709 | !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
|
@@ -1428,6 +1439,17 @@ static void nf_tables_chain_notify(const struct nft_ctx *ctx, int event)
|
1428 | 1439 | {
|
1429 | 1440 | struct sk_buff *skb;
|
1430 | 1441 | int err;
|
| 1442 | + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", |
| 1443 | + ctx->table->name, ctx->table->handle, |
| 1444 | + ctx->chain->name, ctx->chain->handle); |
| 1445 | + |
| 1446 | + audit_log_nfcfg(buf, |
| 1447 | + ctx->family, |
| 1448 | + ctx->chain->use, |
| 1449 | + event == NFT_MSG_NEWCHAIN ? |
| 1450 | + AUDIT_NFT_OP_CHAIN_REGISTER : |
| 1451 | + AUDIT_NFT_OP_CHAIN_UNREGISTER); |
| 1452 | + kfree(buf); |
1431 | 1453 |
|
1432 | 1454 | if (!ctx->report &&
|
1433 | 1455 | !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
|
@@ -2693,6 +2715,17 @@ static void nf_tables_rule_notify(const struct nft_ctx *ctx,
|
2693 | 2715 | {
|
2694 | 2716 | struct sk_buff *skb;
|
2695 | 2717 | int err;
|
| 2718 | + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", |
| 2719 | + ctx->table->name, ctx->table->handle, |
| 2720 | + ctx->chain->name, ctx->chain->handle); |
| 2721 | + |
| 2722 | + audit_log_nfcfg(buf, |
| 2723 | + ctx->family, |
| 2724 | + rule->handle, |
| 2725 | + event == NFT_MSG_NEWRULE ? |
| 2726 | + AUDIT_NFT_OP_RULE_REGISTER : |
| 2727 | + AUDIT_NFT_OP_RULE_UNREGISTER); |
| 2728 | + kfree(buf); |
2696 | 2729 |
|
2697 | 2730 | if (!ctx->report &&
|
2698 | 2731 | !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
|
@@ -3695,6 +3728,17 @@ static void nf_tables_set_notify(const struct nft_ctx *ctx,
|
3695 | 3728 | struct sk_buff *skb;
|
3696 | 3729 | u32 portid = ctx->portid;
|
3697 | 3730 | int err;
|
| 3731 | + char *buf = kasprintf(gfp_flags, "%s:%llu;%s:%llu", |
| 3732 | + ctx->table->name, ctx->table->handle, |
| 3733 | + set->name, set->handle); |
| 3734 | + |
| 3735 | + audit_log_nfcfg(buf, |
| 3736 | + ctx->family, |
| 3737 | + set->field_count, |
| 3738 | + event == NFT_MSG_NEWSET ? |
| 3739 | + AUDIT_NFT_OP_SET_REGISTER : |
| 3740 | + AUDIT_NFT_OP_SET_UNREGISTER); |
| 3741 | + kfree(buf); |
3698 | 3742 |
|
3699 | 3743 | if (!ctx->report &&
|
3700 | 3744 | !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
|
@@ -4811,6 +4855,17 @@ static void nf_tables_setelem_notify(const struct nft_ctx *ctx,
|
4811 | 4855 | u32 portid = ctx->portid;
|
4812 | 4856 | struct sk_buff *skb;
|
4813 | 4857 | int err;
|
| 4858 | + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", |
| 4859 | + ctx->table->name, ctx->table->handle, |
| 4860 | + set->name, set->handle); |
| 4861 | + |
| 4862 | + audit_log_nfcfg(buf, |
| 4863 | + ctx->family, |
| 4864 | + set->handle, |
| 4865 | + event == NFT_MSG_NEWSETELEM ? |
| 4866 | + AUDIT_NFT_OP_SETELEM_REGISTER : |
| 4867 | + AUDIT_NFT_OP_SETELEM_UNREGISTER); |
| 4868 | + kfree(buf); |
4814 | 4869 |
|
4815 | 4870 | if (!ctx->report && !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
|
4816 | 4871 | return;
|
@@ -5892,6 +5947,19 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
5892 | 5947 | obj->ops->type->type != filter->type)
|
5893 | 5948 | goto cont;
|
5894 | 5949 |
|
| 5950 | + if (reset) { |
| 5951 | + char *buf = kasprintf(GFP_KERNEL, |
| 5952 | + "%s:%llu;?:0", |
| 5953 | + table->name, |
| 5954 | + table->handle); |
| 5955 | + |
| 5956 | + audit_log_nfcfg(buf, |
| 5957 | + family, |
| 5958 | + obj->handle, |
| 5959 | + AUDIT_NFT_OP_OBJ_RESET); |
| 5960 | + kfree(buf); |
| 5961 | + } |
| 5962 | + |
5895 | 5963 | if (nf_tables_fill_obj_info(skb, net, NETLINK_CB(cb->skb).portid,
|
5896 | 5964 | cb->nlh->nlmsg_seq,
|
5897 | 5965 | NFT_MSG_NEWOBJ,
|
@@ -6002,6 +6070,17 @@ static int nf_tables_getobj(struct net *net, struct sock *nlsk,
|
6002 | 6070 | if (NFNL_MSG_TYPE(nlh->nlmsg_type) == NFT_MSG_GETOBJ_RESET)
|
6003 | 6071 | reset = true;
|
6004 | 6072 |
|
| 6073 | + if (reset) { |
| 6074 | + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;?:0", |
| 6075 | + table->name, table->handle); |
| 6076 | + |
| 6077 | + audit_log_nfcfg(buf, |
| 6078 | + family, |
| 6079 | + obj->handle, |
| 6080 | + AUDIT_NFT_OP_OBJ_RESET); |
| 6081 | + kfree(buf); |
| 6082 | + } |
| 6083 | + |
6005 | 6084 | err = nf_tables_fill_obj_info(skb2, net, NETLINK_CB(skb).portid,
|
6006 | 6085 | nlh->nlmsg_seq, NFT_MSG_NEWOBJ, 0,
|
6007 | 6086 | family, table, obj, reset);
|
@@ -6077,6 +6156,16 @@ void nft_obj_notify(struct net *net, const struct nft_table *table,
|
6077 | 6156 | {
|
6078 | 6157 | struct sk_buff *skb;
|
6079 | 6158 | int err;
|
| 6159 | + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;?:0", |
| 6160 | + table->name, table->handle); |
| 6161 | + |
| 6162 | + audit_log_nfcfg(buf, |
| 6163 | + family, |
| 6164 | + obj->handle, |
| 6165 | + event == NFT_MSG_NEWOBJ ? |
| 6166 | + AUDIT_NFT_OP_OBJ_REGISTER : |
| 6167 | + AUDIT_NFT_OP_OBJ_UNREGISTER); |
| 6168 | + kfree(buf); |
6080 | 6169 |
|
6081 | 6170 | if (!report &&
|
6082 | 6171 | !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
|
@@ -6856,6 +6945,17 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx,
|
6856 | 6945 | {
|
6857 | 6946 | struct sk_buff *skb;
|
6858 | 6947 | int err;
|
| 6948 | + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;%s:%llu", |
| 6949 | + flowtable->table->name, flowtable->table->handle, |
| 6950 | + flowtable->name, flowtable->handle); |
| 6951 | + |
| 6952 | + audit_log_nfcfg(buf, |
| 6953 | + ctx->family, |
| 6954 | + flowtable->hooknum, |
| 6955 | + event == NFT_MSG_NEWFLOWTABLE ? |
| 6956 | + AUDIT_NFT_OP_FLOWTABLE_REGISTER : |
| 6957 | + AUDIT_NFT_OP_FLOWTABLE_UNREGISTER); |
| 6958 | + kfree(buf); |
6859 | 6959 |
|
6860 | 6960 | if (ctx->report &&
|
6861 | 6961 | !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
|
@@ -6977,6 +7077,9 @@ static void nf_tables_gen_notify(struct net *net, struct sk_buff *skb,
|
6977 | 7077 | struct sk_buff *skb2;
|
6978 | 7078 | int err;
|
6979 | 7079 |
|
| 7080 | + audit_log_nfcfg("?:0;?:0", 0, net->nft.base_seq, |
| 7081 | + AUDIT_NFT_OP_GEN_REGISTER); |
| 7082 | + |
6980 | 7083 | if (nlmsg_report(nlh) &&
|
6981 | 7084 | !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
|
6982 | 7085 | return;
|
|
0 commit comments