| •1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "tst-gcs-helper.h" |
| 20 |
|
| 21 |
#include <linux/prctl.h> |
| 22 |
#include <sys/prctl.h> |
| 23 |
#include <errno.h> |
| 24 |
|
| 25 |
static int |
| 26 |
do_test (void) |
| 27 |
{ |
| 28 |
|
| 29 |
if (!(getauxval (AT_HWCAP) & HWCAP_GCS)) |
| 30 |
FAIL_UNSUPPORTED ("kernel or CPU does not support GCS"); |
| 31 |
|
| 32 |
TEST_VERIFY (__check_gcs_status ()); |
| 33 |
|
| 34 |
|
| 35 |
int res = prctl (PR_SET_SHADOW_STACK_STATUS, 0, 0, 0, 0); |
| 36 |
if (res) |
| 37 |
{ |
| 38 |
TEST_COMPARE (errno, EBUSY); |
| 39 |
#ifdef GCS_SHOULD_UNLOCK |
| 40 |
FAIL_EXIT1 ("GCS was not unlocked (was supposed to): %m"); |
| 41 |
#else |
| 42 |
TEST_VERIFY (__check_gcs_status ()); |
| 43 |
#endif |
| 44 |
} |
| 45 |
else |
| 46 |
{ |
| 47 |
#ifdef GCS_SHOULD_UNLOCK |
| 48 |
TEST_VERIFY (!__check_gcs_status ()); |
| 49 |
puts ("GCS unlocked successfully"); |
| 50 |
#else |
| 51 |
FAIL_EXIT1 ("GCS was unlocked (was not supposed to)"); |
| 52 |
#endif |
| 53 |
} |
| 54 |
|
| 55 |
return 0; |
| 56 |
} |
| 57 |
|
| 58 |
#include <support/test-driver.c> |