Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2366264pxb; Mon, 20 Sep 2021 20:16:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYh6LLB4i6k1cOjEFyamcEKHm3GycHgcauImKwmtrn16JleeEfAlBv8IjbcrIWteCW7raQ X-Received: by 2002:a92:7f08:: with SMTP id a8mr19137897ild.125.1632194186837; Mon, 20 Sep 2021 20:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632194186; cv=none; d=google.com; s=arc-20160816; b=SyuAZg+8Ii3L4TWsdL9alJDzGei/Goh2S9M9fTzwA9Mg3e5YmhCfUZ318jpFEjy/uS +Iz8EmlbXKUEpt/+aodSn6wKl9zSfcnu4tVdpcm4Hbts9+pU15abqHiE+aNOUjdiDPnV iajk84zihi2LgA/JY+vW3Om0gbgoFqcrX3tBYZ9gfj7v0jRc9l0X50VN84jSgvriiQJW +iSWdSrBjctueJ0aMJcuXlcqY5VKfPuLBXtVb5r9hUQg/O0EcUSn5NBnF8TV0WWLva2w WkgYRrvYUnb5V299BzpmC98SsdH15PEMd/iadR0C1FjN6oRJnOYC002iVgWaTQ146AQ4 4QOw== 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=mhlUrzLOyh+1D188J0mVFlDa1mXyF//XkTzME1bvPlc=; b=CDBTFhijxuyu/FAb5pLyqj8g6JBd6QC7fW38P1FArknGi2UCbGb1Q8y5E1FX93a0sQ Wnj0SpX2ps13cM2unA4TH5sIcvMzJucBDYA+t+yIBnfwa5K/uDJMghA7Ccx850vwN6YS xT8zJMQYd+NB//zqZWa0yb9UQJ/4kjasXsJhKo6pYYW41Ob2nJISBEInZPhGHSqfobCh ESccQ4aKfze0XC96+Xf3CSufFKkwlVid5AR6/BvoqijemsdzihvS7/ND/vch0EOk/VWw Fh13lefk6i/yKC/nROOE4DIBc7gnA/fYHHaPfBcNRiVRSYtVLkIh494nSMbTGZb8Hw+n R+eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yo5EcML8; 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 m11si12811736iov.97.2021.09.20.20.16.15; Mon, 20 Sep 2021 20:16:26 -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=yo5EcML8; 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 S1351876AbhITSVd (ORCPT + 99 others); Mon, 20 Sep 2021 14:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:38976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376706AbhITSOQ (ORCPT ); Mon, 20 Sep 2021 14:14:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 70C9F63289; Mon, 20 Sep 2021 17:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158479; bh=NYBGbQrqgHIA7/wGc9qKssP9P97fbCYeHK4QzW0tpj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yo5EcML8Cu8xd2/5HEGzUKpCPmAxPONLEt63E8GmaHpaK8bsm49hTBEM8J6Ugiywe TJpmN2jaHVxDkbLpbAiWegrz3SgT80/pMKYJSVIeZmNesW4U1g38AjUoj3kTH+PCMU lnAlKIt2vJkmRgc5/L1fQCIwSbREOmAE+srwU870= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, chenying , Miklos Szeredi Subject: [PATCH 5.4 175/260] ovl: fix BUG_ON() in may_delete() when called from ovl_cleanup() Date: Mon, 20 Sep 2021 18:43:13 +0200 Message-Id: <20210920163937.031727716@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 @@ -513,8 +513,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: