lin
2025-08-21 57113df3a0e2be01232281fad9a5f2c060567981
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 *
 * Copyright (C) 2014 Allwinner Ltd.
 *
 * Author:
 *    Ryan Chen <ryanchen@allwinnertech.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 */
 
 
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/security.h>
#include <linux/fivm.h>
 
static struct fivm_operation fivm_ops = {NULL, NULL};
int fivm_mmap_verify(struct file *file, unsigned long prot)
{
   if (fivm_ops.mmap_verify)
       return fivm_ops.mmap_verify(file, prot);
   else
       return 0;
}
int fivm_open_verify(struct file *file, const char *pathname, int mask)
{
   if (fivm_ops.open_verify)
       return fivm_ops.open_verify(file, pathname, mask);
   else
       return 0;
}
 
int fivm_register_func(
       int (*mmap_verify)(struct file *, unsigned long),
       int (*open_verify)(struct file *, const char *, int))
{
   memset(&fivm_ops, 0, sizeof(fivm_ops));
   fivm_ops.mmap_verify = mmap_verify;
   fivm_ops.open_verify = open_verify;
   return 0;
}
EXPORT_SYMBOL(fivm_register_func);
 
int fivm_unregister_func(void)
{
   memset(&fivm_ops, 0, sizeof(fivm_ops));
   return 0;
}
EXPORT_SYMBOL(fivm_unregister_func);