File tree 1 file changed +31
-1
lines changed
1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 27
27
28
28
static struct crypto_shash * ima_shash_tfm ;
29
29
30
+ /**
31
+ * ima_kernel_read - read file content
32
+ *
33
+ * This is a function for reading file content instead of kernel_read().
34
+ * It does not perform locking checks to ensure it cannot be blocked.
35
+ * It does not perform security checks because it is irrelevant for IMA.
36
+ *
37
+ */
38
+ static int ima_kernel_read (struct file * file , loff_t offset ,
39
+ char * addr , unsigned long count )
40
+ {
41
+ mm_segment_t old_fs ;
42
+ char __user * buf = addr ;
43
+ ssize_t ret ;
44
+
45
+ if (!(file -> f_mode & FMODE_READ ))
46
+ return - EBADF ;
47
+ if (!file -> f_op -> read && !file -> f_op -> aio_read )
48
+ return - EINVAL ;
49
+
50
+ old_fs = get_fs ();
51
+ set_fs (get_ds ());
52
+ if (file -> f_op -> read )
53
+ ret = file -> f_op -> read (file , buf , count , & offset );
54
+ else
55
+ ret = do_sync_read (file , buf , count , & offset );
56
+ set_fs (old_fs );
57
+ return ret ;
58
+ }
59
+
30
60
int ima_init_crypto (void )
31
61
{
32
62
long rc ;
@@ -104,7 +134,7 @@ static int ima_calc_file_hash_tfm(struct file *file,
104
134
while (offset < i_size ) {
105
135
int rbuf_len ;
106
136
107
- rbuf_len = kernel_read (file , offset , rbuf , PAGE_SIZE );
137
+ rbuf_len = ima_kernel_read (file , offset , rbuf , PAGE_SIZE );
108
138
if (rbuf_len < 0 ) {
109
139
rc = rbuf_len ;
110
140
break ;
You can’t perform that action at this time.
0 commit comments