Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8acd8f8

Browse files
committed
On NetBSD, force dynamic symbol resolution at postmaster start.
The default of lazy symbol resolution means that when the postmasterfirst reaches the select() call in ServerLoop, it'll need to resolvethe link to that libc entry point. NetBSD's dynamic loader takesan internal lock while doing that, and if a signal interrupts theoperation then there is a risk of self-deadlock should the signalhandler do anything that requires that lock, as several of thepostmaster signal handlers do. The window for this is pretty narrow,and timing considerations make it unlikely that a signal would arriveright then anyway. But it's semi-repeatable on slow single-CPUmachines, and in principle the race could happen with any hardware.The least messy solution to this is to force binding of dynamicsymbols at postmaster start, using the "-z now" linker option.While we're at it, also use "-z relro" so as to provide a smallsecurity gain.It's not entirely clear whether any other platforms share thisissue, but for now we'll assume it's NetBSD-specific. (We mightlater try to use "-z now" on more platforms for performancereasons, but that would not likely be something to back-patch.)Report and patch by me; the idea to fix it this way is fromAndres Freund.Discussion:https://postgr.es/m/3384826.1661802235@sss.pgh.pa.us
1 parent05f9084 commit8acd8f8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎src/template/netbsd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,12 @@
22

33
# Extra CFLAGS for code that will go into a shared library
44
CFLAGS_SL="-fPIC -DPIC"
5+
6+
# We must resolve all dynamic linking in the core server at program start.
7+
# Otherwise the postmaster can self-deadlock due to signals interrupting
8+
# resolution of calls, since NetBSD's linker takes a lock while doing that and
9+
# some postmaster signal handlers do things that will also acquire that lock.
10+
# As long as we need "-z now", might as well specify "-z relro" too.
11+
# While there's not a hard reason to adopt these settings for our other
12+
# executables, there's also little reason not to, so just add them to LDFLAGS.
13+
LDFLAGS="$LDFLAGS -Wl,-z,now -Wl,-z,relro"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp