Support badged SMC caps to restrict SMC function IDs - #589
Conversation
4fb3591 to
c7191ec
Compare
c7191ec to
3ea486d
Compare
|
The current way of doing SMC is by setting an attribute The proposed way is using the recently added cap export mechanism and letting users call I agree that this is a better API, as it is more generic and avoids the Microkit wrapper function. However, the I would not disallow |
If I understand correctly your proposal is something like this? <system>
<protection_domain name="arm_smc" priority="1">
<program_image path="arm_smc.elf" />
<cspace>
<cap_initial type="smc" badge="0x84000000" slot="1"/>
</cspace>
</protection_domain>
</system>This would be interesting and a step toward adding a dynamic escape hatch to Microkit, |
This is useful as we are going to add SMC caps and they don't reference PD name/ID, so we need to distinguish them. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Needed for new SMC badge changes. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Useful for debugging. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
The "smc=true" attribute on a PD would provide an unbadged SMC capability that allows a component to invoke any function exposed by the ARM Secure Monitor. Use our extra capabilities / cap mappings feature to support this. This leaves the "smc=true" still enabled and useable. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Use instead <cap_sc> feature instead for allow-listed function IDs. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
3ea486d to
bcb88d1
Compare

Please review commit by commit.
Summary
Add the ability to provide caps for performing SMC invocations which are 'badged',
only allowing certain function invocations. This allows for exposing certain
functions to specific PDs without granting unilateral rights to do anything, i.e.
following a principle of least privilege. This mechanism was explicitly
discussed in RFC 9: New Capability for seL4 SMC Forwarding.
Motivation
The existing Microkit SDF syntax allows for protection domains to be given
SMC capabilities. However, this is an unbadged SMC capability, which allows
access to all SMC functions, i.e. a lot of power over the system.
PDs are then allowed to invoke the
microkit_arm_smc_call(...)function withthe
seL4_ARM_SMCContext *argsandseL4_ARM_SMCContext *respstructs. Thisperforms an invocation on
seL4_ARM_SMC_Call(ARM_SMC_CAP, args, resp).Even if all a PD wants to do is call the
PSCI_VERSION(function0x84000000),they have all the rights to reboot the system, on/offline CPUs, etc.
seL4 provides a simple mechanism to restrict
SMCcapabilities; by providinga badged SMC capability, only function IDs that match the badge are allowed.
For allowing multiple SMC function IDs, one needs multiple badged copies of the
SMC capability.
Proposal
Using the existing
<cspace>cap-mapping feature, we add a new node type to theSDF file, the
cap_smc.User code then looks like this:
Specifying a
function_id="0"is an escape hatch for development, or when youdon't care about security, which provides an SMC capability that is unbadged
and so allows any SMC function call.
As part of this proposal, we remove the
microkit_arm_smc_call()andsmc="true"attribute from the Microkit API. This is because the next release, Microkit 3.0.0,
is planned to be a breaking change. This
is the last commit of this PR and could be dropped instead, leaving in a deprecated
API.
Rationale and alternatives
We briefly discuss the choices in the design space made in this proposal.
First, we continue allowing unbadged SMC capabilities to be provided, i.e.
function_id="0". We could instead disallow this entirely and have part of thisinclude policy to never allow this to be the case. We reject this as it can be
useful for development to allow any function ID.
The second point is the decision to expose the seL4 API and capabilities directly,
for calling
seL4_ARM_SMC_Call. This makes it the responsibility of the userto manage calling multiple SMC call function IDs themselves. This is instead how
CAmkES works: see
camkes_get_smc_capand
vm_smc_handlerof CAmkES-VM.We could do this in Microkit, too. This requires providing information to the PD
about which SMC capabilities are where, and then providing a function to distinguish
based on function ID. We choose not to do this, generally we only pass information
to PDs when the user requests, e.g.
setvar, and it is up to the user to choosehow to encode data about the system in their program; Microkit just provides the
mechanisms.
Original README
Original README
Note: this contains a breaking change by removing the SMC attribute.
This should be fine, as the 3.0.0 release is planned to be breaking anyway.
This change could be reverted; it is left as a separate commit to make that easy.
The other design choice here was that we do not permit "function_id=0", or some other way to make
badge = 0 <=> unbadged smc capwhich has no allowlisting, instead allowing everything. This is always (in my opinion) a bad design.