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 25
25
26
26
static struct crypto_shash * ima_shash_tfm ;
27
27
28
+ /**
29
+ * ima_kernel_read - read file content
30
+ *
31
+ * This is a function for reading file content instead of kernel_read().
32
+ * It does not perform locking checks to ensure it cannot be blocked.
33
+ * It does not perform security checks because it is irrelevant for IMA.
34
+ *
35
+ */
36
+ static int ima_kernel_read (struct file * file , loff_t offset ,
37
+ char * addr , unsigned long count )
38
+ {
39
+ mm_segment_t old_fs ;
40
+ char __user * buf = addr ;
41
+ ssize_t ret ;
42
+
43
+ if (!(file -> f_mode & FMODE_READ ))
44
+ return - EBADF ;
45
+ if (!file -> f_op -> read && !file -> f_op -> aio_read )
46
+ return - EINVAL ;
47
+
48
+ old_fs = get_fs ();
49
+ set_fs (get_ds ());
50
+ if (file -> f_op -> read )
51
+ ret = file -> f_op -> read (file , buf , count , & offset );
52
+ else
53
+ ret = do_sync_read (file , buf , count , & offset );
54
+ set_fs (old_fs );
55
+ return ret ;
56
+ }
57
+
28
58
int ima_init_crypto (void )
29
59
{
30
60
long rc ;
@@ -98,7 +128,7 @@ static int ima_calc_file_hash_tfm(struct file *file,
98
128
while (offset < i_size ) {
99
129
int rbuf_len ;
100
130
101
- rbuf_len = kernel_read (file , offset , rbuf , PAGE_SIZE );
131
+ rbuf_len = ima_kernel_read (file , offset , rbuf , PAGE_SIZE );
102
132
if (rbuf_len < 0 ) {
103
133
rc = rbuf_len ;
104
134
break ;
You can’t perform that action at this time.
0 commit comments