Received: by 10.192.165.156 with SMTP id m28csp1074895imm; Wed, 11 Apr 2018 11:58:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+loCoMCnHu28/5TovUFwzJSfW8m+oUjVKWK5RWzvj36O5afIy1d48fzs43E4EjMZUebVcj X-Received: by 10.167.131.217 with SMTP id j25mr4958127pfn.5.1523473097358; Wed, 11 Apr 2018 11:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473097; cv=none; d=google.com; s=arc-20160816; b=Yp26Bp0nbXeekGKfHhW5Ly18l99IH5yiMIfRl60UtefTDGLXgyGQ27OMnaIN16TGAC hWOd8976cqwl2njcCvQkQ/uF4l3bSMsMmULkQXd1pPmDOvduRm40aZhRjMdRatnSzBuw B6kUv15Qwpp6KgvY9aF0gTa7McMlqeJp39xooXU3GV5C5KcfV29P2aWs7mFUmiYyMuDM 7zNu7t7BnU2g88ZVJAJ80HvAANnrp03R4vzFFcFuFLe0kazRW5B5z4evKrFGb2TX2afd k3BjrCrOJe01GkbP/mb3/wfgdBBPkAKdnLeNvc0vxcz2Bco4DVXJVBca2y8w4KmtZO+e ORzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8fe7G7j2AUvoD3QM5SoaxVsfvtv2bv+Kd7cZs9rg9g0=; b=YFwChKYESHYajbLbSctays3Pmd0CZvVQ/4/4gGiwg/EveeOIBVicbxBpatcm/UB29h 8+aixX5TOsYwfhxv0z6QDiIjCpiyGT4EEphXZrePRA0HvuLXEMIRowwHms7WeuOffvw9 wr2vtNhIMyIKr+jq0Fqtq2EERHaLN3pvi3wdhUKSFWu/HwZyx3QrrQF42nCI4WSK4sVR MxRmpnYTt7sqFdXkKJYY1Y9TYo+4nHKfHvVx8iEhhkQ9wQi5eqEYnd7uaRWlZ3CxnocJ V49WGZZ7BQF2mqvFuud7jg2/rTGESXqja20Ap1NiUDIMDl6/OM00YuSKmJmj7KtVC4/m uUuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 h12-v6si1570847pls.305.2018.04.11.11.57.41; Wed, 11 Apr 2018 11:58:17 -0700 (PDT) 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; 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 S933410AbeDKSx6 (ORCPT + 99 others); Wed, 11 Apr 2018 14:53:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34020 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933393AbeDKSxy (ORCPT ); Wed, 11 Apr 2018 14:53:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1C914EBA; Wed, 11 Apr 2018 18:53:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amir Goldstein , Miklos Szeredi , Sasha Levin Subject: [PATCH 4.9 007/310] ovl: persistent inode numbers for upper hardlinks Date: Wed, 11 Apr 2018 20:32:26 +0200 Message-Id: <20180411183622.606464693@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein [ Upstream commit 5b6c9053fb38a66fd5c6177fcf5022b24767811a ] An upper type non directory dentry that is a copy up target should have a reference to its lower copy up origin. There are three ways for an upper type dentry to be instantiated: 1. A lower type dentry that is being copied up 2. An entry that is found in upper dir by ovl_lookup() 3. A negative dentry is hardlinked to an upper type dentry In the first case, the lower reference is set before copy up. In the second case, the lower reference is found by ovl_lookup(). In the last case of hardlinked upper dentry, it is not easy to update the lower reference of the negative dentry. Instead, drop the newly hardlinked negative dentry from dcache and let the next access call ovl_lookup() to find its lower reference. This makes sure that the inode number reported by stat(2) after the hardlink is created is the same inode number that will be reported by stat(2) after mount cycle, which is the inode number of the lower copy up origin of the hardlink source. NOTE that this does not fix breaking of lower hardlinks on copy up, but only fixes the case of lower nlink == 1, whose upper copy up inode is hardlinked in upper dir. Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/dir.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -180,6 +180,9 @@ static void ovl_instantiate(struct dentr inc_nlink(inode); } d_instantiate(dentry, inode); + /* Force lookup of new upper hardlink to find its lower */ + if (hardlink) + d_drop(dentry); } static int ovl_create_upper(struct dentry *dentry, struct inode *inode,