From owner-dev-commits-src-main@freebsd.org Fri Jan 1 03:56:05 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D35514BCBCF; Fri, 1 Jan 2021 03:56:05 +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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D6WQs5bmSz4rlw; Fri, 1 Jan 2021 03:56:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B35051C810; Fri, 1 Jan 2021 03:56:05 +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 1013u5PT076068; Fri, 1 Jan 2021 03:56:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1013u5o5076067; Fri, 1 Jan 2021 03:56:05 GMT (envelope-from git) Date: Fri, 1 Jan 2021 03:56:05 GMT Message-Id: <202101010356.1013u5o5076067@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jamie Gritton Subject: git: b58a46347c8d - main - jail: revert the attachment part of b4e87a632955 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b58a46347c8dd81137ef164fba1ab6b60c5b94c4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jan 2021 03:56:05 -0000 The branch main has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=b58a46347c8dd81137ef164fba1ab6b60c5b94c4 commit b58a46347c8dd81137ef164fba1ab6b60c5b94c4 Author: Jamie Gritton AuthorDate: 2021-01-01 03:55:49 +0000 Commit: Jamie Gritton CommitDate: 2021-01-01 03:55:49 +0000 jail: revert the attachment part of b4e87a632955 The change to kern_jail_set that was supposed to "also properly clean up when attachment fails" didn't fix a memory leak but actually caused a double free. Back that part out, and leave the part that manages allprison_lock state. --- sys/kern/kern_jail.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 1ecb023717bd..55006939a5ff 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -1835,14 +1835,8 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) slocked = 0; if (error) { vfs_opterror(opts, "attach failed"); - if (born) { - sx_slock(&allprison_lock); - slocked = PD_LIST_SLOCKED; - (void)osd_jail_call(pr, PR_METHOD_REMOVE, NULL); - } - prison_deref(pr, created - ? slocked - : PD_DEREF | slocked); + if (!created) + prison_deref(pr, PD_DEREF); goto done_errmsg; } }