From nobody Wed Jul 20 15:25:29 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LnzzY4rmnz4XGTd; Wed, 20 Jul 2022 15:25:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LnzzY49XDz3qX2; Wed, 20 Jul 2022 15:25:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658330729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hMoFCT7sddav1mIxUPdPi+HErVbhZasqRM4RLqQuVQI=; b=RgY2STYp9gGu7oEYkQZChrDCGLQJkU6O8xrdW+CP6eK7WXsT51tz0ZehTLz9PSO5eglfOn C4IGHhl3hnxhOcfB9xhQUrHc5Nq0Kz/WR4LLfF077dgeV1dQi1dVMMJ7MKoJ5ecO9+XDxg pX0AWhmzGDhcJdtupvGfgLJ4wn5s3kC16CMfd9wNwL6gpXo15JMCcXYiJq8kvUL6mPkzAs ggYF1rD4g61/Ys5HpmPKXxchI0JRrhtAKUgX+0JIl/bY1HyFhPs+acz51b++ldR1ESYF5r 1E2ctRB6v8xuzsiF1xQ3Nm7j1nWgRBO1B+F1kjf33H/VtM/Z8Fe90vOZvWwyeg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LnzzY3CkJz12Sr; Wed, 20 Jul 2022 15:25:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26KFPT9J086288; Wed, 20 Jul 2022 15:25:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26KFPTdJ086287; Wed, 20 Jul 2022 15:25:29 GMT (envelope-from git) Date: Wed, 20 Jul 2022 15:25:29 GMT Message-Id: <202207201525.26KFPTdJ086287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Tom Jones Subject: git: dc2e12abb22a - stable/13 - Unlock inp when handling TCP_MD5SIG socket options List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: thj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: dc2e12abb22a303aed88c6dd042d652cab8a2bad Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658330729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hMoFCT7sddav1mIxUPdPi+HErVbhZasqRM4RLqQuVQI=; b=p6S/It97t/d5lzg22E1Ya9kKZBbnv8hoAdTYWfBMx4NJ5UYdK0hCiHVjsbEzGTa1Z/lC3+ 5WN/yC4U4IrUReuw3LLvc2GhkpDP/VHDogOuhdSSux1RVDOjKtDY5+HNlbrGmwZEkE8VUq cn7baB2ZMSBGGyZ2yie6qz4JXF11nEGmaiUqcCgzf6+jnjOzuLbTJGaIr2AmJDLSOAGtTQ rEa9+o3av9wJOzB5WDFtJJKEyBT+i75/+rszYnXvv1GjI0kxT1vDp7PXmEV+YvLRmrKfWn zQ9MZIX5xBYS3ZHQvXrxfjo7HpchPso4QKnSYs1W5b2j5LKnkeezfBm9nB3h1g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658330729; a=rsa-sha256; cv=none; b=iH6OQMfA0+OwG/uyHrVvjDhEN1It8TvcS7x3BeTq4y7YsrK3hUvkCo+gSWp264ksbeGR4p 1J0jOeXLK8BEgZMgwLdi7yG5nHPRXTbgltyKVlCjAgZ45w6YpgXcGQfCmczjGMX2veLO5P 2n5c8CPmDsrP9yVnxf4cA4YP+d745oYzKq8v15NsnN3hNRXhcclvbQuk60QYgQV/doGQZA jYOX5MCfh3cycPx21lKAYrYhY1R9r5trAShXRz77bd0K+yF0X152iurvQJ6oDit8UAXJWZ Zvo7bVMiXOSaAf4B6S+Ky6baueykfO5RMqLtDVwtvGEwi9vQV45TU5Ds5w93PQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by thj: URL: https://cgit.FreeBSD.org/src/commit/?id=dc2e12abb22a303aed88c6dd042d652cab8a2bad commit dc2e12abb22a303aed88c6dd042d652cab8a2bad Author: Claudio Jeker AuthorDate: 2022-06-23 14:50:47 +0000 Commit: Tom Jones CommitDate: 2022-07-20 15:24:49 +0000 Unlock inp when handling TCP_MD5SIG socket options Unlock the inp when hanlding TCP_MD5SIG socket options. tcp_ipsec_pcbctl handles locking the inp when the option is being modified. This was found by Claudio Jeker while working on the OpenBGPd port. On 14 we get a panic when trying to call getsockopt, on 13.1 the process locks up using 100% CPU. Reviewed by: rscheff (transport), tuexen MFC after: 3 days Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D35532 (cherry picked from commit 97453e5e7258158042795740f2736cfca972269d) --- sys/netinet/tcp_usrreq.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index d48a09533f5f..4f40fe4d7730 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1968,13 +1968,13 @@ tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp switch (sopt->sopt_name) { #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) case TCP_MD5SIG: - if (!TCPMD5_ENABLED()) { - INP_WUNLOCK(inp); + INP_WUNLOCK(inp); + if (!TCPMD5_ENABLED()) return (ENOPROTOOPT); - } error = TCPMD5_PCBCTL(inp, sopt); if (error) return (error); + INP_WLOCK_RECHECK(inp); goto unlock_and_done; #endif /* IPSEC */ @@ -2381,10 +2381,9 @@ unlock_and_done: switch (sopt->sopt_name) { #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) case TCP_MD5SIG: - if (!TCPMD5_ENABLED()) { - INP_WUNLOCK(inp); + INP_WUNLOCK(inp); + if (!TCPMD5_ENABLED()) return (ENOPROTOOPT); - } error = TCPMD5_PCBCTL(inp, sopt); break; #endif