Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Creating audit records for mapped devices.
0004  *
0005  * Copyright (C) 2021 Fraunhofer AISEC. All rights reserved.
0006  *
0007  * Authors: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
0008  */
0009 
0010 #ifndef DM_AUDIT_H
0011 #define DM_AUDIT_H
0012 
0013 #include <linux/device-mapper.h>
0014 #include <linux/audit.h>
0015 
0016 #ifdef CONFIG_DM_AUDIT
0017 void dm_audit_log_bio(const char *dm_msg_prefix, const char *op,
0018               struct bio *bio, sector_t sector, int result);
0019 
0020 /*
0021  * dm_audit_log_ti() is not intended to be used directly in dm modules,
0022  * the wrapper functions below should be called by dm modules instead.
0023  */
0024 void dm_audit_log_ti(int audit_type, const char *dm_msg_prefix, const char *op,
0025              struct dm_target *ti, int result);
0026 
0027 static inline void dm_audit_log_ctr(const char *dm_msg_prefix,
0028                     struct dm_target *ti, int result)
0029 {
0030     dm_audit_log_ti(AUDIT_DM_CTRL, dm_msg_prefix, "ctr", ti, result);
0031 }
0032 
0033 static inline void dm_audit_log_dtr(const char *dm_msg_prefix,
0034                     struct dm_target *ti, int result)
0035 {
0036     dm_audit_log_ti(AUDIT_DM_CTRL, dm_msg_prefix, "dtr", ti, result);
0037 }
0038 
0039 static inline void dm_audit_log_target(const char *dm_msg_prefix, const char *op,
0040                        struct dm_target *ti, int result)
0041 {
0042     dm_audit_log_ti(AUDIT_DM_EVENT, dm_msg_prefix, op, ti, result);
0043 }
0044 #else
0045 static inline void dm_audit_log_bio(const char *dm_msg_prefix, const char *op,
0046                     struct bio *bio, sector_t sector,
0047                     int result)
0048 {
0049 }
0050 static inline void dm_audit_log_target(const char *dm_msg_prefix,
0051                        const char *op, struct dm_target *ti,
0052                        int result)
0053 {
0054 }
0055 static inline void dm_audit_log_ctr(const char *dm_msg_prefix,
0056                     struct dm_target *ti, int result)
0057 {
0058 }
0059 
0060 static inline void dm_audit_log_dtr(const char *dm_msg_prefix,
0061                     struct dm_target *ti, int result)
0062 {
0063 }
0064 #endif
0065 
0066 #endif