Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec Fix locking: it is fine if the lock is already ...
details: https://anonhg.NetBSD.org/src/rev/52573456231b
branches: trunk
changeset: 997189:52573456231b
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Feb 26 06:52:34 2019 +0000
description:
Fix locking: it is fine if the lock is already key_so_mtx, this can happen
in socketpair. In that case don't take it.
Ok ozaki-r@
Reported-by: syzbot+901e2e5edaaaed21c069%syzkaller.appspotmail.com@localhost
diffstat:
sys/netipsec/keysock.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diffs (35 lines):
diff -r e1dd5ae94c62 -r 52573456231b sys/netipsec/keysock.c
--- a/sys/netipsec/keysock.c Tue Feb 26 06:28:43 2019 +0000
+++ b/sys/netipsec/keysock.c Tue Feb 26 06:52:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: keysock.c,v 1.68 2019/01/27 02:08:48 pgoyette Exp $ */
+/* $NetBSD: keysock.c,v 1.69 2019/02/26 06:52:34 maxv Exp $ */
/* $FreeBSD: keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.68 2019/01/27 02:08:48 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.69 2019/02/26 06:52:34 maxv Exp $");
/* This code has derived from sys/net/rtsock.c on FreeBSD2.2.5 */
@@ -383,10 +383,12 @@
s = splsoftnet();
- KASSERT(so->so_lock == NULL);
- mutex_obj_hold(key_so_mtx);
- so->so_lock = key_so_mtx;
- solock(so);
+ if (so->so_lock != key_so_mtx) {
+ KASSERT(so->so_lock == NULL);
+ mutex_obj_hold(key_so_mtx);
+ so->so_lock = key_so_mtx;
+ solock(so);
+ }
error = raw_attach(so, proto, &key_rawcb);
if (error) {
Home |
Main Index |
Thread Index |
Old Index