Blame sysdeps/x86/tst-cet-legacy-8.c

Packit Service bbc580
/* Check incompatibility with legacy JIT engine.
Packit Service bbc580
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Service bbc580
   This file is part of the GNU C Library.
Packit Service bbc580
Packit Service bbc580
   The GNU C Library is free software; you can redistribute it and/or
Packit Service bbc580
   modify it under the terms of the GNU Lesser General Public
Packit Service bbc580
   License as published by the Free Software Foundation; either
Packit Service bbc580
   version 2.1 of the License, or (at your option) any later version.
Packit Service bbc580
Packit Service bbc580
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service bbc580
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service bbc580
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service bbc580
   Lesser General Public License for more details.
Packit Service bbc580
Packit Service bbc580
   You should have received a copy of the GNU Lesser General Public
Packit Service bbc580
   License along with the GNU C Library; if not, see
Packit Service bbc580
   <https://www.gnu.org/licenses/>.  */
Packit Service bbc580
Packit Service bbc580
#include <stdio.h>
Packit Service bbc580
#include <stdlib.h>
Packit Service bbc580
#include <x86intrin.h>
Packit Service bbc580
#include <sys/mman.h>
Packit Service bbc580
#include <support/test-driver.h>
Packit Service bbc580
#include <support/xsignal.h>
Packit Service bbc580
#include <support/xunistd.h>
Packit Service bbc580
Packit Service bbc580
/* Check that mmapped legacy code trigges segfault with -fcf-protection.  */
Packit Service bbc580
Packit Service bbc580
static int
Packit Service bbc580
do_test (void)
Packit Service bbc580
{
Packit Service bbc580
  /* NB: This test should trigger SIGSEGV on CET platforms.  If SHSTK
Packit Service bbc580
     is disabled, assuming IBT is also disabled.  */
Packit Service bbc580
  if (_get_ssp () == 0)
Packit Service bbc580
    return EXIT_UNSUPPORTED;
Packit Service bbc580
Packit Service bbc580
  void (*funcp) (void);
Packit Service bbc580
  funcp = xmmap (NULL, 0x1000, PROT_EXEC | PROT_READ | PROT_WRITE,
Packit Service bbc580
		 MAP_ANONYMOUS | MAP_PRIVATE, -1);
Packit Service bbc580
  printf ("mmap = %p\n", funcp);
Packit Service bbc580
  /* Write RET instruction.  */
Packit Service bbc580
  *(char *) funcp = 0xc3;
Packit Service bbc580
  funcp ();
Packit Service bbc580
  return EXIT_FAILURE;
Packit Service bbc580
}
Packit Service bbc580
Packit Service bbc580
#define EXPECTED_SIGNAL (_get_ssp () == 0 ? 0 : SIGSEGV)
Packit Service bbc580
#include <support/test-driver.c>