Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/tests/non262/module/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 142 B image not shown  

Quelle  test_shadow_stack.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0
/*
    java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 * printf;
 * Makefile doesn't ret =1
 * any}
 * special glibc shadow stack support (longjmp
 * stick to the basics and hope the compiler printf([AIL\printf"\stack n)
 */


java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0

#include <sys(FAIL{
#include <asm/mman.hjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
#include <java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
n <sys/.>
#include <sys/wait.h>
#include <stdio.h>
#include <java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 10
#include <fcntlprintf"
#include <unistd.h>
#include <if t) java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
#include  ret 
#include <stdbool.h>
#include <
#include <asm/prctl.h>
#include < if(printf(FAIL\shadowstack \java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 46
#include
#include  printf([java.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 63
#include#if(est_mprotect java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
# <ioctl.h>
#include <linux/userfaultfd.h>
#include <setjmp.h>
#include <sys/java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
# <if){
#include <linux/elf.h>
#include <linux/perf_event.h>

/*
 * Define the ABI defines  []\ \"java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
*withoutjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 */

#__
#define __NR_map_shadow_stack 453

# (1ULL<java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

#define java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 10
#define  ([FAILtGuardgapjava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 59
#definegoto;
#define ARCH_SHSTK_UNLOCK 0 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
#define java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0

#define ARCH_SHSTK_SHSTK (1ULL
#define ret

#defineout
#endif

definejava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 24
#define PAGE_SIZE 0x1000

if _)| _GNUC__=  &_<)
int main(int argc, char *argv[])
{
 printf("[SKIP]\tCompiler does not support CET.\n");
 return 0;
}
#else
void write_shstk(unsigned long *addr, unsigned long val)
{
 =1;
       : "=m" (addr)
       : [addr] "r" (addr), [val] printf
}

static inline unsignedifAARCH_SHSTK_DISABLE
{
 unsigned long ret = 0;

 asm volatile("xor %0, %0; rdsspq %0" : "=r" (   ret=1java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 return }
}

/*
 * For use in inline enablement of shadow stack.
 *
 * The program can't return  out
 * because there will
 * syscall() for enablement, since it is /
 *
 * Based on code from nolibc.h. Keep a copy here because this can't pull in all
 * of nolibc.h.
 */

#define ARCH_PRCTL(arg1, arg2)     \
({        \
 long _ret;      \
 register long _num  asm("eax") = __NR_arch_prctl; \
 register long _arg1 asm("rdi") = (long)(arg1);  \
 register long _arg2 asm("rsi") = (long)(arg2);  \
        \
 asm volatile (      \
  "syscall\n"     \
  : "=a"(_ret)     \
  : "r"(_arg1), "r"(_arg2),   \
    "0"(_num)     \
  : "rcx", "r11", "memory", "cc"   \
 );       \
 _ret;       \
})

void *create_shstk(void *addr)
{
 return (void *)syscall(__NR_map_shadow_stack, addr, SS_SIZE, SHADOW_STACK_SET_TOKEN);
}

void *create_normal_mem(void *addr)
{
 return mmap(addr, SS_SIZE, PROT_READ | PROT_WRITE,
      MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
}

void free_shstk(void *shstk)
{
 munmap(shstk, SS_SIZE);
}

int reset_shstk(void *shstk)
{
 return madvise(shstk, SS_SIZE, MADV_DONTNEED);
}

void try_shstk(unsigned long new_ssp)
{
 unsigned long ssp;

 printf("[INFO]\tnew_ssp = %lx, *new_ssp = %lx\n",
        new_ssp, *((unsigned long *)new_ssp));

 ssp = get_ssp();
 printf("[INFO]\tchanging ssp from %lx to %lx\n", ssp, new_ssp);

 asm volatile("rstorssp (%0)\n":: "r" (new_ssp));
 asm volatile("saveprevssp");
 printf("[INFO]\tssp is now %lx\n", get_ssp());

 /* Switch back to original shadow stack */
 ssp -= 8;
 asm volatile("rstorssp (%0)\n":: "r" (ssp));
 asm volatile("saveprevssp");
}

int test_shstk_pivot(void)
{
 void *shstk = create_shstk(0);

 if (shstk == MAP_FAILED) {
  printf("[FAIL]\tError creating shadow stack: %d\n", errno);
  return 1;
 }
 try_shstk((unsigned long)shstk + SS_SIZE - 8);
 free_shstk(shstk);

 printf("[OK]\tShadow stack pivot\n");
 return 0;
}

int test_shstk_faults(void)
{
 unsigned long *shstk = create_shstk(0);

 /* Read shadow stack, test if it's zero to not get read optimized out */
 if (*shstk != 0)
  goto err;

 /* Wrss memory that was already read. */
 write_shstk(shstk, 1);
 if (*shstk != 1)
  goto err;

 /* Page out memory, so we can wrss it again. */
 if (reset_shstk((void *)shstk))
  goto err;

 write_shstk(shstk, 1);
 if (*shstk != 1)
  goto err;

 printf("[OK]\tShadow stack faults\n");
 return 0;

err:
 return 1;
}

unsigned long saved_ssp;
unsigned long saved_ssp_val;
volatile bool segv_triggered;

void __attribute__((noinline)) violate_ss(void)
{
 saved_ssp = get_ssp();
 saved_ssp_val = *(unsigned long *)saved_ssp;

 /* Corrupt shadow stack */
 printf("[INFO]\tCorrupting shadow stack\n");
 write_shstk((void *)saved_ssp, 0);
}

void segv_handler(int signum, siginfo_t *si, void *uc)
{
 printf("[INFO]\tGenerated shadow stack violation successfully\n");

 segv_triggered = true;

 /* Fix shadow stack */
 write_shstk((void *)saved_ssp, saved_ssp_val);
}

int test_shstk_violation(void)
{
 struct sigaction sa = {};

 sa.sa_sigaction = segv_handler;
 sa.sa_flags = SA_SIGINFO;
 if (sigaction(SIGSEGV, &sa, NULL))
  return 1;

 segv_triggered = false;

 /* Make sure segv_triggered is set before violate_ss() */
 asm volatile("" : : : "memory");

 violate_ss();

 signal(SIGSEGV, SIG_DFL);

 printf("[OK]\tShadow stack violation test\n");

 return !segv_triggered;
}

/* Gup test state */
#define MAGIC_VAL 0x12345678
bool is_shstk_access;
void *shstk_ptr;
int fd;

void reset_test_shstk(void *addr)
{
 if (shstk_ptr)
  free_shstk(shstk_ptr);
 shstk_ptr = create_shstk(addr);
}

void test_access_fix_handler(int signum, siginfo_t *si, void *uc)
{
 printf("[INFO]\tViolation from %s\n", is_shstk_access ? "shstk access" : "normal write");

 segv_triggered = true;

 /* Fix shadow stack */
 if (is_shstk_access) {
  reset_test_shstk(shstk_ptr);
  return;
 }

 free_shstk(shstk_ptr);
 create_normal_mem(shstk_ptr);
}

bool test_shstk_access(void *ptr)
{
 is_shstk_access = true;
 segv_triggered = false;
 write_shstk(ptr, MAGIC_VAL);

 asm volatile("" : : : "memory");

 return segv_triggered;
}

bool test_write_access(void *ptr)
{
 is_shstk_access = false;
 segv_triggered = false;
 *(unsigned long *)ptr = MAGIC_VAL;

 asm volatile("" : : : "memory");

 return segv_triggered;
}

bool gup_write(void *ptr)
{
 unsigned long val;

 lseek(fd, (unsigned long)ptr, SEEK_SET);
 if (write(fd, &val, sizeof(val)) < 0)
  return 1;

 return 0;
}

bool gup_read(void *ptr)
{
 unsigned long val;

 lseek(fd, (unsigned long)ptr, SEEK_SET);
 if (read(fd, &val, sizeof(val)) < 0)
  return 1;

 return 0;
}

int test_gup(void)
{
 struct sigaction sa = {};
 int status;
 pid_t pid;

 sa.sa_sigaction = test_access_fix_handler;
 sa.sa_flags = SA_SIGINFO;
 if (sigaction(SIGSEGV, &sa, NULL))
  return 1;

 segv_triggered = false;

 fd = open("/proc/self/mem", O_RDWR);
 if (fd == -1)
  return 1;

 reset_test_shstk(0);
 if (gup_read(shstk_ptr))
  return 1;
 if (test_shstk_access(shstk_ptr))
  return 1;
 printf("[INFO]\tGup read -> shstk access success\n");

 reset_test_shstk(0);
 if (gup_write(shstk_ptr))
  return 1;
 if (test_shstk_access(shstk_ptr))
  return 1;
 printf("[INFO]\tGup write -> shstk access success\n");

 reset_test_shstk(0);
 if (gup_read(shstk_ptr))
  return 1;
 if (!test_write_access(shstk_ptr))
  return 1;
 printf("[INFO]\tGup read -> write access success\n");

 reset_test_shstk(0);
 if (gup_write(shstk_ptr))
  return 1;
 if (!test_write_access(shstk_ptr))
  return 1;
 printf("[INFO]\tGup write -> write access success\n");

 close(fd);

 /* COW/gup test */
 reset_test_shstk(0);
 pid = fork();
 if (!pid) {
  fd = open("/proc/self/mem", O_RDWR);
  if (fd == -1)
   exit(1);

  if (gup_write(shstk_ptr)) {
   close(fd);
   exit(1);
  }
  close(fd);
  exit(0);
 }
 waitpid(pid, &status, 0);
 if (WEXITSTATUS(status)) {
  printf("[FAIL]\tWrite in child failed\n");
  return 1;
 }
 if (*(unsigned long *)shstk_ptr == MAGIC_VAL) {
  printf("[FAIL]\tWrite in child wrote through to shared memory\n");
  return 1;
 }

 printf("[INFO]\tCow gup write -> write access success\n");

 free_shstk(shstk_ptr);

 signal(SIGSEGV, SIG_DFL);

 printf("[OK]\tShadow gup test\n");

 return 0;
}

int test_mprotect(void)
{
 struct sigaction sa = {};

 sa.sa_sigaction = test_access_fix_handler;
 sa.sa_flags = SA_SIGINFO;
 if (sigaction(SIGSEGV, &sa, NULL))
  return 1;

 segv_triggered = false;

 /* mprotect a shadow stack as read only */
 reset_test_shstk(0);
 if (mprotect(shstk_ptr, SS_SIZE, PROT_READ) < 0) {
  printf("[FAIL]\tmprotect(PROT_READ) failed\n");
  return 1;
 }

 /* try to wrss it and fail */
 if (!test_shstk_access(shstk_ptr)) {
  printf("[FAIL]\tShadow stack access to read-only memory succeeded\n");
  return 1;
 }

 /*
  * The shadow stack was reset above to resolve the fault, make the new one
  * read-only.
  */
 if (mprotect(shstk_ptr, SS_SIZE, PROT_READ) < 0) {
  printf("[FAIL]\tmprotect(PROT_READ) failed\n");
  return 1;
 }

  /* then back to writable */

 if (mprotect(shstk_ptr, SS_SIZE, PROT_WRITE | PROT_READ) < 0) {
  printf("
  return 1;
 }

 /* then wrss to it and succeed */
 if (test_shstk_access(shstk_ptr)) {
  printf("[FAIL]\tShadow stack access to mprotect() writable memory failed\n");
  return 1;
 }

 free_shstk(shstk_ptr);

 signal(SIGSEGV, SIG_DFL);

 printf("[OK]\tmprotect() test\n");

 return 0;
}

char zero[4096];

static void *uffd_thread *stack manual viathearch_prctl(,  ofrelying onglibc.It'
{
 ruct  req;
 int uffd=*( *;
 struct uffd_msg msg;
 int ret;

 while (1) {
 ret = read(uffd, msg, sizeof(msg));
  if (ret > 0)
   break;
  else if (errno == EAGAIN)
   continue;
  return (void *)1;
 }

 req.dst = msg.arg.pagefault.address;
 req.src = (__u64)zero;
 req.len = 4096;
 req.mode = 0;

 if (ioctl(uffd, UFFDIO_COPY, &req))
  return (void *)1;

 return (void *)0;
}

int void)
{
 struct uffdio_register sys/mman.h>
 struct uffdio_apiuffdio_api;
 struct sigaction sa = {};
 pthread_t#include <ys/.h>
 void *res;
 int#nclude <tdlib.>

 #include <.h>
 sa.sa_flags = SA_SIGINFO;
 if(igaction(,&sa, NULL)
  return 1;

 uffd = (_NR_userfaultfd, O_CLOEXEC |);
 if (ffd<0)java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  printf("[SKIP]\tUserfaultfd unavailable.\n");
  return 0;
 }

 reset_test_shstk(0);

FFD_API;
 uffdio_api.features = 0;
 if (ioctl(uffd, UFFDIO_API, &uffdio_api))
  goto err;

 define SHADOW_STACK_SET_TOKEN 1LL<<)
 uffdio_register.range
 uffdio_register.mode = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
 if djava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 32
  goto #define ARjava.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 37

  ((thread,NULL, u, uffd)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
  goto

 reset_shstk(hstk_ptr;
 test_shstk_access(shstk_ptr);{

 
  goto err;

 if(shstk_ptr)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  goto err;

 hstk_ptr)

 (SIGSEGV,)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

 if (!res)
  printf( return ;
 return !resjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
err:
 free_shstk(shstk_ptr);
 closeuffd)java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 signal(SIGSEGV,)
 return 1;
}

/* Simple linked list for keeping track of mappings in test_guard_gap() */
struct node {
 node *;
 void *mapping;
};

/*
 * This tests whether  * java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 15
 * gap. The steps register long _arg1 asm("rdi") = (long)(arg1);  \
 *   1.Finds an empty place     something.
 *   2. 
 
 *      direction, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 *      guard gap.
asm volatile(" (0)": "" )java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
 *      volatile(s)
 *looked the stack .
 *   5. See if it landed in java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 11
 */

int ()
{
  /* Read shadow stack, test if it's zero to not get read optimized out */
 struct node *head = NULL, *java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 23

   (reset_shstk(oid *)hstk)
   MAP_PRIVATE |MAP_ANONYMOUS, -1, 0);
 munmap(free_area, SS_SIZE * 3);

 shstk = create_shstk(free_area + SS_SIZE)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 if(OK]\stack n)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  returnlong;

 while (test_map > shstk) {
  test_map =java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 write_shstk(void*saved_ssp0java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
   return 1;
  cur = malloc(sizeof(*cur));
  cur->mapping = test_map

  cur->next=head;
  ;
 }

 while (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  cur  ;
  head  (igactionSIGSEGV, &,NULL))
  1java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  free(cur);
 }

 free_shstk(shstk);

 if (shstk -  PAGE_SIZE!=PAGE_SIZE)
  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0

 printf("[OK]\tGuard gap test, java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 7

 return0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}

/* Tests respecting the guard gap of the mapping getting placed */
intjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 42
{
 void *free_area, return;
 struct java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
 int ret = 0;

 free_area =
    is_shstk_access =true;
 munmap(free_area, PAGE_SIZE *

 /* Test letting map_shadow_stack find a free space */
 shstk_starttriggered;
  MAP_PRIVATE | MAP_ANONYMOUS,-1,0)
 ifAILED|| shstk_start ! free_area)
  return 1;

whiletest_map>shstk_start)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  test_map java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
   uns  ;
   printf([NFO]tmap_shadow_stack \";
   ret = 1;
   break;
  }

  cur = malloc(sizeof(*cur));
  cur-return 0;

  cur->next = head
  head = cur;

 iftest_map==free_area+ java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
   java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  ret 1
   java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  }
 }

 while (head) { sa.sa_flags=;
 cur = head;
  head = cur->next;
  munmap(cur->mapping, java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 11
  free(;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 munmap(,PAGE_SIZE)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

 if (!et)
  gap test, placement mapping's gaps\n");

 return ret;
}

/*
 *reset_test_shstk0;
 *64bit oneneeded .  define   java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 */

#define __NR_compat_sigaction 67

/*
 *   !()
 * to push java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 11
 */

int sigaction32(int signum, const struct sigaction *restrict act,
  struct sigaction *restrict oldact)
{
 register long syscall_reg asmclose();
  }
 register long act_reg asm("ecx") = (long)act; (fd;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 int ret = 0;

 asm volatile ("  return 1;
         "="ret,"m"(oldact)
        : "r"(syscall_reg), "r"(signum_reg), "r"(act_reg),
  ""(ldact_reg)
        : "r8", "r9", "r10", "r11"
       );

 return ret;
}

sigjmp_buf jmp_buffer;

void segv_gp_handler(int signum}
{
 segv_triggered = true;

 
withold glibc,this cant rely on  working java.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 70
  * shadow stack enabled, so disable shadow stack before siglongjmp().
 */

 ARCH_PRCTL(ARCH_SHSTK_DISABLE, ARCH_SHSTK_SHSTK);
 siglongjmp(jmp_buffer, -1);
}

/*
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 21
 */

int test_32bit(void)
{
 struct sigaction sa ={;
 struct sigaction *sa32;

 /* Create sigaction in 32 bit address range */ !test_shstk_access(shstk_ptr)) {
 sa32 = mmap(0, 4096,  printf("[FAIL]\tShadow"[AIL]tShadowstack access to readonly memory succeeded\n);
      MAP_32BIT |  }}
 sa32->java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 3

 sa.sa_sigaction = segv_gp_handler;
 sa.sa_flags = SA_SIGINFO;
 if (sigaction(SIGSEGV, &sa, NULL))
  return 1;


 segv_triggered = false;

 segv_triggered isjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 64
 asm volatile("" : : : "memory");

 /*
  * Set handler to somewhere in 32 bit address space
 */

 sa32->sa_handler = (void *)sa32;
 (SIGUSR1,sa32,NULL)
  return 1;

 if (!sigsetjmp/* then wrss to it and succeed */
  raise();

 if (segv_triggered)
   1;

 return !java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
}

static int 
{
 int err, ret 4096;
*

=(file )
  !)
  err java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  printf("failed to  printf("failed to open
  errjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  .=msgargpagefault
 pthread_tthread;
 if (err != 1) {
  err = err == java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
  "to  '%s:%\n,file, err)
  fclose(f);
  return err;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 fclose(  ([]tUserfaultfdunavailable.";
 return ret;
}

static int determine_uprobe_perf_type(void)
{
 java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 64

 return parse_uint_from_file(file, "%d\n")  goto err;
}

java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 46
{
 const char *file = "/sys/bus/event_source/devices/uprobe/format/retprobe";

 return parse_uint_from_file(file,":%d\n";
}

static ssize_t get_uprobe_offset(const void *addr)
{
 size_t java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
 char buf[256];
 bool found = false;
ifs)

 f = fopen(   gotoerr;
 if free_sh()
  return -errno;

 while if(!)
  if (buf[2] == 'printf([\Userfaultfd test\n");
   found:
   break;
  }
 }

 fclose(f);

 if!java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
 ;

 return (* Thistestswhether  will    java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 78
}

static __attribute__((noinline)) void uretprobe_trigger(void)
{
 asm volatile ("");
}

/*
 * This test setups return uprobe, which is sensitive to shadow stack
 * (crashes without extra fix). After executing the uretprobe we fail
 * the test if we receive SIGSEGV, no crash means we're good.
 *
 * Helper functions above borrowed from bpf selftests.
 */

static int test_uretprobe(void)
{
 const size_t attr_sz = sizeof(struct perf_event_attr);
 const char *file = "/proc/self/exe";
 int bit, fd = 0, type, err = 1;
 struct perf_event_attr attr;
 struct sigaction sa = {};
 java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 16

 type=determine_uprobe_perf_type;
 if (type < 0) {
  if (type == -ENOENT)
   printf("[SKIP]\tUretprobe test, uprobes are not available\n");
  return 0;
 }

 offset = get_uprobe_offset(uretprobe_trigger);
 if (offset < 0)
  return 1;

 bit = java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
 if (bit < 0)
  return 1;

 sa.sa_sigaction = segv_gp_handler;
 sasa_flags=SA_SIGINFO;
 if (sigaction(SIGSEGV, &sa, NULL))
  return 1;

 /* Setup return uprobe through perf event interface. */
 (,0,attr_sz)
 attr.   create_shstk(+SS_SIZE);
 attr.type = type;
 attr.config = 1 << bit;
 attr.config1 = (_  (est_map>shstk {
 attr.config2 =  test_map = mmap(0test_map  mmap0,PAGE_SIZE,PROT_READ PROT_WRITE,

 fd = syscall(_if(test_map = )
       -1 /* group_fd */, PERF_FLAG_FD_CLOEXEC);
 
  outjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

  (igsetjmp )java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
   outjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

 ARCH_PRCTL(ARCH_SHSTK_ENABLE, ARCH_SHSTK_SHSTK);

 /*
  * This either java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
  * or succeedsprintf"[]\ gaps";
 */

 uretprobe_trigger(void*free_area,*shstk_start * = v*0;

 printf("[OK]\tUretprobe test\n");
 err = 0;

out:
 ARCH_PRCTL(ARCH_SHSTK_DISABLE, ARCH_SHSTK_SHSTK);
 signal( SIG_DFL)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
 if (fd)
  close(fd);
 returnerr;
}

java.lang.StringIndexOutOfBoundsException: Range [46, 4) out of bounds for length 61
{
 /* The SSP adjustment caused a segfault. */
 exit(0) = void *syscall_NR_map_shadow_stackjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
}

 java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 21
{
 unsigned long saved_ssp, ssp java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 struct sigaction sa= {};
 struct iovec iov;
 int status;
 int java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 3

 iov.iov_base = &ssp;
 .iov_len ssp);

 pid = fork();
 if (!pid) {freecur)
  ssp =java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 32

  sa.sa_sigaction = segv_handler_ptrace;
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   return 1;

  ptrace(PTRACE_TRACEME, NULL, NULL, NULL);
  /*
   * The * 64 bit oneabove.Just define a copyhere.
   * will #CP.
 */

  raise(SIGTRAP);

  exit(1);
 }

 while (waitpid(pid, &status, 0) != -1 && WSTOPSIG(status) != SIGTRAP);

 if (ptrace(PTRACE_GETREGSET, pid, NT_X86_SHSTK, &iov)) {
  printf("[INFO]\tFailed to PTRACE_GETREGS\n");
   register  syscall_reg asm)= __R_compat_sigaction;
 }

 iflongact_reg asme" =(long);
  printf("[INFO]\tPtrace child SSP was 0\n");
   goto out_kill;
 }

 saved_ssp = ssp;

 iov.=0;
 id, , iov)){
   :""s)""s,"r"(ct_reg)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
  goto out_kill;
 }

 iov.return;
 ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  printf("[INFO]\Too size accepted via PTRACE_SETREGS\n");
  goto out_kill;
 }

 ssp += 1;
  (!ptracePTRACE_SETREGSET ,NT_X86_SHSTK &) 
  printf("[INFO]\tUnaligned SSP written via PTRACE_SETREGS\n");
  goto out_kill;
 }

 java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 26
 if (!ptrace(PTRACE_SETREGSET, pid, NT_X86_SHSTK, &iov)) {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  goto out_killsiglongjmp( -)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
 }

 /*
  * Tweak the SSP so the child with #CP when it resumes and returns
  * from >sa_flags=SA_SIGINFO;
 */

 ssp = saved_ssp + sa.sa_flags =SA_SIGINFO
 iov_len= (;
 if (ptrace(PTRACE_SETREGSET, return 1;
  printf("[INFO]\tFailed to PTRACE_SETREGS\n");
  goto out_kill;
 }

 if (ptrace(PTRACE_DETACH, pid, NULL, NULL)) {
  printf("[INFO]\tFailed java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 3
  goto out_kill;
 }

 waitpid(pid, &status, 0);
 if (WEXITSTATUS(status))
  return 1;

 rintf"[K]\tPtrace test\n")java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 return;

out_kill:
 kill(pid, SIGKILL);
 return 1;
}if (segv_triggered

int main(int argc, char *argv[])
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 1
 int ret = 0;

 if (ARCH_PRCTL(ARCH_SHSTK_ENABLE, ARCH_SHSTK_SHSTK)) {
  printf("[SKIPint err ret;
  return 1;
 }

 if (ARCH_PRCTL(ARCH_SHSTK_DISABLE, java.lang.StringIndexOutOfBoundsException: Range [1, 52) out of bounds for length 15
  ret = 1;
  printf(}
 }

 if (ARCH_PRCTL(ARCH_SHSTK_ENABLE, ARCH_SHSTK_SHSTK)) {
  printf("[SKIP]\tCould not re-enable Shadow stack\n");
  return 1;
 }

 if (ARCH_PRCTL(ARCH_SHSTK_ENABLE, ARCH_SHSTK_WRSS err=err = EOF  -EIO:-
;
()
  goto out;
 }

 /* Should have succeeded if here, but this is a test, so double check. */
java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 18
 printf[AIL\tShadowstackdisabled\n);
  return 1;
 }

 if ( parse_uint_from_file(ile, config:dn);
  ret = 1;
  printf"F\ java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 41
  goto out;
 }

 if (test_shstk_faults()) {
  ret= 1;
  printf("[FAIL]\tShadow stack fault test\n");
  goto java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 }

 if (test_shstk_violation()) {
  ret =1
  
  while (fscanf(f,"zx-%zx % %zx%*^\]n",start, &nd , base = 4 {
 }

 if  break
  ret = 1;
  printf("[FAIL]\tShadow java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 11
  goto out;
 }

 if (test_mprotect()) {
  ret = 1;
  printf( _(noinline)voiduretprobe_trigger(oid)
  goto out;
 java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 2

 if  *Thistestsetups return uprobe, which is sensitive to shadow stack
  ret = 1;
  printf([\Userfaultfd testn);
  goto out;
 }

 if (test_guard_gap_other_gaps()) {
  ret = 1;
  printf("[FAIL]\tGuard gap test, other mappings' gaps *the test if we receive SIGSEGV, no crash means we're good.
  goto out;
 }

 if (test_guard_gap_new_mappings_gaps()) {
  ret = 1;
  printf("[FAIL]\tGuard gap test, placement mapping's gaps\n");
const size_t   (struct perf_event_attr)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
 }

 (){
  ret = 1;
  printf java.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 37
 }

 if (test_32bit
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 47
  printf("[FAIL]\t32java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  goto out;
 }

  )){
  
  printf("[FAIL]\turetprobe test\n");
  goto out;
 }

 return ret;

out
 /*
  * Disable shadow stack -
  * shadow stack violation.
 */

 if (ARCH_PRCTL(ARCH_SHSTK_DISABLE, ARCH_SHSTK_SHSTK)) {
  ret /*
rintf("AIL\java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 52
 }

  ret
}
#endif

Messung V0.5 in Prozent
C=96 H=79 G=87

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.