Skip to content

BM/cet: add signal/thread/legacy SHSTK and kernel IBT cases - #603

Merged
hongyuni merged 1 commit into
intel:mainfrom
hongyuni:sync/cet-20260916
Sep 16, 2026
Merged

hongyuni merged 1 commit into
intel:mainfrom
hongyuni:sync/cet-20260916

Conversation

@hongyuni

Copy link
Copy Markdown
Contributor

Add the missing CET shadow stack cases into BM/cet:

  • sig_stack.c: CET signal stack test, verify the signal-triggered function is protected by SHSTK (bare "a" access check and cp_test "s" violation).
  • cet_thread.c: SHSTK violation in a new thread should be #CP blocked. Accept upstream SEGV_CPERR(3) in addition to the legacy si_code 8|10 so the case works on mainline kernels.
  • glibc_shstk_test_legacy: build glibc_shstk_test.c without CET protection (NOCETFLAGS) and verify none of the violation params trigger #CP (no_cp).
  • test_shadow_stack.c: treat an EINVAL from UFFDIO_REGISTER on a shadow stack VMA as SKIP, since recent kernels reject userfaultfd registration of special VMAs.

Kernel IBT b1/b2 cases:

  • cet_tests.sh: kmod_ibt_illegal triggers a kernel-space missing-ENDBR #CP; block the case unless the kernel is booted with ibt=warn (and block on ibt=off) to avoid crashing the host.
  • load_cet_driver block_tests with a clear message pointing at the required kernel-devel/headers when cet_ioctl.ko is missing.
  • cet_driver/Makefile: fail early with an actionable error when the kernel build dir is absent, and suppress the module's missing-prototype/declaration warnings on -Werror kernels.
  • cet_driver/cet_ioctl.h: guard CPUID_LEAF_XSTATE so it does not conflict with the kernel's own definition.

Document the ibt=warn requirement in the tests list and README, and wire the new binaries into Makefile, CMakeLists.txt and .gitignore.

(cherry picked from commit 8e9069c323d408fcd75b4b61ee669b8fe3fc5425)

Add the missing CET shadow stack cases into BM/cet:

- sig_stack.c: CET signal stack test, verify the signal-triggered
  function is protected by SHSTK (bare "a" access check and cp_test
  "s" violation).
- cet_thread.c: SHSTK violation in a new thread should be #CP blocked.
  Accept upstream SEGV_CPERR(3) in addition to the legacy si_code 8|10
  so the case works on mainline kernels.
- glibc_shstk_test_legacy: build glibc_shstk_test.c without CET
  protection (NOCETFLAGS) and verify none of the violation params
  trigger #CP (no_cp).
- test_shadow_stack.c: treat an EINVAL from UFFDIO_REGISTER on a
  shadow stack VMA as SKIP, since recent kernels reject userfaultfd
  registration of special VMAs.

Kernel IBT b1/b2 cases:

- cet_tests.sh: kmod_ibt_illegal triggers a kernel-space missing-ENDBR
  #CP; block the case unless the kernel is booted with ibt=warn (and
  block on ibt=off) to avoid crashing the host.
- load_cet_driver block_tests with a clear message pointing at the
  required kernel-devel/headers when cet_ioctl.ko is missing.
- cet_driver/Makefile: fail early with an actionable error when the
  kernel build dir is absent, and suppress the module's
  missing-prototype/declaration warnings on -Werror kernels.
- cet_driver/cet_ioctl.h: guard CPUID_LEAF_XSTATE so it does not
  conflict with the kernel's own definition.

Document the ibt=warn requirement in the tests list and README, and
wire the new binaries into Makefile, CMakeLists.txt and .gitignore.

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Farrah Chen <farrah.chen@intel.com>
(cherry picked from commit 8e9069c323d408fcd75b4b61ee669b8fe3fc5425)
@hongyuni
hongyuni merged commit e6e4521 into intel:main Sep 16, 2026
5 checks passed
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.

2 participants