summaryrefslogtreecommitdiff
path: root/src/dev/nodedev/memnodedev.cil
blob: f0cd387bc0a97a40a0ea8ff13a44d379adbc24c3 (plain)
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
;; SPDX-FileCopyrightText: M-BM-) 2025 Dominick Grift <dominick.grift@defensec.nl>
;; SPDX-License-Identifier: Unlicense

(block mem

    (filecon "/dev/mem" char nodedev_context)
    (filecon "/dev/port" char nodedev_context)

    (blockinherit .nodedev.template)

    (call .nodedev.exception.type (nodedev))

    (block read

	(macro type ((type ARG1))
	    (typeattributeset typeattr ARG1))

	(typeattribute not_typeattr)
	(typeattribute typeattr)

	(typeattributeset not_typeattr (not typeattr))

	(neverallow not_typeattr mem.nodedev (chr_file (read))))

    (block readwrite

	(macro type ((type ARG1))
	    (typeattributeset typeattr ARG1))

	(typeattribute typeattr)

	(call read.type (typeattr))
	(call write.type (typeattr)))

    (block write

	(macro type ((type ARG1))
	    (typeattributeset typeattr ARG1))

	(typeattribute not_typeattr)
	(typeattribute typeattr)

	(typeattributeset not_typeattr (not typeattr))

	(neverallow not_typeattr mem.nodedev (chr_file (append write)))))

(in nodedev.unconfined

    (call .mem.readwrite.type (typeattr)))