2
2
#ifndef DFLTCC_UTIL_H
3
3
#define DFLTCC_UTIL_H
4
4
5
+ #include "dfltcc.h"
6
+ #include <linux/kmsan-checks.h>
5
7
#include <linux/zutil.h>
6
8
7
9
/*
@@ -20,6 +22,7 @@ typedef enum {
20
22
#define DFLTCC_CMPR 2
21
23
#define DFLTCC_XPND 4
22
24
#define HBT_CIRCULAR (1 << 7)
25
+ #define DFLTCC_FN_MASK ((1 << 7) - 1)
23
26
#define HB_BITS 15
24
27
#define HB_SIZE (1 << HB_BITS)
25
28
@@ -34,6 +37,7 @@ static inline dfltcc_cc dfltcc(
34
37
)
35
38
{
36
39
Byte * t2 = op1 ? * op1 : NULL ;
40
+ unsigned char * orig_t2 = t2 ;
37
41
size_t t3 = len1 ? * len1 : 0 ;
38
42
const Byte * t4 = op2 ? * op2 : NULL ;
39
43
size_t t5 = len2 ? * len2 : 0 ;
@@ -59,6 +63,30 @@ static inline dfltcc_cc dfltcc(
59
63
: "cc" , "memory" );
60
64
t2 = r2 ; t3 = r3 ; t4 = r4 ; t5 = r5 ;
61
65
66
+ /*
67
+ * Unpoison the parameter block and the output buffer.
68
+ * This is a no-op in non-KMSAN builds.
69
+ */
70
+ switch (fn & DFLTCC_FN_MASK ) {
71
+ case DFLTCC_QAF :
72
+ kmsan_unpoison_memory (param , sizeof (struct dfltcc_qaf_param ));
73
+ break ;
74
+ case DFLTCC_GDHT :
75
+ kmsan_unpoison_memory (param , offsetof(struct dfltcc_param_v0 , csb ));
76
+ break ;
77
+ case DFLTCC_CMPR :
78
+ kmsan_unpoison_memory (param , sizeof (struct dfltcc_param_v0 ));
79
+ kmsan_unpoison_memory (
80
+ orig_t2 ,
81
+ t2 - orig_t2 +
82
+ (((struct dfltcc_param_v0 * )param )-> sbb == 0 ? 0 : 1 ));
83
+ break ;
84
+ case DFLTCC_XPND :
85
+ kmsan_unpoison_memory (param , sizeof (struct dfltcc_param_v0 ));
86
+ kmsan_unpoison_memory (orig_t2 , t2 - orig_t2 );
87
+ break ;
88
+ }
89
+
62
90
if (op1 )
63
91
* op1 = t2 ;
64
92
if (len1 )
0 commit comments