From a0a5c4c7ecb0e50cbaced67d943f45bbf11374c5 Mon Sep 17 00:00:00 2001 From: mvs Date: Thu, 18 May 2023 09:59:43 +0000 Subject: [PATCH] Revert ip_sysctl() unlocking. Lock order issue was triggered in UVM layer. --- sys/kern/uipc_domain.c | 8 +++----- sys/netinet/in_proto.c | 3 +-- sys/netinet/ip_input.c | 9 +++------ sys/sys/protosw.h | 4 +--- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index aa38e09d03a..ba9a69b96bd 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_domain.c,v 1.62 2023/05/16 19:36:00 mvs Exp $ */ +/* $OpenBSD: uipc_domain.c,v 1.63 2023/05/18 09:59:43 mvs Exp $ */ /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */ /* @@ -244,12 +244,10 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, protocol = name[1]; for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_protocol == protocol && pr->pr_sysctl) { - if ((pr->pr_flags & PR_MPSYSCTL) == 0) - KERNEL_LOCK(); + KERNEL_LOCK(); error = (*pr->pr_sysctl)(name + 2, namelen - 2, oldp, oldlenp, newp, newlen); - if ((pr->pr_flags & PR_MPSYSCTL) == 0) - KERNEL_UNLOCK(); + KERNEL_UNLOCK(); return (error); } return (ENOPROTOOPT); diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 2a49df55c5d..526596eb6b8 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_proto.c,v 1.100 2023/05/16 19:36:00 mvs Exp $ */ +/* $OpenBSD: in_proto.c,v 1.101 2023/05/18 09:59:43 mvs Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* @@ -177,7 +177,6 @@ u_char ip_protox[IPPROTO_MAX]; const struct protosw inetsw[] = { { .pr_domain = &inetdomain, - .pr_flags = PR_MPSYSCTL, .pr_init = ip_init, .pr_slowtimo = ip_slowtimo, .pr_sysctl = ip_sysctl diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index cfa703cca3e..31c8a8eaf54 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.384 2023/05/16 19:36:00 mvs Exp $ */ +/* $OpenBSD: ip_input.c,v 1.385 2023/05/18 09:59:43 mvs Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1704,11 +1704,8 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (ip_sysctl_ipstat(oldp, oldlenp, newp)); #ifdef MROUTING case IPCTL_MRTSTATS: - KERNEL_LOCK(); - error = sysctl_rdstruct(oldp, oldlenp, newp, - &mrtstat, sizeof(mrtstat)); - KERNEL_UNLOCK(); - return (error); + return (sysctl_rdstruct(oldp, oldlenp, newp, + &mrtstat, sizeof(mrtstat))); case IPCTL_MRTMFC: if (newp) return (EPERM); diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 0456d320c05..bf17e7b78a8 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.61 2023/05/16 19:44:55 mvs Exp $ */ +/* $OpenBSD: protosw.h,v 1.62 2023/05/18 09:59:44 mvs Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -131,8 +131,6 @@ struct protosw { #define PR_ABRTACPTDIS 0x0020 /* abort on accept(2) to disconnected socket */ #define PR_SPLICE 0x0040 /* socket splicing is possible */ -#define PR_MPSYSCTL 0x0080 /* (*pr_sysctl)() doesn't require - kernel lock */ /* * The arguments to usrreq are: -- 2.20.1