Skip to content

Add library authentication feature for MTL and LNL - #8741

Merged
lgirdwood merged 4 commits into
thesofproject:mainfrom
jxstelter:jst-prv-library-auth
Jan 26, 2024
Merged

Add library authentication feature for MTL and LNL#8741
lgirdwood merged 4 commits into
thesofproject:mainfrom
jxstelter:jst-prv-library-auth

Conversation

@jxstelter

Copy link
Copy Markdown
Contributor

These changes will enable loadable library authentication before load.
Untrusted libraries will be not loaded.
Feature is available only on Intel platforms since it uses rom_ext module interface to
perform validation.

Signed-off-by: Jaroslaw Stelter Jaroslaw.Stelter@intel.com

@jxstelter
jxstelterforce-pushed the jst-prv-library-auth branch 5 times, most recently from 2875328 to fa78e53CompareJanuary 15, 2024 11:15
@jxstelter
jxstelter marked this pull request as ready for review January 16, 2024 08:47

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. Not 100% sure what is the right place to put the auth headers to. This is not specific to RTOS, but is specific to targets. Platform seems the right place to put these.

Comment threadzephyr/include/sof/auth/auth_api.h
Comment threadzephyr/include/sof/auth/status_logger_api.h
Comment threadsrc/library_manager/lib_manager.c Outdated
Comment threadsrc/library_manager/lib_manager.c Outdated
Comment threadzephyr/include/sof/auth/auth_api.h
Comment threadzephyr/include/sof/auth/auth_api.h Outdated
Comment threadzephyr/include/sof/auth/auth_api.h Outdated
Comment threadzephyr/include/sof/auth/auth_api_iface.h
Comment threadsrc/library_manager/Kconfig Outdated
Comment threadsrc/library_manager/lib_manager.c Outdated
Comment threadsrc/library_manager/lib_manager.c Outdated
Comment threadsrc/library_manager/lib_manager.c Outdated
Comment threadsrc/library_manager/lib_manager.c Outdated
Comment threadsrc/library_manager/lib_manager.c Outdated

@lgirdwoodlgirdwood left a comment

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.

The API is mostly generic but has some Intel specific flows, I think we can solve all this in the short term by renaming the header files to auth/intel.h and auth/intel_iface.h. Short term we need the fix, long term we need to look at Zephyr auth driver API as this code should really be in RTOS as a system driver.

Comment threadzephyr/include/sof/auth/auth_api.h
Comment threadzephyr/include/sof/auth/auth_api.h
Comment threadzephyr/include/sof/auth/auth_api.h
ret = auth_api_result(&ext_lib->auth_ctx);

if (ret != AUTH_IMAGE_TRUSTED) {
tr_err(&lib_manager_tr, "lib_manager_auth_proc() Untrasted library!");

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.

untrusted

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jxstelter can we fix the typo in a follow up?

Comment threadsrc/library_manager/lib_manager.c Outdated
@jxstelter
jxstelterforce-pushed the jst-prv-library-auth branch 4 times, most recently from ad16ee6 to a0e476dCompareJanuary 17, 2024 13:46

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Almost there. Two things:

  1. @lgirdwood proposed a bit different approach, to keep the headers in sof/zephyr/include but rename the interface with Intel prefix. I think the current V2 version imlements the platform option cleanly (a few nits inline), but granted the interface is likely fairly Intel specific. But yeah, Liam, preference which way to go?

  2. Missing rfree on error path, Guennadi's comment.

Comment threadsrc/include/sof/auth_api_iface.h Outdated
Comment threadsrc/platform/intel/ace/include/ace/auth/auth_api.h
Comment threadsrc/include/sof/lib_manager.h Outdated
Comment threadsrc/library_manager/lib_manager.c
@jxstelter

Copy link
Copy Markdown
ContributorAuthor

Almost there. Two things:

  1. @lgirdwood proposed a bit different approach, to keep the headers in sof/zephyr/include but rename the interface with Intel prefix. I think the current V2 version imlements the platform option cleanly (a few nits inline), but granted the interface is likely fairly Intel specific. But yeah, Liam, preference which way to go?
  2. Missing rfree on error path, Guennadi's comment.

@lgirdwood Should I change names according to Your first review input?

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, looks good to me!

@lgirdwood

Copy link
Copy Markdown
Member

Almost there. Two things:

  1. @lgirdwood proposed a bit different approach, to keep the headers in sof/zephyr/include but rename the interface with Intel prefix. I think the current V2 version imlements the platform option cleanly (a few nits inline), but granted the interface is likely fairly Intel specific. But yeah, Liam, preference which way to go?
  2. Missing rfree on error path, Guennadi's comment.

@lgirdwood Should I change names according to Your first review input?

Yeah - just for the implementation side with Intel IP code. I think the interface is quite generic so hopefully can be lifted into Zephyr in the future without too many changes.

For ACE platforms library authentication could be done using external
entity - rom_ext. This module reside in L3 memory space and provides
verification functionality. Following code expose that API to SOF.
Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
This patch adds usage of authentication API to check
library signature. If feature enabled it will block loading of
library without valid signature.
Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
This enables library authentication on MTL platforms.
Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
This enables library authentication on LNL platforms.
Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Refresh +1

@kv2019ikv2019i mentioned this pull request Jan 26, 2024
man_tmp_buffer = (__sparse_force void __sparse_cache *)
rballoc_align(0, SOF_MEM_CAPS_DMA,
MAN_MAX_SIZE_V1_8, dma_ext->addr_align);
MAN_MAX_SIZE_V1_8, CONFIG_MM_DRV_PAGE_SIZE);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

how is this related? Can we add a comment in a follow-up? Or, if this wasn't intended, revert this

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Authentication engine in ROM_EXT requires page aligned buffer. Otherwise it fails.

struct ext_library *ext_lib = ext_lib_get();
int ret;

ret = auth_api_init_auth_proc(&ext_lib->auth_ctx, buffer_data, buffer_size, phase);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this also needed in the LAST stage? A bit asymmetric

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This is how reference code uses this API.

@lgirdwood
lgirdwood merged commit 17b3b01 into thesofproject:mainJan 26, 2024
@lgirdwood

Copy link
Copy Markdown
Member

Merging now as it fixes an issue. We can now start to look at how "authentication drivers" can upstream into Zephyr in the long term. @nashif@teburd@ceolin fyi.

@jsarhajsarha mentioned this pull request Feb 12, 2024
Sign up for freeto 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.

5 participants

@jxstelter@lgirdwood@lyakh@btian1@kv2019i