aboutsummaryrefslogtreecommitdiff
path: root/drivers/md/dm-audit.h
blob: 2385f2b659bef815759c29549a728655d0896e78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Creating audit records for mapped devices.
 *
 * Copyright (C) 2021 Fraunhofer AISEC. All rights reserved.
 *
 * Authors: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
 */

#ifndef DM_AUDIT_H
#define DM_AUDIT_H

#include <linux/device-mapper.h>
#include <linux/audit.h>

#ifdef CONFIG_DM_AUDIT
void dm_audit_log_bio(const char *dm_msg_prefix, const char *op,
		      struct bio *bio, sector_t sector, int result);

/*
 * dm_audit_log_ti() is not intended to be used directly in dm modules,
 * the wrapper functions below should be called by dm modules instead.
 */
void dm_audit_log_ti(int audit_type, const char *dm_msg_prefix, const char *op,
		     struct dm_target *ti, int result);

static inline void dm_audit_log_ctr(const char *dm_msg_prefix,
				    struct dm_target *ti, int result)
{
	dm_audit_log_ti(AUDIT_DM_CTRL, dm_msg_prefix, "ctr", ti, result);
}

static inline void dm_audit_log_dtr(const char *dm_msg_prefix,
				    struct dm_target *ti, int result)
{
	dm_audit_log_ti(AUDIT_DM_CTRL, dm_msg_prefix, "dtr", ti, result);
}

static inline void dm_audit_log_target(const char *dm_msg_prefix, const char *op,
				       struct dm_target *ti, int result)
{
	dm_audit_log_ti(AUDIT_DM_EVENT, dm_msg_prefix, op, ti, result);
}
#else
static inline void dm_audit_log_bio(const char *dm_msg_prefix, const char *op,
				    struct bio *bio, sector_t sector,
				    int result)
{
}
static inline void dm_audit_log_target(const char *dm_msg_prefix,
				       const char *op, struct dm_target *ti,
				       int result)
{
}
static inline void dm_audit_log_ctr(const char *dm_msg_prefix,
				    struct dm_target *ti, int result)
{
}

static inline void dm_audit_log_dtr(const char *dm_msg_prefix,
				    struct dm_target *ti, int result)
{
}
#endif

#endif