Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1543413pxb; Thu, 16 Sep 2021 09:35:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0VaqoOVlIpMOUgJj8OPCBzJwExA0Y3eLKGCETVJm3VBsiV3iaFxgeVkpXoXsmeXoodntk X-Received: by 2002:a05:6e02:1b89:: with SMTP id h9mr4509096ili.297.1631810138651; Thu, 16 Sep 2021 09:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631810138; cv=none; d=google.com; s=arc-20160816; b=GN2qswjU2HHhbuKijCh3XQR07C3aHC6d1slPyFLOTjByLWVSPfnyQjoKi9v6DjBrn+ 3uRmqlp5MOlmQDwCmPmbthAL9Jx718JdzKh1EuCbvUpOpUBh5AWCJOZhIehjK4EBJjn7 Ihg/iwAlhhlcj/qVOtJx+12SMgn48k8NhVvgxgg8nksqHaEaYB1jXZ/u8z0YbDXBeXxt PX1G7RjBVXmAZHrsfqD3MfhWechhrVmEQpw3qikysuPdvI+fWq7amk5YZuhXigjewkx+ 9b1TZB1swQzBGigIGiKj9Cvkb/7xufWxWSozoZOvIOc1/P/YEFvEwjfbp/iglZlMYlu0 TboQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bN/8YbWvPsW3Fb2+oshAwizWFqjX8PIbRCzXYNt3JKI=; b=An/l8sNT+aNSCzMOs2YUugkCzNFPkvGK4o+dcBkZe5ucwbZc/3tCkF7dn2afNlHCsd puZ/443ewGrOhILAGgjjMneUcg+SS86EwQw5UrqrqwOC+CW+JibelwhQwFfuN94ddCqo TP2AjZojYwRPtWIjINXLbsK5qnD6dKbiYUuKktPkmXEBhl7NPHHaL+aIswtsr1OqOu0D 2EI30ow/nmcfMnAAmMP9ZZE1/sz7p2fXkNscSA2B3kN/n0k+ZfKPf57/iovor+1CIHU2 xi3i6oKEplf0x9xe9lOs3dT2tH+M2Ez6mY/Vukjs4DF+5Oxir7MhOhe9Jkp3fUqiFZIa 1r3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y8IOaeua; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y28si3102526iot.48.2021.09.16.09.35.27; Thu, 16 Sep 2021 09:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y8IOaeua; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243264AbhIPQdf (ORCPT + 99 others); Thu, 16 Sep 2021 12:33:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:37486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241235AbhIPQZL (ORCPT ); Thu, 16 Sep 2021 12:25:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64C2B604E9; Thu, 16 Sep 2021 16:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808994; bh=IkSr81dmRKz8Vb0/fkgJQKts2MtDrWrqbK1Bm8mS7Q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8IOaeuaalPZJ5QWPIVR7rNz2QE1gx9qVzhrCJUoEvvNOEwiy1ovNrKjWhGG2k9hQ prHdTXc1V8JmoZFtlHE2xOjaCnhVoQuAKJCtgEp4LK/GrorJ4XEfPwSXYyeEKp3eE+ zVVu/h6B2hjZSy63Ih0u0iaUCveL/kMiHv8Z+Agk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, chenying , Miklos Szeredi Subject: [PATCH 5.10 281/306] ovl: fix BUG_ON() in may_delete() when called from ovl_cleanup() Date: Thu, 16 Sep 2021 18:00:26 +0200 Message-Id: <20210916155803.654485025@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: chenying commit 52d5a0c6bd8a89f460243ed937856354f8f253a3 upstream. If function ovl_instantiate() returns an error, ovl_cleanup will be called and try to remove newdentry from wdir, but the newdentry has been moved to udir at this time. This will causes BUG_ON(victim->d_parent->d_inode != dir) in fs/namei.c:may_delete. Signed-off-by: chenying Fixes: 01b39dcc9568 ("ovl: use inode_insert5() to hash a newly created inode") Link: https://lore.kernel.org/linux-unionfs/e6496a94-a161-dc04-c38a-d2544633acb4@bytedance.com/ Cc: # v4.18 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/dir.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -542,8 +542,10 @@ static int ovl_create_over_whiteout(stru goto out_cleanup; } err = ovl_instantiate(dentry, inode, newdentry, hardlink); - if (err) - goto out_cleanup; + if (err) { + ovl_cleanup(udir, newdentry); + dput(newdentry); + } out_dput: dput(upper); out_unlock: