-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shutdown polkitd properly on SIGTERM #521
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
While trying to break polkit using dfuzzer I couldn't make ASan/LSan report _any_ memory leaks no matter how obvious they were. After a lot of tinkering I managed to get the reports only when calling __lsan_do_recoverable_leak_check() explicitly, which told me that the shutdown __lsan_do_leak_check() is somehow getting skipped. Turns out that polkitd does a "proper" shutdown on SIGINT (with which ASan/LSan worked as expected), but not for SIGTERM. Fixing this, by stopping the even loop even on SIGTERM, makes ASan/LSan happy (except for the couple of memory leaks that were unfortunately hidden by this behavior).
Otherwise it gets leaked: [356645.511913] systemd[1]: Stopping polkit.service - Authorization Manager... [356645.514024] polkitd[15468]: Handling SIGTERM [356645.514024] polkitd[15468]: Shutting down [356645.519238] polkitd[15468]: Exiting with code 0 [356645.618456] polkitd[15468]: ================================================================= [356645.618456] polkitd[15468]: ==15468==ERROR: LeakSanitizer: detected memory leaks [356645.618456] polkitd[15468]: Direct leak of 4000 byte(s) in 50 object(s) allocated from: [356645.619128] polkitd[15468]: #0 0x0000004a1a33 in malloc (/usr/lib/polkit-1/polkitd+0x4a1a33) (BuildId: a927b98f2ddc1b57773bec4e0f8a537fe46632b1) [356645.619128] polkitd[15468]: #1 0x7f1b20324039 in g_malloc (/lib64/libglib-2.0.so.0+0x47039) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619128] polkitd[15468]: #2 0x7f1b2033d4d4 in g_slice_alloc (/lib64/libglib-2.0.so.0+0x604d4) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619128] polkitd[15468]: #3 0x7f1b2036b547 in g_variant_iter_new (/lib64/libglib-2.0.so.0+0x8e547) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619128] polkitd[15468]: polkit-org#4 0x7f1b2036dc5d (/lib64/libglib-2.0.so.0+0x90c5d) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619128] polkitd[15468]: polkit-org#5 0x7f1b2036d8b7 (/lib64/libglib-2.0.so.0+0x908b7) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619128] polkitd[15468]: polkit-org#6 0x7f1b2036de0f in g_variant_get_va (/lib64/libglib-2.0.so.0+0x90e0f) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619128] polkitd[15468]: polkit-org#7 0x7f1b2036df88 in g_variant_get (/lib64/libglib-2.0.so.0+0x90f88) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619128] polkitd[15468]: polkit-org#8 0x7f1b2067ce85 in polkit_system_bus_name_get_creds_sync /root/polkit/build/../src/polkit/polkitsystembusname.c:542:3 [356645.619128] polkitd[15468]: polkit-org#9 0x7f1b2067c997 in polkit_system_bus_name_get_process_sync /root/polkit/build/../src/polkit/polkitsystembusname.c:629:8 [356645.619128] polkitd[15468]: polkit-org#10 0x0000005069af in polkit_backend_session_monitor_get_session_for_subject /root/polkit/build/../src/polkitbackend/polkitbackendsessionmonitor-systemd.c:365:41 [356645.619128] polkitd[15468]: polkit-org#11 0x0000004f11b5 in polkit_backend_interactive_authority_revoke_temporary_authorization_by_id /root/polkit/build/../src/polkitbackend/polkitbackendinteractiveauthority.c:3567:24 [356645.619128] polkitd[15468]: polkit-org#12 0x0000004ea2c8 in server_handle_revoke_temporary_authorization_by_id /root/polkit/build/../src/polkitbackend/polkitbackendauthority.c:1292:8 [356645.619128] polkitd[15468]: polkit-org#13 0x0000004e805c in server_handle_method_call /root/polkit/build/../src/polkitbackend/polkitbackendauthority.c:1346:5 [356645.619128] polkitd[15468]: polkit-org#14 0x7f1b20565195 (/lib64/libgio-2.0.so.0+0xd9195) (BuildId: d06dc1cc6f8ddbb3cda89ef05ecf83d6fe037ae7) [356645.619332] polkitd[15468]: polkit-org#15 0x7f1b20323e5c (/lib64/libglib-2.0.so.0+0x46e5c) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619332] polkitd[15468]: polkit-org#16 0x7f1b2031d60b (/lib64/libglib-2.0.so.0+0x4060b) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619332] polkitd[15468]: polkit-org#17 0x7f1b2037db37 (/lib64/libglib-2.0.so.0+0xa0b37) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619332] polkitd[15468]: polkit-org#18 0x7f1b203236f6 in g_main_loop_run (/lib64/libglib-2.0.so.0+0x466f6) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [356645.619332] polkitd[15468]: polkit-org#19 0x0000004e3619 in main /root/polkit/build/../src/polkitbackend/polkitd.c:298:3 [356645.619332] polkitd[15468]: polkit-org#20 0x7f1b1fe59447 in __libc_start_call_main (/lib64/libc.so.6+0x3447) (BuildId: f3ac204eaa4ceed81438c80e80998209f828bb1a) [356645.619332] polkitd[15468]: polkit-org#21 0x7f1b1fe5950a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x350a) (BuildId: f3ac204eaa4ceed81438c80e80998209f828bb1a) [356645.619332] polkitd[15468]: polkit-org#22 0x000000401c04 in _start (/usr/lib/polkit-1/polkitd+0x401c04) (BuildId: a927b98f2ddc1b57773bec4e0f8a537fe46632b1) ... Follow-up for 8cabb11.
[357268.621800] systemd[1]: Stopping polkit.service - Authorization Manager... [357268.623321] polkitd[15601]: Handling SIGTERM [357268.623321] polkitd[15601]: Shutting down [357268.629022] polkitd[15601]: Exiting with code 0 [357268.748206] polkitd[15601]: ================================================================= [357268.748455] polkitd[15601]: ==15601==ERROR: LeakSanitizer: detected memory leaks [357268.748455] polkitd[15601]: Direct leak of 48 byte(s) in 3 object(s) allocated from: [357268.749382] polkitd[15601]: #0 0x0000004a1a33 in malloc (/usr/lib/polkit-1/polkitd+0x4a1a33) (BuildId: a927b98f2ddc1b57773bec4e0f8a537fe46632b1) [357268.749382] polkitd[15601]: #1 0x7fe21ebe5039 in g_malloc (/lib64/libglib-2.0.so.0+0x47039) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: #2 0x7fe21ebfe4d4 in g_slice_alloc (/lib64/libglib-2.0.so.0+0x604d4) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: #3 0x7fe21ebfe5c4 in g_slice_alloc0 (/lib64/libglib-2.0.so.0+0x605c4) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: polkit-org#4 0x7fe21ebc6910 (/lib64/libglib-2.0.so.0+0x28910) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: polkit-org#5 0x7fe21ebc70a4 in g_error_new_valist (/lib64/libglib-2.0.so.0+0x290a4) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: polkit-org#6 0x7fe21ebc72e0 in g_set_error (/lib64/libglib-2.0.so.0+0x292e0) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: polkit-org#7 0x7fe21ee50b52 (/lib64/libgio-2.0.so.0+0x103b52) (BuildId: d06dc1cc6f8ddbb3cda89ef05ecf83d6fe037ae7) [357268.749382] polkitd[15601]: polkit-org#8 0x000000508a88 in ensure_all_files /root/polkit/build/../src/polkitbackend/polkitbackendactionpool.c:572:18 [357268.749382] polkitd[15601]: polkit-org#9 0x0000005097c1 in polkit_backend_action_pool_get_all_actions /root/polkit/build/../src/polkitbackend/polkitbackendactionpool.c:456:3 [357268.749382] polkitd[15601]: polkit-org#10 0x0000004e80fd in server_handle_enumerate_actions /root/polkit/build/../src/polkitbackend/polkitbackendauthority.c:689:13 [357268.749382] polkitd[15601]: polkit-org#11 0x0000004e80fd in server_handle_method_call /root/polkit/build/../src/polkitbackend/polkitbackendauthority.c:1326:5 [357268.749382] polkitd[15601]: polkit-org#12 0x7fe21ee26195 (/lib64/libgio-2.0.so.0+0xd9195) (BuildId: d06dc1cc6f8ddbb3cda89ef05ecf83d6fe037ae7) [357268.749382] polkitd[15601]: polkit-org#13 0x7fe21ebe4e5c (/lib64/libglib-2.0.so.0+0x46e5c) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: polkit-org#14 0x7fe21ebde60b (/lib64/libglib-2.0.so.0+0x4060b) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: polkit-org#15 0x7fe21ec3eb37 (/lib64/libglib-2.0.so.0+0xa0b37) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749382] polkitd[15601]: polkit-org#16 0x7fe21ebe46f6 in g_main_loop_run (/lib64/libglib-2.0.so.0+0x466f6) (BuildId: c18bb9dc5295ff894f6098fa33e9ba39341c5bc1) [357268.749797] polkitd[15601]: polkit-org#17 0x0000004e3619 in main /root/polkit/build/../src/polkitbackend/polkitd.c:298:3 [357268.749797] polkitd[15601]: polkit-org#18 0x7fe21e71a447 in __libc_start_call_main (/lib64/libc.so.6+0x3447) (BuildId: f3ac204eaa4ceed81438c80e80998209f828bb1a) [357268.749797] polkitd[15601]: polkit-org#19 0x7fe21e71a50a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x350a) (BuildId: f3ac204eaa4ceed81438c80e80998209f828bb1a) [357268.749797] polkitd[15601]: polkit-org#20 0x000000401c04 in _start (/usr/lib/polkit-1/polkitd+0x401c04) (BuildId: a927b98f2ddc1b57773bec4e0f8a537fe46632b1) Follow-up for 9958c25.
I think it should also help to build coverage reports. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While trying to break polkit using dfuzzer I couldn't make ASan/LSan
report any memory leaks no matter how obvious they were. After a lot
of tinkering I managed to get the reports only when calling
__lsan_do_recoverable_leak_check()
explicitly, which told me that theshutdown
__lsan_do_leak_check()
is somehow getting skipped.Turns out that polkitd does a "proper" shutdown on
SIGINT
(with whichASan/LSan worked as expected), but not for
SIGTERM
. Fixing this, bystopping the even loop even on SIGTERM, makes ASan/LSan happy (except
for the couple of memory leaks that were unfortunately hidden by this
behavior).
This PR together with #520 should be, for now, hopefully enough to let me introduce dfuzzer into polkit's test suite and address #515.
/cc @evverx