Bug 21050 - Prevent tailcall optimizations of libdl functions
Summary: Prevent tailcall optimizations of libdl functions
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2017-01-14 06:33 UTC by Yuri Gribov
Modified: 2017-01-25 11:19 UTC (History)
5 users (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Gribov 2017-01-14 06:33:40 UTC
Some libdl functions rely on return address to figure out the calling DSO and then use this information in computation (e.g. output of dlsym depends on which library called it).

As reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66826 this may break under tailcall optimization i.e. in cases like

  return dlsym(...);

Rich Felker suggested that adding new GCC attribute is a possible solution. Another option would be to hack around dlsym to prevent tailcall from happening e.g.

  #define dlsym(h, name) { volatile void *sym = dlsym(h, name); return (void *)sym; }

Which solution is more appropriate for Glibc?
Comment 1 Yuri Gribov 2017-01-25 08:19:41 UTC
Pinged libc-alpha: https://sourceware.org/ml/libc-alpha/2017-01/msg00455.html