public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/27709] New: arm: FAIL: debug/tst-longjmp_chk2
@ 2021-04-07 14:57 nsz at gcc dot gnu.org
  2021-04-12 13:28 ` [Bug libc/27709] " cvs-commit at gcc dot gnu.org
  2021-04-13  8:18 ` nsz at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: nsz at gcc dot gnu.org @ 2021-04-07 14:57 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27709

            Bug ID: 27709
           Summary: arm: FAIL: debug/tst-longjmp_chk2
           Product: glibc
           Version: 2.33
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: nsz at gcc dot gnu.org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

on arm i see

FAIL: debug/tst-longjmp_chk2

$ cat debug/tst-longjmp_chk2.out
not on alternate stack
 in signal handler
 on alternate stack
Didn't expect signal from child: got `Aborted'

which seems to happen if sp in setjmp is the bottom of the
sigaltstack and longjmp is called on the sigaltstack. i.e. the
following code crashes when compiled with -D_FORTIFIED_SOURCE=1


#include <signal.h>
#include <setjmp.h>

jmp_buf buf;

void handler (int sig)
{
  longjmp (buf, 1);
}

void setup_sigaltstack (char *p, size_t n)
{
  stack_t ss;
  struct sigaction sa;
  ss.ss_sp = p;
  ss.ss_size = n;
  ss.ss_flags = 0;
  sigaltstack (&ss, NULL);
  sigemptyset (&sa.sa_mask);
  sa.sa_handler = handler;
  sa.sa_flags = SA_ONSTACK;
  sigaction (SIGUSR1, &sa, NULL);
}

int main ()
{
  char alt[10000];
  setup_sigaltstack (alt, sizeof alt);
  if (setjmp (buf) == 0)
    raise (SIGUSR1);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/27709] arm: FAIL: debug/tst-longjmp_chk2
  2021-04-07 14:57 [Bug libc/27709] New: arm: FAIL: debug/tst-longjmp_chk2 nsz at gcc dot gnu.org
@ 2021-04-12 13:28 ` cvs-commit at gcc dot gnu.org
  2021-04-13  8:18 ` nsz at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-12 13:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27709

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Szabolcs Nagy <nsz@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8d4d77f6c848538cfb9e5ad0a14825e7ae4a1657

commit 8d4d77f6c848538cfb9e5ad0a14825e7ae4a1657
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Apr 7 12:45:53 2021 +0100

    arm: Fix an incorrect check in ____longjmp_chk [BZ #27709]

    An incorrect check in __longjmp_chk could fail on valid code causing

    FAIL: debug/tst-longjmp_chk2

    The original check was

      altstack_sp + altstack_size - setjmp_sp > altstack_size

    i.e. sp at setjmp was outside of the altstack range. Here we know that
    longjmp is called from a signal handler on the altstack (SS_ONSTACK),
    and that it jumps in the wrong direction (sp decreases), so the check
    wants to ensure the jump goes to another stack.

    The check is wrong when altstack_sp == setjmp_sp which can happen
    when the altstack is a local buffer in the function that calls setjmp,
    so the patch allows == too. This fixes bug 27709.

    Note that the generic __longjmp_chk check seems to be different.
    (it checks if longjmp was on the altstack but does not check setjmp,
    so it would not catch incorrect longjmp use within the signal handler).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/27709] arm: FAIL: debug/tst-longjmp_chk2
  2021-04-07 14:57 [Bug libc/27709] New: arm: FAIL: debug/tst-longjmp_chk2 nsz at gcc dot gnu.org
  2021-04-12 13:28 ` [Bug libc/27709] " cvs-commit at gcc dot gnu.org
@ 2021-04-13  8:18 ` nsz at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: nsz at gcc dot gnu.org @ 2021-04-13  8:18 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27709

Szabolcs Nagy <nsz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |2.34
             Status|NEW                         |RESOLVED

--- Comment #2 from Szabolcs Nagy <nsz at gcc dot gnu.org> ---
Fixed for 2.34.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-13  8:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 14:57 [Bug libc/27709] New: arm: FAIL: debug/tst-longjmp_chk2 nsz at gcc dot gnu.org
2021-04-12 13:28 ` [Bug libc/27709] " cvs-commit at gcc dot gnu.org
2021-04-13  8:18 ` nsz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).