Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp648455imu; Fri, 11 Jan 2019 06:46:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7WOB8u/gzxwH4gJqGLAk5Xt2bRaf04jH70rIN7rO4ltGOACZtRX6xnYk4iSCgo5Mk5IT1G X-Received: by 2002:a63:2bc4:: with SMTP id r187mr13476591pgr.306.1547218014050; Fri, 11 Jan 2019 06:46:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547218014; cv=none; d=google.com; s=arc-20160816; b=evxgZE/234npbH/VtYesz3iNkbiSETDj2MO5RbWn7UCQoGI35VzXGtOY57qDmpE4pt ShfAzjABfW722i3P+Fn4Bd1M45BOpURe2bMEoEVvUeXyV31hOZrCyGca9U99Ct+7eCDV AfK6Jwe5Jai4dAIAN8ZQuxOl9pht3Pj3y53euJHsU2XfVCJfwDLS5c+jwyaFksIdemUh G24P3tq5fKkyPjVRcJbb1S8VkTPJO5Jj79vy0Ej7DZCYyah20CVGuWMsLdiZUvBSPnkd Gk1+WufDFvG2U2U9ji6Z7ly/dy0hxOmjZPZDgPUelzTRPQwFMbdSyUthgoxBLrZs3l4n k+xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cBVoqRUCk8mZMuP9BOM0+LGiAZyQ+2KRez94RxThpTQ=; b=AhrFL1oUYgxA+i7+LBBnqo14jNpMSh2/Rzt2qQX0BYRPdY13OEswuNoqk6I4b7Yng/ vOy9vLWVof1Vg4jI1zWLDm9024jYETarC7Yv5FTtVmvUVHiweE526aXMBwmblWBPFveO 8YHFLjpNsF6SoLpRryj7J8NMf1/d6zQf57I6BaA06Qy5j1qh2cj9/YnojrQATY6zazU+ 7S/3GrpyAMGJH89e24eFPR5FXJqxk/w6GhndRVNvCYBVc05StJprPxQbIkkfLGcfOORY u3cywfP2szo32/xUC7s3a9uym20n6elchOa7WXx5QnT7lMOtL64phDo7mbDM5dCVu2PG ZFcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WaAnBetf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si13564361pgh.565.2019.01.11.06.46.38; Fri, 11 Jan 2019 06:46:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WaAnBetf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404407AbfAKOng (ORCPT + 99 others); Fri, 11 Jan 2019 09:43:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:36434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404026AbfAKOnd (ORCPT ); Fri, 11 Jan 2019 09:43:33 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 63069206B6; Fri, 11 Jan 2019 14:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217812; bh=8Hjs2BNd7XV9satEaGpNrDIhN2iN5zPfaY5P0HXZuLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WaAnBetfV/HAol0yvXR2VtdeM2pPGHtSgAtQTA8HOG45MdaszOst/CwsU0xVahlCp NZepks9hFagr4lwkG2qZolJSU3kcd/F33odj0nMCIQc6SlS8Tu1icLveBzy9iGFOwq bcRuOUTQhcDTxLgFfaQxnVFEQYDTH88DuKJwGokE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Christoph Hellwig , Andreas Gruenbacher , Bob Peterson Subject: [PATCH 4.20 33/65] gfs2: Get rid of potential double-freeing in gfs2_create_inode Date: Fri, 11 Jan 2019 15:15:19 +0100 Message-Id: <20190111131100.894748678@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andreas Gruenbacher commit 6ff9b09e00a441599f3aacdf577254455a048bc9 upstream. In gfs2_create_inode, after setting and releasing the acl / default_acl, the acl / default_acl pointers are not set to NULL as they should be. In that state, when the function reaches label fail_free_acls, gfs2_create_inode will try to release the same acls again. Fix that by setting the pointers to NULL after releasing the acls. Slightly simplify the logic. Also, posix_acl_release checks for NULL already, so there is no need to duplicate those checks here. Fixes: e01580bf9e4d ("gfs2: use generic posix ACL infrastructure") Reported-by: Pan Bian Cc: Christoph Hellwig Cc: stable@vger.kernel.org # v4.9+ Signed-off-by: Andreas Gruenbacher Signed-off-by: Bob Peterson Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/inode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -744,17 +744,19 @@ static int gfs2_create_inode(struct inod the gfs2 structures. */ if (default_acl) { error = __gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); + if (error) + goto fail_gunlock3; posix_acl_release(default_acl); + default_acl = NULL; } if (acl) { - if (!error) - error = __gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS); + error = __gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS); + if (error) + goto fail_gunlock3; posix_acl_release(acl); + acl = NULL; } - if (error) - goto fail_gunlock3; - error = security_inode_init_security(&ip->i_inode, &dip->i_inode, name, &gfs2_initxattrs, NULL); if (error) @@ -789,10 +791,8 @@ fail_free_inode: } gfs2_rsqa_delete(ip, NULL); fail_free_acls: - if (default_acl) - posix_acl_release(default_acl); - if (acl) - posix_acl_release(acl); + posix_acl_release(default_acl); + posix_acl_release(acl); fail_gunlock: gfs2_dir_no_add(&da); gfs2_glock_dq_uninit(ghs);