Skip to content

Commit c65d07c

Browse files
luk1337Michael Bestas
authored and
Michael Bestas
committed
sepolicy: Add sdcard_posix_contextmount_type attribute
* Since we can't use contextmount_type for sdcard_posix due to contextmount_type being read only by design we need to declare our own attribute to bypass relabelto neverallow. That way we can mount external ext4/f2fs SD with sdcard_posix context and write permissions. Test: m -j selinux_policy Change-Id: I0dfe49cc0b34dfcce2840198843bde1272cbc61c
1 parent 31e0945 commit c65d07c

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

prebuilts/api/30.0/public/attributes

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ attribute fs_type;
1818
# All types used for context= mounts.
1919
attribute contextmount_type;
2020

21+
# All types used for sdcard_posix context= mounts.
22+
attribute sdcard_posix_contextmount_type;
23+
2124
# All types used for files that can exist on a labeled fs.
2225
# Do not use for pseudo file types.
2326
# On change, update CHECK_FC_ASSERT_ATTRS

prebuilts/api/30.0/public/domain.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ neverallow * rootfs:file { create write setattr relabelto append unlink link ren
494494

495495
# Restrict context mounts to specific types marked with
496496
# the contextmount_type attribute.
497-
neverallow * {fs_type -contextmount_type}:filesystem relabelto;
497+
neverallow * {fs_type -contextmount_type -sdcard_posix_contextmount_type}:filesystem relabelto;
498498

499499
# Ensure that context mount types are not writable, to ensure that
500500
# the write to /system restriction above is not bypassed via context=

public/attributes

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ attribute fs_type;
1818
# All types used for context= mounts.
1919
attribute contextmount_type;
2020

21+
# All types used for sdcard_posix context= mounts.
22+
attribute sdcard_posix_contextmount_type;
23+
2124
# All types used for files that can exist on a labeled fs.
2225
# Do not use for pseudo file types.
2326
# On change, update CHECK_FC_ASSERT_ATTRS

public/domain.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ neverallow * rootfs:file { create write setattr relabelto append unlink link ren
494494

495495
# Restrict context mounts to specific types marked with
496496
# the contextmount_type attribute.
497-
neverallow * {fs_type -contextmount_type}:filesystem relabelto;
497+
neverallow * {fs_type -contextmount_type -sdcard_posix_contextmount_type}:filesystem relabelto;
498498

499499
# Ensure that context mount types are not writable, to ensure that
500500
# the write to /system restriction above is not bypassed via context=

0 commit comments

Comments
 (0)