[Bug libc/25093] New: sparc64 sigsetjmp buffer size mismatch

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] New: sparc64 sigsetjmp buffer size mismatch

glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

            Bug ID: 25093
           Summary: sparc64 sigsetjmp buffer size mismatch
           Product: glibc
           Version: 2.32
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: tg at mirbsd dot de
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Created attachment 12036
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12036&action=edit
patch

While reviewing a bug in µClibc-ng, which uses the same sigsetjmp structure as
glibc but actually uses the __mask_was_saved member during siglongjmp, I found
that said member was at offset 496, not 512 as expected (and therefore, the
structure was too short).

Looking at what it does, it calls the getcontext syscall, and the kernel side
of the structure has one more member in the FPU registers (which doesn’t exist
on sparc32 apparently and maybe therefore was missed?).

Adding the missing FPU member (patch attached) makes the offsetof the
__mask_was_saved member jump to 512 (at least in µClibc-ng, didn’t check
glibc).

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

Gregor Riepl <onitake at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |onitake at gmail dot com

--- Comment #1 from Gregor Riepl <onitake at gmail dot com> ---
Please correct me if I'm wrong, but there is no getcontext syscall in Linux.
This is a library function provided by libc:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/sparc64/getcontext.S;h=45572d77b2271099169a8a808e183069f57a318b;hb=HEAD

If there is a mismatch between the data structures used by sigsetjmp and
getcontext, then this is an internal inconsistency in the libc.

The implementation for sparc32 is here:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/sparc32/getcontext.S;h=5e92bec8150ab3aea9da8c555e95c4c53d45e677;hb=HEAD

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

--- Comment #2 from Andreas Schwab <[hidden email]> ---
See sparc64_get_context.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adhemerval.zanella at linaro dot o
                   |                            |rg,
                   |                            |glaubitz at physik dot fu-berlin.d
                   |                            |e, matorola at gmail dot com

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

--- Comment #3 from John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> ---
(In reply to Andreas Schwab from comment #2)
> See sparc64_get_context.

Is there a sparc32-equivalent to that?

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

--- Comment #5 from John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> ---
@Thorsten:

Your patch is incomplete, it currently breaks the build:

include ../include/libc-symbols.h       -DTOP_NAMESPACE=glibc
-DGEN_AS_CONST_HEADERS \
                   -MD -MP -MF /home/glaubitz/glibc/build/tcb-offsets.h.dT \
                   -MT '/home/glaubitz/glibc/build/tcb-offsets.h.d
/home/glaubitz/glibc/build/tcb-offsets.h'" \
          ../sysdeps/sparc/nptl/tcb-offsets.sym >
/home/glaubitz/glibc/build/tcb-offsets.hT
In file included from ../nptl/descr.h:24,
                 from ../sysdeps/sparc/nptl/tls.h:81,
                 from ../include/errno.h:25,
                 from ../sysdeps/unix/sysv/linux/sysdep.h:23,
                 from ../sysdeps/unix/sysv/linux/sparc/sysdep.h:23,
                 from ../sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h:22,
                 from <stdin>:1:
../include/setjmp.h:42:3: error: static assertion failed: "size of jmp_buf !=
640"
   42 |   _Static_assert (sizeof (type) == size, \
      |   ^~~~~~~~~~~~~~
../include/setjmp.h:55:1: note: in expansion of macro ‘TEST_SIZE’
   55 | TEST_SIZE (jmp_buf, JMP_BUF_SIZE);
      | ^~~~~~~~~
../include/setjmp.h:42:3: error: static assertion failed: "size of sigjmp_buf
!= 640"
   42 |   _Static_assert (sizeof (type) == size, \
      |   ^~~~~~~~~~~~~~
../include/setjmp.h:56:1: note: in expansion of macro ‘TEST_SIZE’
   56 | TEST_SIZE (sigjmp_buf, SIGJMP_BUF_SIZE);
      | ^~~~~~~~~
../include/setjmp.h:50:3: error: static assertion failed: "offset of
__mask_was_saved field of struct __jmp_buf_tag != 496"
   50 |   _Static_assert (offsetof (type, member) == offset, \
      |   ^~~~~~~~~~~~~~
../include/setjmp.h:63:1: note: in expansion of macro ‘TEST_OFFSET’
   63 | TEST_OFFSET (struct __jmp_buf_tag, __mask_was_saved,
      | ^~~~~~~~~~~
../include/setjmp.h:50:3: error: static assertion failed: "offset of
__saved_mask field of struct __jmp_buf_tag != 504"
   50 |   _Static_assert (offsetof (type, member) == offset, \
      |   ^~~~~~~~~~~~~~
../include/setjmp.h:65:1: note: in expansion of macro ‘TEST_OFFSET’
   65 | TEST_OFFSET (struct __jmp_buf_tag, __saved_mask,
      | ^~~~~~~~~~~

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

--- Comment #6 from John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> ---
Looks like you need to adjust the values in
sysdeps/unix/sysv/linux/sparc/sparc64/jmp_buf-macros.h.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

--- Comment #7 from Andreas Schwab <[hidden email]> ---
That would of course be an ABI break.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

--- Comment #8 from Thorsten Glaser <tg at mirbsd dot de> ---
Sorry, like I said, that was a patch against µClibc-ng which shares this header
and some of the related code with glibc, it was never intended to directly
apply to glibc alone, I just noticed that (IIRC) the size of the jump buffer
(if I misremember, then definitely the offset of the __mask_was_saved member)
was off.

I put it here so people knowledgeable about glibc can have a look at the change
and see whether something related is needed in glibc.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

Andreas Schwab <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at redhat dot com

--- Comment #9 from Andreas Schwab <[hidden email]> ---
It seems like this has been broken "forever", see commit a1303dc8dc.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/25093] sparc64 sigsetjmp buffer size mismatch

Sourceware - glibc-bugs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25093

--- Comment #10 from John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> ---
FWIW, I have tested Thorsten's patch on gcc202, with the necessary changes to
the constants I mentioned. It does build fine after but the testsuite results
don't improve (one more test is marked as "UNSUPPORTED" though).

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