]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / ____longjmp_chk.c
CommitLineData
d614a753 1/* Copyright (C) 2009-2020 Free Software Foundation, Inc.
b8bb339f
UD
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
b8bb339f
UD
18
19#include <errno.h>
20#include <sysdep.h>
21#include <setjmp.h>
22#include <bits/setjmp.h>
23#include <stdlib.h>
24#include <unistd.h>
25#include <stdio.h>
6dfeb524
JJ
26#include <stdint.h>
27#include <signal.h>
28#include <sys/syscall.h>
2f438e20
SL
29
30#define __longjmp ____longjmp_chk
b8bb339f
UD
31
32#define CHECK_SP(env, guard) \
33 do \
34 { \
35 uintptr_t cur_sp; \
36 uintptr_t new_sp = env->__gregs[9]; \
31cf3942 37 __asm__ ("lr %0, %%r15" : "=r" (cur_sp)); \
b8bb339f
UD
38 new_sp ^= guard; \
39 if (new_sp < cur_sp) \
6dfeb524
JJ
40 { \
41 stack_t oss; \
42 INTERNAL_SYSCALL_DECL (err); \
43 int res = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss); \
44 if (!INTERNAL_SYSCALL_ERROR_P (res, err)) \
45 { \
46 if ((oss.ss_flags & SS_ONSTACK) == 0 \
47 || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \
e3b7670b 48 < oss.ss_size)) \
6dfeb524
JJ
49 __fortify_fail ("longjmp causes uninitialized stack frame");\
50 } \
51 } \
b8bb339f
UD
52 } while (0)
53
2f438e20 54#include "__longjmp.c"