blob: f24986cb6569e3934abf48d4b683f38e2396330b [file] [log] [blame]
David Andersonfe303692020-10-19 22:11:29 -07001# snapuserd - Daemon for servicing dm-user requests for Virtual A/B snapshots.
David Anderson09bb9442020-11-13 00:45:59 -08002type snapuserd, domain;
3type snapuserd_exec, exec_type, file_type, system_file_type;
David Andersonfe303692020-10-19 22:11:29 -07004
5typeattribute snapuserd coredomain;
6
7init_daemon_domain(snapuserd)
8
9allow snapuserd kmsg_device:chr_file rw_file_perms;
10
Akilesh Kailash8494fbe2021-07-22 08:23:45 +000011# Allow snapuserd to reach block devices in /dev/block.
12allow snapuserd block_device:dir search;
13
14# Read /sys/block to find all the DM directories like (/sys/block/dm-X).
15allow snapuserd sysfs:dir { open read };
16
17# Read /sys/block/dm-X/dm/name (which is a symlink to
18# /sys/devices/virtual/block/dm-X/dm/name) to identify the mapping between
19# dm-X and dynamic partitions.
20allow snapuserd sysfs_dm:dir { open read search };
21allow snapuserd sysfs_dm:file r_file_perms;
22
David Andersonfe303692020-10-19 22:11:29 -070023# Reading and writing to /dev/block/dm-* (device-mapper) nodes.
24allow snapuserd block_device:dir r_dir_perms;
25allow snapuserd dm_device:chr_file rw_file_perms;
26allow snapuserd dm_device:blk_file rw_file_perms;
27
28# Reading and writing to dm-user control nodes.
David Anderson09bb9442020-11-13 00:45:59 -080029allow snapuserd dm_user_device:dir r_dir_perms;
David Andersonfe303692020-10-19 22:11:29 -070030allow snapuserd dm_user_device:chr_file rw_file_perms;
David Andersonf4cba7e2020-12-02 21:15:08 -080031
David Andersonbf5b6ce2021-07-26 15:03:11 -070032# Reading and writing to /dev/socket/snapuserd and snapuserd_proxy.
David Andersonf4cba7e2020-12-02 21:15:08 -080033allow snapuserd snapuserd_socket:unix_stream_socket { accept listen getattr read write };
David Andersonbf5b6ce2021-07-26 15:03:11 -070034allow snapuserd snapuserd_proxy_socket:sock_file write;
David Andersonf4cba7e2020-12-02 21:15:08 -080035
36# This arises due to first-stage init opening /dev/null without F_CLOEXEC
37# (see SetStdioToDevNull in init). When we fork() and execveat() snapuserd
38# again, the descriptor leaks into the new process.
39allow snapuserd kernel:fd use;
David Andersonbf5b6ce2021-07-26 15:03:11 -070040
41# snapuserd.* properties
42set_prop(snapuserd, snapuserd_prop)
43
44# For inotify watching for /dev/socket/snapuserd_proxy to appear.
David Anderson136b4ea2021-08-04 19:24:06 -070045allow snapuserd tmpfs:dir { read watch };
David Andersonbf5b6ce2021-07-26 15:03:11 -070046
47# Forbid anything other than snapuserd and init setting snapuserd properties.
48neverallow {
49 domain
50 -snapuserd
51 -init
52} snapuserd_prop:property_service set;