Skip to content

use SRSO spec_rstack_overflow kernel setting? #177

Description

@adrelanos

To test:

cat /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow

https://kernel.org/doc/html/latest/admin-guide/hw-vuln/srso.html

	spec_rstack_overflow=
			[X86] Control RAS overflow mitigation on AMD Zen CPUs

			off		- Disable mitigation
			microcode	- Enable microcode mitigation only
			safe-ret	- Enable sw-only safe RET mitigation (default)
			ibpb		- Enable mitigation by issuing IBPB on
					  kernel entry
			ibpb-vmexit	- Issue IBPB only on VMEXIT
					  (cloud-specific mitigation)

Best to use spec_rstack_overflow=ibpb?

Or not needed because we're already using spec_store_bypass_disable=on?

Activity

  1. adrelanos commented on Dec 5, 2023

    @adrelanos
    ContributorAuthor
    sudo dmesg | grep -i speculative
    
  2. adrelanos commented on Dec 9, 2023

    @adrelanos
    ContributorAuthor

    spectre_v2_user=seccomp,ibpb

                            seccomp,ibpb
                                    - Like "seccomp" above, but only STIBP is
                                      controlled per thread. IBPB is issued
                                      always when switching between different
                                      user space processes.
    

    The word "only" is concerning?

    This seems a weaker setting than:

                            on      - Unconditionally enable mitigations. Is
                                      enforced by spectre_v2=on
    

    mitigations=auto,nosmt sounds good.

                            auto,nosmt
                                    Mitigate all CPU vulnerabilities, disabling SMT
                                    if needed.  This is for users who always want to
                                    be fully mitigated, even if it means losing SMT.
                                    Equivalent to: l1tf=flush,nosmt [X86]
                                                   mds=full,nosmt [X86]
                                                   tsx_async_abort=full,nosmt [X86]
                                                   mmio_stale_data=full,nosmt [X86]
                                                   retbleed=auto,nosmt [X86]
    

    It might obsolete a few of our other settings.

  3. adrelanos commented on Dec 11, 2023

    @adrelanos
    ContributorAuthor

    Not sure what you're suggesting? Setting spectre_v2_user=seccomp,ibpb? Why would we weaken the settings?

    To make sure something is enabled rather than nothing? That would be the wrong approach.

    verification: Better to ask the kernel from within the running system by using the usual API (/proc or /sys) if mitigation are enabled. This kind of testing, confirmation would be a job for systemcheck.

    We could drop most and use mitigations=auto,nosmt instead. Everything that is covered by mitigations= does not need to be duplicated. Since we don't have verification it's still non-ideal but acceptable. Still flying blind.

  4. adrelanos commented on Dec 12, 2023

    @adrelanos
    ContributorAuthor

    mitigations=auto,nosmt is nice and we can enable it. Quote:

                            auto,nosmt
                                    Mitigate all CPU vulnerabilities, disabling SMT
                                    if needed.  This is for users who always want to
                                    be fully mitigated, even if it means losing SMT.
                                    Equivalent to: l1tf=flush,nosmt [X86]
                                                   mds=full,nosmt [X86]
                                                   tsx_async_abort=full,nosmt [X86]
                                                   mmio_stale_data=full,nosmt [X86]
                                                   retbleed=auto,nosmt [X86]
    

    but mitigations=auto,nosmt kernel manual does not mention spec_rstack_overflow. Explicitly setting spec_rstack_overflow might be more secure.

    Note,

    It's not the same. Both have their own dedicated kernel manual page.

  5. raja-grewal commented on Jan 25, 2024

    @raja-grewal
    Contributor

    Comparing to we already have in our configuration, we seem to be explicitly missing:

    1. retbleed=auto,nosmt: This should be added.

    2. spec_rstack_overflow=ibpb or spec_rstack_overflow=safe-ret: I am not certain which one is superior for our explicit purposes. I think the first is probably better.

    As you have stated, using mitigations=auto,nosmt is probably a good idea. While it would obsolete existing settings, I don’t think any harm will come since we use the same equivalent settings.

    Perhaps we should place this kernel parameter at the top of the configuration so it is applied first and then reinforced by our already more fine-grained settings?

    This way we will inherit any future mitigation from this kernel parameter that are not explicitly specified while also keeping our strict fine-grained settings fixed.

    Finally , since spec_rstack_overflow is not explicitly mentioned in mitigations, I believe we should put it in directly just to be safe.

  6. adrelanos commented on Jan 29, 2024

    @adrelanos
    ContributorAuthor
    1. retbleed=auto,nosmt: This should be added.

    Ok.

    1. spec_rstack_overflow=ibpb or spec_rstack_overflow=safe-ret: I am not certain which one is superior for our explicit purposes. I think the first is probably better.

    If we don't know it, we should ask somewhere. Short of an obvious answer or expert opinion, without being sure, we better keep it as is.

    The kernel built-in default setting might actually already be the most secure setting.

    As you have stated, using mitigations=auto,nosmt is probably a good idea.

    Ok.

    Perhaps we should place this kernel parameter at the top of the configuration so it is applied first and then reinforced by our already more fine-grained settings?

    Ok.

  7. adrelanos commented on Jan 29, 2024

    @adrelanos
    ContributorAuthor

    The spec_rstack_overflow change in #197 I'd comment out after merge due to my above comment.

  8. raja-grewal commented on Jan 29, 2024

    @raja-grewal
    Contributor

    I have left that parameter as the default kernel mitigation: spec_rstack_overflow=safe-ret?

  9. adrelanos commented on Jan 29, 2024

    @adrelanos
    ContributorAuthor

    If we don't know a more safe setting than the default, we could as well as leave the default?
    Not sure that will ever happen here but generally if the kernel gets a better, more secure default, we wouldn't want to have hardcoded it.
    So as a general rule I guess brevity as in not configuring things which have no effect should be preferred.

  10. raja-grewal commented on Jan 29, 2024

    @raja-grewal
    Contributor

    I'll leave it in for clarity but remove the hard-coding while providing an explanation.

    Thoughts?

  11. adrelanos commented on Jan 30, 2024

    @adrelanos
    ContributorAuthor

    The updated, linked PR (which no longer touched spec_rstack_overflow) looks good now.

    Keeping that PR a few days longer open to see if there's any other feedback.

  12. adrelanos commented on Feb 3, 2024

    @adrelanos
    ContributorAuthor

    Was merged and seems reflecting consensus.

    Please re-open or create a new issue should there still be something to cover.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions