CVSROOT: /cvs Module name: src Changes by: m...@cvs.openbsd.org 2022/11/23 08:12:27
Modified files: sys/net : if_pflow.c if_pflow.h Log message: Make `so' dereference safe within pflow_output_process(). sosend() has sleep points, so the kernel lock serialisation within pflow_output_process() doesn't work as expected. The pflow(4) interface associated socket `so' could be overwritten by concurrent pflowioctl() thread. Introduce pflow(4) interface's `sc_lock' rwlock(9) to make `so' dereference safe. Since the solock() of udp(4) sockets uses netlock as backend, the `sc_lock' should be taken first. This expands a little netlock relocking within pflowioctl(). pflow_sendout_mbuf() called by pflow_output_process(), now called without kernel lock held, so the mp safe counters_pkt(9) used instead of manual `if_opackets' increment. Since if_detach() does partial ifnet destruction, now it can't be called before we finish pflow_output_process() task, otherwise we introduce use after free for interface counters. In other hand, we need to deny pflowioctl() to reschedule pflow_output_process() task. The `sc_dyind' flag introduced for that. Tested by Hrvoje Popovski. ok bluhm@