Skip to content

Commit 4c0b60b

Browse files
committed
Add ARP hook name recognition
Added an ARP netfilter hook table mapping numeric values to INPUT, OUTPUT, and FORWARD for audit interpretation. Extended the build system and test suite to generate and exercise the new ARP hook translations alongside existing inet hooks. Updated print_hook to detect the surrounding record’s netfilter family and choose the proper ARP or inet hook name accordingly.
1 parent 07db54e commit 4c0b60b

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed

auparse/Makefile.am

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ BUILT_SOURCES = accesstabs.h captabs.h clocktabs.h clone-flagtabs.h \
6565
seektabs.h shm_modetabs.h signaltabs.h sockoptnametabs.h \
6666
socktabs.h sockleveltabs.h socktypetabs.h \
6767
tcpoptnametabs.h typetabs.h umounttabs.h inethooktabs.h \
68-
netactiontabs.h \
68+
arphooktabs.h netactiontabs.h \
6969
normalize_obj_kind_maps.h normalize_record_maps.h \
7070
normalize_syscall_maps.h normalize_evtypetabs.h bpftabs.h \
7171
openat2-resolvetabs.h xattr-atflagtabs.h access-flagtabs.h
@@ -83,7 +83,7 @@ noinst_PROGRAMS = gen_accesstabs_h gen_captabs_h gen_clock_h \
8383
gen_seektabs_h gen_shm_modetabs_h gen_signals_h \
8484
gen_sockoptnametabs_h gen_socktabs_h gen_sockleveltabs_h \
8585
gen_socktypetabs_h gen_tcpoptnametabs_h gen_typetabs_h \
86-
gen_umounttabs_h gen_inethooktabs_h gen_netactiontabs_h \
86+
gen_umounttabs_h gen_inethooktabs_h gen_arphooktabs_h gen_netactiontabs_h \
8787
gen_normalize_record_map gen_normalize_syscall_map \
8888
gen_normalize_obj_kind_map gen_normalize_evtypetabs_h gen_bpftabs_h \
8989
gen_openat2-resolvetabs_h gen_xattr-atflagtabs_h gen_access-flagtabs_h
@@ -705,3 +705,16 @@ gen_openat2-resolvetabs_h$(BUILD_EXEEXT): LDFLAGS=$(LDFLAGS_FOR_BUILD)
705705
openat2-resolvetabs.h: gen_openat2-resolvetabs_h Makefile
706706
./gen_openat2-resolvetabs_h --i2s-transtab openat2_resolve > $@
707707

708+
709+
gen_arphooktabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h arphooktab.h
710+
gen_arphooktabs_h_CFLAGS = '-DTABLE_H="arphooktab.h"'
711+
$(gen_arphooktabs_h_OBJECTS): CC=$(CC_FOR_BUILD)
712+
$(gen_arphooktabs_h_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD)
713+
$(gen_arphooktabs_h_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
714+
$(gen_arphooktabs_h_OBJECTS): LDFLAGS=$(LDFLAGS_FOR_BUILD)
715+
gen_arphooktabs_h$(BUILD_EXEEXT): CC=$(CC_FOR_BUILD)
716+
gen_arphooktabs_h$(BUILD_EXEEXT): CFLAGS=$(CFLAGS_FOR_BUILD)
717+
gen_arphooktabs_h$(BUILD_EXEEXT): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
718+
gen_arphooktabs_h$(BUILD_EXEEXT): LDFLAGS=$(LDFLAGS_FOR_BUILD)
719+
arphooktabs.h: gen_arphooktabs_h Makefile
720+
./gen_arphooktabs_h --i2s arphook > $@

auparse/interpret.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "internal.h"
2828
#include "interpret.h"
2929
#include "auparse-idata.h"
30+
#include "auparse.h"
3031
#include "nvlist.h"
3132
#include <stddef.h>
3233
#include <stdio.h>
@@ -45,6 +46,7 @@
4546
#include <linux/atm.h>
4647
#include <linux/x25.h>
4748
#include <linux/capability.h>
49+
#include <linux/netfilter.h>
4850
#include <sys/personality.h>
4951
#include <sys/prctl.h>
5052
#include <sched.h>
@@ -123,6 +125,7 @@
123125
#include "umounttabs.h"
124126
#include "ioctlreqtabs.h"
125127
#include "inethooktabs.h"
128+
#include "arphooktabs.h"
126129
#include "netactiontabs.h"
127130
#include "bpftabs.h"
128131
#include "openat2-resolvetabs.h"
@@ -3011,12 +3014,14 @@ static const char *print_protocol(const char *val)
30113014
return out;
30123015
}
30133016

3014-
/* FIXME - this assumes inet hook. Could also be an arp hook */
3015-
static const char *print_hook(const char *val)
3017+
/* Netfilter hook names */
3018+
static const char *print_hook(auparse_state_t *au, const char *val)
30163019
{
30173020
int hook;
30183021
char *out;
30193022
const char *str;
3023+
const char *fam;
3024+
int proto = -1;
30203025

30213026
errno = 0;
30223027
hook = strtoul(val, NULL, 16);
@@ -3025,7 +3030,21 @@ static const char *print_hook(const char *val)
30253030
out = NULL;
30263031
return out;
30273032
}
3028-
str = inethook_i2s(hook);
3033+
3034+
fam = auparse_find_field(au, "family");
3035+
if (fam) {
3036+
errno = 0;
3037+
proto = strtoul(fam, NULL, 10);
3038+
if (errno)
3039+
proto = -1;
3040+
}
3041+
auparse_find_field(au, "hook");
3042+
3043+
if (proto == NFPROTO_ARP)
3044+
str = arphook_i2s(hook);
3045+
else
3046+
str = inethook_i2s(hook);
3047+
30293048
if (str == NULL) {
30303049
if (asprintf(&out, "unknown-hook(%s)", val) < 0)
30313050
out = NULL;
@@ -3521,7 +3540,7 @@ char *auparse_do_interpretation(auparse_state_t *au, int type, const idata *id,
35213540
out = print_proctitle(id->val);
35223541
break;
35233542
case AUPARSE_TYPE_HOOK:
3524-
out = print_hook(id->val);
3543+
out = print_hook(au, id->val);
35253544
break;
35263545
case AUPARSE_TYPE_NETACTION:
35273546
out = print_netaction(id->val);

auparse/test/lookup_test.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ test_icmptypetab(void)
185185
#undef I2S
186186
}
187187

188+
#include "../arphooktabs.h"
189+
static void
190+
test_arphooktab(void)
191+
{
192+
static const struct entry t[] = {
193+
#include "../arphooktab.h"
194+
};
195+
196+
printf("Testing arphooktab...\n");
197+
#define I2S(I) arphook_i2s(I)
198+
TEST_I2S(0);
199+
#undef I2S
200+
}
201+
188202
#include "../inethooktabs.h"
189203
static void
190204
test_inethooktab(void)
@@ -540,6 +554,7 @@ main(void)
540554
test_fcntltab();
541555
test_fsconfig();
542556
test_icmptypetab();
557+
test_arphooktab();
543558
test_inethooktab();
544559
test_ioctlreqtab();
545560
test_ip6optnametab();

0 commit comments

Comments
 (0)