Skip to contentSkip to conversation

three patches to external/sepolicy

PATCH In review Haiqing Jiang 2 participants 10 messages Jul 19, 2012 – Jul 23, 2012 SELinux security module

lore
Share & tools
lore
#0 lore raw

[PATCH 1/3] external/sepolicy: the media apps from third-party are labeled with media_app instead of untrusted_app The applications installed from third party, which will be "untrusted_app" (e.g., cts test apks), do not have "seinfo==media". Therefore, these applications will not be labeled as "media_app" (policy in seapp_contexts). But these applications will call the same permissions of regular media_app. So, we need to add these untrusted_app to media_app class.

Note that those application are for CTS test (currently we do not find others). So a better way should be proposing bool-enabled scheme in seapp_contexts, which has been discussed among us yesterday. We could update later if the new scheme is done. (Waiting for you guys' comments)

[PATCH 2/3] external/sepolicy: install daemon link/unlink application data files the installer daemon get the permissions (link, unlink) the application data files.

[PATCH 3/3] external/sepolicy: system r/w udp_socket of untrusted apps system get the read/write permissions on udp_socket related to untrusted applications.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw

PATCH 1/3 external/sepolicy: the media apps from third-party are labeled with media_app instead of untrusted_app

From: hqjiang <[email protected]>

---
 seapp_contexts |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
seapp_contexts +1 -0
index 502206a..1e98f91 100644
@@ -38,3 +38,4 @@ user=app_* seinfo=shared domain=shared_app levelFromUid=true
 user=app_* seinfo=media domain=media_app levelFromUid=true
 user=app_* seinfo=release domain=release_app levelFromUid=true
 user=app_* seinfo=release name=com.android.browser domain=browser_app levelFromUid=true
+user=app_* name=android.process.media domain=media_app levelFromUid=true
Signature · 7 lines
1.7.0.4


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

Re: [PATCH 1/3] external/sepolicy: the media apps from third-party are labeled with media_app instead of untrusted_app

Quoted 11 lines · Haiqing Jiang

From: hqjiang <[email protected]>

---
 seapp_contexts |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
seapp_contexts +0 -0
index 502206a..1e98f91 100644

seapp_contexts user=app_* seinfo=shared domain=shared_app levelFromUid=true · line 41

Quoted 4 lines
seapp_contexts +1 -0
@@ -38,3 +38,4 @@ user=app_* seinfo=shared domain=shared_app levelFromUid=true
 user=app_* seinfo=media domain=media_app levelFromUid=true
 user=app_* seinfo=release domain=release_app levelFromUid=true
 user=app_* seinfo=release name=com.android.browser domain=browser_app levelFromUid=true
+user=app_* name=android.process.media domain=media_app levelFromUid=true

Wouldn't this allow an arbitrary third party app to run in media_app, just by using android.process.media as its package name?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw

Re: [PATCH 1/3] external/sepolicy: the media apps from third-party are labeled with media_app instead of untrusted_app

Right.. It could be. We are thinking of adding bool-enabled scheme in seapp_contexts.

Quoted 27 lines · Stephen Smalley

seapp_contexts user=app_* seinfo=shared domain=shared_app

Quoted 11 lines · Haiqing Jiang

From: hqjiang <[email protected]>

---
 seapp_contexts |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
seapp_contexts +0 -0
index 502206a..1e98f91 100644
@@ -38,3 +38,4 @@ user=app_* seinfo=shared domain=shared_app

levelFromUid=true

seapp_contexts user=app_* seinfo=shared domain=shared_app levelFromUid=true

Quoted 3 lines
seapp_contexts +0 -0
 user=app_* seinfo=media domain=media_app levelFromUid=true
 user=app_* seinfo=release domain=release_app levelFromUid=true
 user=app_* seinfo=release name=com.android.browser domain=browser_app

levelFromUid=true

seapp_contexts user=app_* seinfo=shared domain=shared_app levelFromUid=true · line 41

Quoted 1 line
seapp_contexts +1 -0
+user=app_* name=android.process.media domain=media_app levelFromUid=true

Wouldn't this allow an arbitrary third party app to run in media_app, just by using android.process.media as its package name?

--
Stephen Smalley
National Security Agency

Signature · 4 lines
-----------------------------------
Haiqing Jiang, PH.D student

Computer Science Department, North Carolina State University
#4 lore raw

PATCH 2/3 external/sepolicy: install daemon link/unlink application data files

In reply to Haiqing Jiang

From: hqjiang <[email protected]>

---
 installd.te |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
installd.te +2 -0
index 466125e..5211f0a 100644
@@ -20,3 +20,5 @@ dontaudit installd self:capability sys_admin;
 selinux_check_context(installd)
 # Read /seapp_contexts, presently on the rootfs.
 allow installd rootfs:file r_file_perms;
+# Link/Unlink app_data_file
+allow installd app_data_file:lnk_file link_file_perms;
Signature · 7 lines
1.7.0.4


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw

Re: [PATCH 2/3] external/sepolicy: install daemon link/unlink application data files

Quoted 11 lines · Haiqing Jiang

From: hqjiang <[email protected]>

---
 installd.te |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
installd.te +0 -0
index 466125e..5211f0a 100644

installd.te dontaudit installd self:capability sys_admin; · line 24

Quoted 5 lines
installd.te +2 -0
@@ -20,3 +20,5 @@ dontaudit installd self:capability sys_admin;
 selinux_check_context(installd)
 # Read /seapp_contexts, presently on the rootfs.
 allow installd rootfs:file r_file_perms;
+# Link/Unlink app_data_file
+allow installd app_data_file:lnk_file link_file_perms;

What actual permissions were required? link (create a hard link) doesn't make sense on a symlink (lnk_file). unlink and rename are legitimate, but wondering whether anything other than unlink was required.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw

Re: [PATCH 2/3] external/sepolicy: install daemon link/unlink application data files

You are right. Only required permission is unlink.

Quoted 28 lines · Stephen Smalley
Quoted 11 lines · Haiqing Jiang

From: hqjiang <[email protected]>

---
 installd.te |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
installd.te +0 -0
index 466125e..5211f0a 100644

installd.te dontaudit installd self:capability sys_admin; · line 24

Quoted 5 lines
installd.te +2 -0
@@ -20,3 +20,5 @@ dontaudit installd self:capability sys_admin;
 selinux_check_context(installd)
 # Read /seapp_contexts, presently on the rootfs.
 allow installd rootfs:file r_file_perms;
+# Link/Unlink app_data_file
+allow installd app_data_file:lnk_file link_file_perms;

What actual permissions were required? link (create a hard link) doesn't make sense on a symlink (lnk_file). unlink and rename are legitimate, but wondering whether anything other than unlink was required.

--
Stephen Smalley
National Security Agency

Signature · 4 lines
-----------------------------------
Haiqing Jiang, PH.D student

Computer Science Department, North Carolina State University
#7 lore raw

PATCH 3/3 external/sepolicy: system r/w udp_socket of untrusted apps

In reply to Haiqing Jiang

From: hqjiang <[email protected]>

---
 system.te |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
system.te +3 -0
index a4065cf..5c34f81 100644
@@ -196,3 +196,6 @@ allow system domain:file r_file_perms;
 # to uart driver and ctrl proc entry
 allow system gps_device:chr_file rw_file_perms;
 allow system gps_control:file rw_file_perms;
+
+# system Read/Write udp_socket of untrusted_app
+allow system untrusted_app:udp_socket { read write };
Signature · 7 lines
1.7.0.4


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw

Re: [PATCH 3/3] external/sepolicy: system r/w udp_socket of untrusted apps

Quoted 11 lines · Haiqing Jiang

From: hqjiang <[email protected]>

---
 system.te |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
system.te +0 -0
index a4065cf..5c34f81 100644

system.te allow system domain:file r_file_perms; · line 201

Quoted 6 lines
system.te +3 -0
@@ -196,3 +196,6 @@ allow system domain:file r_file_perms;
 # to uart driver and ctrl proc entry
 allow system gps_device:chr_file rw_file_perms;
 allow system gps_control:file rw_file_perms;
+
+# system Read/Write udp_socket of untrusted_app
+allow system untrusted_app:udp_socket { read write };

So an app is passing a socket fd to the system_server over Binder and the system_server is then writing to the socket? Wonder why. Anyway, rather than writing this only in terms of one app domain (untrusted_app), cover all cases by using the appdomain attribute, i.e. allow system appdomain:udp_socket { read write };

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#9 lore raw

Re: [PATCH 3/3] external/sepolicy: system r/w udp_socket of untrusted apps

That will be fine. Appdomain is more general. Thanks.

Quoted 30 lines · Stephen Smalley
Quoted 11 lines · Haiqing Jiang

From: hqjiang <[email protected]>

---
 system.te |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
system.te +0 -0
index a4065cf..5c34f81 100644

system.te allow system domain:file r_file_perms; · line 201

Quoted 6 lines
system.te +3 -0
@@ -196,3 +196,6 @@ allow system domain:file r_file_perms;
 # to uart driver and ctrl proc entry
 allow system gps_device:chr_file rw_file_perms;
 allow system gps_control:file rw_file_perms;
+
+# system Read/Write udp_socket of untrusted_app
+allow system untrusted_app:udp_socket { read write };

So an app is passing a socket fd to the system_server over Binder and the system_server is then writing to the socket? Wonder why. Anyway, rather than writing this only in terms of one app domain (untrusted_app), cover all cases by using the appdomain attribute, i.e. allow system appdomain:udp_socket { read write };

--
Stephen Smalley
National Security Agency

Signature · 4 lines
-----------------------------------
Haiqing Jiang, PH.D student

Computer Science Department, North Carolina State University