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