Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
controller: Store src_mac, src_ip in svc_monitor struct.
These structure members are read in pinctrl_handler() in a separare thread. This is unsafe: when IDL is re-connected or some IDL objects are freed after svc_monitors list with svc_monitor structures, which point to sbrec_service_monitor is initialized, sb_svc_mon structure property can point to wrong address, which then leads to segmentation fault in svc_monitor_send_tcp_health_check__() and svc_monitor_send_udp_health_check() on accessing svc_mon->sb_svc_mon. Imagine situation: Main ovn-controller thread: 1. Connects to SB and fills IDL with DB contents. 2. run pinctrl_run() with pinctrl mutex and sync_svc_monitors() as a part of it. 3. Release mutex. ... 4. Loss of OVNSB connection for any reason (network outage/inactivity probe timeout/etc), start new main-loop iteration, re-initialize IDL in ovsdb_idl_run() (which probably will destroy previous IDL objects). ... pinctrl thread: 5. Awake from poll_block(). ... run new iteration in its main loop ... 6. Acquire mutex lock. 7. Run svc_monitors_run(), run svc_monitor_send_tcp_health_check__() or svc_monitor_send_udp_health_check(), which try to access IDL objects with outdated pointers. 8. Segmentation fault: Stack trace of thread 212406: __GI_strlen (libc.so.6) inet_pton (libc.so.6) ip_parse (ovn-controller) svc_monitor_send_tcp_health_check__.part.37 (ovn-controller) svc_monitor_send_health_check (ovn-controller) pinctrl_handler (ovn-controller) ovsthread_wrapper (ovn-controller) start_thread (libpthread.so.0) __clone (libc.so.6) This patch removes unsafe access to IDL objects from pinctrl thread. New svc_monitor structure members are used to store needed data. Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2024-April/413198.html CC: Numan Siddique <numans@ovn.org> Acked-by: Ales Musil <amusil@redhat.com> Fixes: 8be01f4 ("Send service monitor health checks") Signed-off-by: Vladislav Odintsov <odivlad@gmail.com> Signed-off-by: Numan Siddique <numans@ovn.org>
- Loading branch information