Skip to content

Commit 84bb46c

Browse files
author
Jakub Kicinski
committed
Revert "bpf: Emit audit messages upon successful prog load and unload"
This commit reverts commit 91e6015 ("bpf: Emit audit messages upon successful prog load and unload") and its follow up commit 7599a89 ("audit: Move audit_log_task declaration under CONFIG_AUDITSYSCALL") as requested by Paul Moore. The change needs close review on linux-audit, tests etc. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8dcdc95 commit 84bb46c

File tree

4 files changed

+1
-38
lines changed

4 files changed

+1
-38
lines changed

include/linux/audit.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ static inline void audit_ptrace(struct task_struct *t)
358358
__audit_ptrace(t);
359359
}
360360

361-
extern void audit_log_task(struct audit_buffer *ab);
362-
363361
/* Private API (for audit.c only) */
364362
extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
365363
extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
@@ -647,9 +645,6 @@ static inline void audit_ntp_log(const struct audit_ntp_data *ad)
647645

648646
static inline void audit_ptrace(struct task_struct *t)
649647
{ }
650-
651-
static inline void audit_log_task(struct audit_buffer *ab)
652-
{ }
653648
#define audit_n_rules 0
654649
#define audit_signals 0
655650
#endif /* CONFIG_AUDITSYSCALL */

include/uapi/linux/audit.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
#define AUDIT_FANOTIFY 1331 /* Fanotify access decision */
117117
#define AUDIT_TIME_INJOFFSET 1332 /* Timekeeping offset injected */
118118
#define AUDIT_TIME_ADJNTPVAL 1333 /* NTP value adjustment */
119-
#define AUDIT_BPF 1334 /* BPF subsystem */
120119

121120
#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
122121
#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */

kernel/auditsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,7 @@ void __audit_ntp_log(const struct audit_ntp_data *ad)
25452545
audit_log_ntp_val(ad, "adjust", AUDIT_NTP_ADJUST);
25462546
}
25472547

2548-
void audit_log_task(struct audit_buffer *ab)
2548+
static void audit_log_task(struct audit_buffer *ab)
25492549
{
25502550
kuid_t auid, uid;
25512551
kgid_t gid;

kernel/bpf/syscall.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <linux/timekeeping.h>
2424
#include <linux/ctype.h>
2525
#include <linux/nospec.h>
26-
#include <linux/audit.h>
2726
#include <uapi/linux/btf.h>
2827

2928
#define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PROG_ARRAY || \
@@ -1322,34 +1321,6 @@ static void free_used_maps(struct bpf_prog_aux *aux)
13221321
kfree(aux->used_maps);
13231322
}
13241323

1325-
enum bpf_event {
1326-
BPF_EVENT_LOAD,
1327-
BPF_EVENT_UNLOAD,
1328-
};
1329-
1330-
static const char * const bpf_event_audit_str[] = {
1331-
[BPF_EVENT_LOAD] = "LOAD",
1332-
[BPF_EVENT_UNLOAD] = "UNLOAD",
1333-
};
1334-
1335-
static void bpf_audit_prog(const struct bpf_prog *prog, enum bpf_event event)
1336-
{
1337-
bool has_task_context = event == BPF_EVENT_LOAD;
1338-
struct audit_buffer *ab;
1339-
1340-
if (audit_enabled == AUDIT_OFF)
1341-
return;
1342-
ab = audit_log_start(audit_context(), GFP_ATOMIC, AUDIT_BPF);
1343-
if (unlikely(!ab))
1344-
return;
1345-
if (has_task_context)
1346-
audit_log_task(ab);
1347-
audit_log_format(ab, "%sprog-id=%u event=%s",
1348-
has_task_context ? " " : "",
1349-
prog->aux->id, bpf_event_audit_str[event]);
1350-
audit_log_end(ab);
1351-
}
1352-
13531324
int __bpf_prog_charge(struct user_struct *user, u32 pages)
13541325
{
13551326
unsigned long memlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
@@ -1466,7 +1437,6 @@ static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock)
14661437
{
14671438
if (atomic64_dec_and_test(&prog->aux->refcnt)) {
14681439
perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0);
1469-
bpf_audit_prog(prog, BPF_EVENT_UNLOAD);
14701440
/* bpf_prog_free_id() must be called first */
14711441
bpf_prog_free_id(prog, do_idr_lock);
14721442
__bpf_prog_put_noref(prog, true);
@@ -1876,7 +1846,6 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)
18761846
*/
18771847
bpf_prog_kallsyms_add(prog);
18781848
perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0);
1879-
bpf_audit_prog(prog, BPF_EVENT_LOAD);
18801849

18811850
err = bpf_prog_new_fd(prog);
18821851
if (err < 0)

0 commit comments

Comments
 (0)