On Sat, May 19, 2018 at 12:57:19PM +0200, Peter J. Philipp wrote:
> panic: kernel diagnostic assertion...(cut)

This is an important line.
panic: kernel diagnostic assertion "_kernel_lock_held()" failed in file "/us
Then the photo is cut, but I can guess what is next.

> soassertlocked(ffffffff815c8c03) at soassertlocked+0x73
> sorwakeup(ffff800032d930c8) at sorwakeup+0xf
> pfkeyv2_sendmessage(b0, 
> ffff800000137c00,4,ffff80000124d700,ffff800032d93128,2aa6da05f83cead1) at 
> pfkeyv2_sendmessage+0x20b

I would say as long we have no per socket locking, we must grab
either net lock or kernel lock when accessing the socket.  For pf
key sockets it is kernel lock, so just add it there.

bluhm

Index: net/pfkeyv2.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/pfkeyv2.c,v
retrieving revision 1.179
diff -u -p -r1.179 pfkeyv2.c
--- net/pfkeyv2.c       16 May 2018 13:19:00 -0000      1.179
+++ net/pfkeyv2.c       19 May 2018 11:50:53 -0000
@@ -381,12 +381,15 @@ pfkey_sendup(struct keycb *kp, struct mb
        } else
                m = m0;
 
+       KERNEL_LOCK()
        if (!sbappendaddr(so, &so->so_rcv, &pfkey_addr, m, NULL)) {
                m_freem(m);
+               KERNEL_UNLOCK();
                return (ENOBUFS);
        }
 
        sorwakeup(so);
+       KERNEL_UNLOCK();
        return (0);
 }
 

Reply via email to