From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2464C2D0C3 for ; Mon, 16 Dec 2019 18:09:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AD382082E for ; Mon, 16 Dec 2019 18:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519793; bh=+acM6/3oFbKzz7oCcG64SWWaZNc21NPB0mvTRhzs49c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OUUJZWLWqYDxSHNzgz5eK3tI4h9/AmIa+SUCD04uQmDCCTHt3fesmkTwAQweVDTMh ofgIvChvKbrkNipJsSJJgFirHBfNwDk4XTbNr0dGtMN6Gv+g7SGwVHvZa4Uy+tzZUu iIyhHUT7jhPpPJGv5JQPuU4n8/W/wuqyOP+62RmU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730515AbfLPSJw (ORCPT ); Mon, 16 Dec 2019 13:09:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:52512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730500AbfLPSJw (ORCPT ); Mon, 16 Dec 2019 13:09:52 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 E9F5C206B7; Mon, 16 Dec 2019 18:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519791; bh=+acM6/3oFbKzz7oCcG64SWWaZNc21NPB0mvTRhzs49c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPO1IPaCJrNBAQAVY1SvC0kV0Sv4lzQo+kQ1m+fVuSDXT2B4dDB8JojoSgI2549xm 1yV22tazXDorZxlpGE3JWrzYplJFN99eYWDjsHI4BDVMMFMoAvT31CSaVd3xsjNxic EU+ytxBmz85oJsU62u9ZVixbNZmSRMlMiqRzm9cw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amir Goldstein , Miklos Szeredi Subject: [PATCH 5.3 068/180] ovl: fix corner case of non-unique st_dev;st_ino Date: Mon, 16 Dec 2019 18:48:28 +0100 Message-Id: <20191216174830.044230419@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174806.018988360@linuxfoundation.org> References: <20191216174806.018988360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Amir Goldstein commit 9c6d8f13e9da10a26ad7f0a020ef86e8ef142835 upstream. On non-samefs overlay without xino, non pure upper inodes should use a pseudo_dev assigned to each unique lower fs and pure upper inodes use the real upper st_dev. It is fine for an overlay pure upper inode to use the same st_dev;st_ino values as the real upper inode, because the content of those two different filesystem objects is always the same. In this case, however: - two filesystems, A and B - upper layer is on A - lower layer 1 is also on A - lower layer 2 is on B Non pure upper overlay inode, whose origin is in layer 1 will have the same st_dev;st_ino values as the real lower inode. This may result with a false positive results of 'diff' between the real lower and copied up overlay inode. Fix this by using the upper st_dev;st_ino values in this case. This breaks the property of constant st_dev;st_ino across copy up of this case. This breakage will be fixed by a later patch. Fixes: 5148626b806a ("ovl: allocate anon bdev per unique lower fs") Cc: stable@vger.kernel.org # v4.17+ Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/inode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -200,8 +200,14 @@ int ovl_getattr(const struct path *path, if (ovl_test_flag(OVL_INDEX, d_inode(dentry)) || (!ovl_verify_lower(dentry->d_sb) && (is_dir || lowerstat.nlink == 1))) { - stat->ino = lowerstat.ino; lower_layer = ovl_layer_lower(dentry); + /* + * Cannot use origin st_dev;st_ino because + * origin inode content may differ from overlay + * inode content. + */ + if (samefs || lower_layer->fsid) + stat->ino = lowerstat.ino; } /*