Fix segfault when interrupting fapolicyd startup#391
Fix segfault when interrupting fapolicyd startup#391stevegrubb merged 1 commit intolinux-application-whitelisting:mainfrom
Conversation
|
This looks like it contains another patch already merged. In general, I would fix this in the function that crashes and not the call of the function. Typically at the beginning of a function you would test for NULL and return. |
60f7413 to
4ce2ecb
Compare
Yes we could but since it's a rare condition I think it's better to not check constantly |
|
Neither of these are on the hot path. Just check the value on entry and we're good to go. |
In non-daemon mode, hitting Ctrl-C while fapolicyd initializes leads to getting 2 segfaults: - first one in term_handler() because 'q' is not initialized yet - then one in coredump_handler() because 'm' is not initialized yet Reproducer: ~~~ # fapolicyd --debug [...] 01/22/26 10:48:37 [ INFO ]: Loading rpmdb backend ^CSegmentation fault (core dumped) ~~~ GDB shows: ~~~ (gdb) bt #0 mlist_first (m=m@entry=0x0) at daemon/mounts.c:86 <<<<< SECOND SEGFAULT linux-application-whitelisting#1 0x00005627e02de9ec in unmark_fanotify (m=0x0) at daemon/notify.c:258 linux-application-whitelisting#2 0x00005627e02dda13 in coredump_handler (sig=11) at daemon/fapolicyd.c:336 linux-application-whitelisting#3 coredump_handler (sig=11) at daemon/fapolicyd.c:333 linux-application-whitelisting#4 <signal handler called> linux-application-whitelisting#5 __new_sem_post (sem=0x20) at sem_post.c:36 <<<<< FIRST SEGFAULT linux-application-whitelisting#6 <signal handler called> linux-application-whitelisting#7 __recvmsg_syscall (flags=0, msg=0x7ffe93e00350, fd=6) at ../sysdeps/unix/sysv/linux/recvmsg.c:27 linux-application-whitelisting#8 __libc_recvmsg (fd=6, msg=msg@entry=0x7ffe93e00350, flags=flags@entry=0) at ../sysdeps/unix/sysv/linux/recvmsg.c:41 linux-application-whitelisting#9 0x00005627e02eef82 in rpm_load_list (conf=<optimized out>) at library/rpm-backend.c:260 linux-application-whitelisting#10 0x00005627e02ecc02 in backend_load (conf=conf@entry=0x5627e02fa0e0 <config>) at library/backend-manager.c:152 linux-application-whitelisting#11 0x00005627e02e21c0 in init_database (config=config@entry=0x5627e02fa0e0 <config>) at library/database.c:1440 linux-application-whitelisting#12 0x00005627e02db599 in main (argc=<optimized out>, argv=<optimized out>) at daemon/fapolicyd.c:1053 ~~~
4ce2ecb to
f5ac587
Compare
OK, done. |
|
Thanks! |
6762080
into
linux-application-whitelisting:main
In non-daemon mode, hitting
Ctrl-Cwhile fapolicyd initializes leads to getting 2 segfaults:- first one in
term_handler()becauseqis not initialized yet- then one in
coredump_handler()becausemis not initialized yetReproducer:
GDB shows: