]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/x86/tst-cet-vfork-1.c
dc0b5984067a828fa4f02e8480b7026d33a2c74d
1 /* Verify that child of the vfork-calling function can't return when
2 shadow stack is in use.
3 Copyright (C) 2020-2021 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
24 #include <sys/types.h>
26 #include <x86intrin.h>
27 #include <support/test-driver.h>
28 #include <support/xsignal.h>
29 #include <support/xunistd.h>
31 __attribute__ ((noclone
, noinline
))
44 if ((p1
= vfork ()) == 0)
47 TEMP_FAILURE_RETRY (write (fd
[1], &p
, sizeof (p
)));
48 /* Child return should trigger SIGSEGV. */
53 puts ("vfork failed");
58 if (TEMP_FAILURE_RETRY (read (fd
[0], &p2
, sizeof (pid_t
)))
60 puts ("pipd read failed");
64 if (TEMP_FAILURE_RETRY (waitpid (p1
, &r
, 0)) != p1
)
65 puts ("waitpid failed");
67 puts ("pip write in child failed");
70 /* Parent exits immediately so that parent returns without triggering
71 SIGSEGV when shadow stack isn't in use. */
78 /* NB: This test should trigger SIGSEGV with shadow stack enabled. */
80 return EXIT_UNSUPPORTED
;
82 /* Child exits immediately so that child returns without triggering
83 SIGSEGV when shadow stack isn't in use. */
87 #define EXPECTED_SIGNAL (_get_ssp () == 0 ? 0 : SIGSEGV)
88 #include <support/test-driver.c>