Skip to content

tee_supplicant: Add necessary SELinux policy for tee_supplicant domain#1105

Open
wenjz-qualcomm wants to merge 2 commits into
SELinuxProject:mainfrom
wenjz-qualcomm:main
Open

tee_supplicant: Add necessary SELinux policy for tee_supplicant domain#1105
wenjz-qualcomm wants to merge 2 commits into
SELinuxProject:mainfrom
wenjz-qualcomm:main

Conversation

@wenjz-qualcomm
Copy link
Copy Markdown
Contributor

@wenjz-qualcomm wenjz-qualcomm commented Apr 16, 2026

Define some new interfaces to access /var/lib/tee, /var/lib/qtee_supplicant
and /var/lib/tee/qtee_supplicant.

Grant the nescessary permission to tee_supplicant for resolving
AVC denials in enforcing mode.

Upstream-Status: Inappropriate [embedded specific]

In the commit write the Upstream-status just because yocto project request it, the status isn't the truly status, just to maintain a uniform format.

Comment thread policy/modules/services/tee_supplicant.fc Outdated
Comment thread policy/modules/services/tee_supplicant.fc Outdated
Comment thread policy/modules/services/tee_supplicant.if Outdated
Comment thread policy/modules/services/tee_supplicant.if Outdated
Comment thread policy/modules/services/tee_supplicant.if Outdated
Comment thread policy/modules/services/tee_supplicant.te Outdated
Comment thread policy/modules/services/tee_supplicant.te Outdated
Comment thread policy/modules/services/tee_supplicant.if Outdated
@wenjz-qualcomm wenjz-qualcomm force-pushed the main branch 2 times, most recently from c7d9e2a to fc2e74a Compare April 17, 2026 09:23
Comment thread policy/modules/services/tee_supplicant.fc Outdated
Comment thread policy/modules/services/tee_supplicant.fc Outdated
Comment thread policy/modules/services/tee_supplicant.if Outdated
Comment thread policy/modules/services/tee_supplicant.if Outdated
Comment thread policy/modules/services/tee_supplicant.if Outdated
Comment thread policy/modules/services/tee_supplicant.te Outdated
Comment thread policy/modules/services/tee_supplicant.te Outdated
Comment thread policy/modules/services/tee_supplicant.te Outdated
@harshaldev27
Copy link
Copy Markdown

harshaldev27 commented Apr 17, 2026

Hi @wenjz-qualcomm , Can you please update the Commit message to explicitly state that we are adding these new interface for qtee-supplicant which requires more permissions than OPTEE's tee-supplicant. Also, please describe what all permissions (high level) we are adding and why. Please also fix the indentation on your commit message body.

Finally, drop this "Upstream-Status: Inappropriate [embedded specific]" from the commit message.

@wenjz-qualcomm
Copy link
Copy Markdown
Contributor Author

Hi @harshaldev27 and @dburgener, I already modified all mentioned comments, pls help me review the latest version. Thanks.

@@ -1,5 +1,5 @@
## <summary>tee_supplicant</summary>
#
##
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add unnecessary #s here. This file should be un-touched.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change still remains.

Comment thread policy/modules/services/tee_supplicant.te Outdated
@wenjz-qualcomm wenjz-qualcomm force-pushed the main branch 2 times, most recently from e1b57ab to 61d20af Compare April 21, 2026 06:31
Comment thread policy/modules/services/tee_supplicant.fc Outdated
Comment thread policy/modules/services/tee_supplicant.te Outdated
@wenjz-qualcomm wenjz-qualcomm force-pushed the main branch 3 times, most recently from e8ffeaf to 31ceb11 Compare April 28, 2026 06:56
Comment thread policy/modules/services/tee_supplicant.te Outdated
@pebenito
Copy link
Copy Markdown
Member

pebenito commented May 4, 2026

Hi @pebenito, does that mean that we should label /usr/bin/qtee_supplicant as tee_supplicant_qtee, and then for all the permissions that it needs common with tee_supplicant_t call the same interfaces? Or is there a better way to do this?

No, /usr/bin/qtee_supplicant would remain tee_supplicant_exec_t. The entire .te file should use tee_supplicant_t. Any permissions known to be specific to qtee_supplicant should be in the tunable. Then on your system, you would enable the tee_supplicant_qtee Boolean to enable the rules.

@harshaldev27
Copy link
Copy Markdown

Hi @pebenito, does that mean that we should label /usr/bin/qtee_supplicant as tee_supplicant_qtee, and then for all the permissions that it needs common with tee_supplicant_t call the same interfaces? Or is there a better way to do this?

No, /usr/bin/qtee_supplicant would remain tee_supplicant_exec_t. The entire .te file should use tee_supplicant_t. Any permissions known to be specific to qtee_supplicant should be in the tunable. Then on your system, you would enable the tee_supplicant_qtee Boolean to enable the rules.

Understood. I believe @wenjz-qualcomm has already accomodated this direction in the lastest pushed changes.

Comment thread policy/modules/services/tee_supplicant.te Outdated
Comment on lines +43 to +65
# Access tee_supplicant to read /var
files_list_var(tee_supplicant_t)

# Access qtee_supplicant to visit /var/lib
files_list_var_lib(tee_supplicant_t)

# Access qtee_supplicant to access compatible of device tree
dev_read_sysfs(tee_supplicant_t)

# Access qtee_supplicant to send logs to systemd journal
logging_send_syslog_msg(tee_supplicant_t)

# Access qtee_supplicant to access /proc/cmdline
kernel_read_system_state(tee_supplicant_t)

# Access qtee_supplicant to request sys_rawio capability
allow tee_supplicant_t self:capability sys_rawio;

# Access qtee_supplicant to write wake_lock
dev_write_sysfs(tee_supplicant_t)

# Allow qtee_supplicant to block system suspend (wake_lock)
allow tee_supplicant_t self:capability2 block_suspend;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please order the lines in the tunable block according to the StyleGuide.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordered.

files_list_var_lib(tee_supplicant_t)

# Access qtee_supplicant to access compatible of device tree
dev_read_sysfs(tee_supplicant_t)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which files/directories in sysfs does this read? We are slowly adding more labeling in sysfs. Please put comments that summarize what is accessed in sysfs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented.

This change is adding some interfaces for qtee_supplicant which requires
more permissions than OPTEE’s tee‑supplicant.

Overall, some necessary permissions for qtee_supplicant to accessing
system resources have been added.

Signed-off-by: Wenjia Zhang <wenjia.zhang@oss.qualcomm.com>
@wenjz-qualcomm
Copy link
Copy Markdown
Contributor Author

Hi @pebenito , could you please help me to do the further review?

Copy link
Copy Markdown

@harshaldev27 harshaldev27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good from my side.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
')

optional_policy(`
tee_supplicant_var_lib_filetrans(initrc_t)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too broad. This will make any file or directory it creates in /var/lib as tee_supplicant_var_lib_t. The interface should be revised like

filetrans_pattern($1, root_t, $2, $3, $4)
so the object class and dir name can be specified at the call site.

@@ -1,5 +1,5 @@
## <summary>tee_supplicant</summary>
#
##
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change still remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants