Bug 20382 - getcontext and setjmp should have __attribute__((returns_twice))
Summary: getcontext and setjmp should have __attribute__((returns_twice))
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.23
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-18 08:27 UTC by Bernd Edlinger
Modified: 2016-07-22 13:28 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Edlinger 2016-07-18 08:27:35 UTC
Functions like getcontext and setjmp (maybe also swapcontext?)
should have the decl-attribute returns_twice in the header file.

This attribute is available starting from gcc-4.1.0 AFAICT.

Currently the glibc-headers are missing this attribute,
and GCC simply "knows" getcontext, setjmp, _setjmp, __sigsetjmp by name,
and injects the ECF_RETURNS_TWICE in special_function_p, but that
is a hack.

To my knowledge, SPARC and IA64 simply don't save all callee saved registers,
and therefore a missing returns_twice attribute may lead to invalid code,
other targets would probably not see the -Wclobber warning when appropriate.
Comment 1 Bernd Edlinger 2016-07-22 13:28:14 UTC
I forgot to mention: vfork does also need to be declared return_twice.