summaryrefslogtreecommitdiff
path: root/src/dev/nodedev/memnodedev.cil
blob: dad7a1c58d3d7aec21022554e89d2aa54dfbe71a (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
50
51
52
53
;; SPDX-FileCopyrightText: © 2024 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 dev.unconfined

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

(in nodedev.unconfined

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