From patchwork Fri May 4 09:41:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10380279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B82E6038F for ; Fri, 4 May 2018 09:40:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB7C29372 for ; Fri, 4 May 2018 09:40:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F4F829376; Fri, 4 May 2018 09:40:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFAC929372 for ; Fri, 4 May 2018 09:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751785AbeEDJkP (ORCPT ); Fri, 4 May 2018 05:40:15 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37674 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751592AbeEDJkN (ORCPT ); Fri, 4 May 2018 05:40:13 -0400 Received: by mail-wm0-f45.google.com with SMTP id l1-v6so3588961wmb.2; Fri, 04 May 2018 02:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qpAy/tHhE8QfVGwSkIu374FrLolLLfRQnUeKG9CmsQg=; b=FEvlP7D9WA3vJ+fnptghkCH8WSz//B08BV8VTCxg39p6k3kQVyGy7jpFtAQD2yS4QQ X6rn7QEcXsY/UDLW7paG7y6/DM3xJm8/8Jf+Qu4CeSD+g/bo9lZbMZye20gLzJKoJNlE LCLkksOD40pAl+kMvCYQYikLUvEd6X/RDqsuTASJrRBoM7iSlJQ6Pi4bh4KLQKFowg3Q FlwlgfV7hTrib2tW0F1VkIMpxjb9rEkzR7W0krpQqH6Q0/UvGcQzTsGjOphGVEJ9vjdp HszpyvqTiE99OKhNPBUjKe3KAB/Q6/Wgjpgu/6BLeoxZhhGA2zxNNhxcj49PKiPFGJve Ustw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qpAy/tHhE8QfVGwSkIu374FrLolLLfRQnUeKG9CmsQg=; b=puLVA9W/O/zL3f8i6yd1YdJhLbAKTKmMhg5fMZTCzajwt6z9TR2dq3kiwd6BI4u1Oi 5mOlpE5QNSNoM1gWcbknwJTJWUAhGc3LJKKRSgiNgKSsfx23+z6p9lt94g4JgSVrAuu8 6eoDVrV6aO/yQb4s+gmr0KizJTH2XpJZNi+wrzZbb3sh3o8uUw5qtRW1bfn5xkS3i1vO jNrrKdKbjkczlGLYdAp45xBkQ1h4CMKz+Q2NLSoBAt/j+xXozl+0gS/WFZYw3ilgvSx9 9rkWd9f9kzseDDsGIHzbkCNCXeTcmWeTQkRErMnWpLEQabrRAvpu3tVwitBlIdZodGar HgGA== X-Gm-Message-State: ALQs6tB+sCLxz34vxekcs2Wcbh4CRYvnog3XAkBWOWAizPIvLES6Mfvv kwWcCONbhg4Pt/g/bLQEctx9YQ== X-Google-Smtp-Source: AB8JxZp3B5IZUe3uRjJyNykklPoBSNmFQT6rEA3kqctQ2lI20wH6K8LD0amXEN119bApUIdoPfOrog== X-Received: by 10.28.150.211 with SMTP id y202mr15822806wmd.106.1525426812310; Fri, 04 May 2018 02:40:12 -0700 (PDT) Received: from localhost.localdomain ([94.230.83.122]) by smtp.gmail.com with ESMTPSA id j1-v6sm16066990wre.25.2018.05.04.02.40.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 May 2018 02:40:11 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Vivek Goyal , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 2/2] overlay: test multiple origin references to the same lower file Date: Fri, 4 May 2018 12:41:31 +0300 Message-Id: <1525426891-6121-3-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525426891-6121-1-git-send-email-amir73il@gmail.com> References: <1525426891-6121-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Multiple origin references to the same lower file from upper files that are not hardlinks will falsely return the same st_ino/st_dev for two different overlay files and will cause 'diff' to falsely report that content of files is the same when it is not. This test checks that overlayfs detects and fails lookup of a multiply referenced origin. The check for multiply referenced origin was a by-product of kernel commit 31747eda41ef ("ovl: hash directory inodes for fsnotify") Signed-off-by: Amir Goldstein --- tests/overlay/059 | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/059.out | 2 + tests/overlay/group | 1 + 3 files changed, 108 insertions(+) create mode 100755 tests/overlay/059 create mode 100644 tests/overlay/059.out diff --git a/tests/overlay/059 b/tests/overlay/059 new file mode 100755 index 0000000..5ac2b1b --- /dev/null +++ b/tests/overlay/059 @@ -0,0 +1,105 @@ +#! /bin/bash +# FS QA Test 059 +# +# Test multiple origin references to the same lower file. +# +# Multiple origin references to the same lower file from upper files that +# are not hardlinks will falsely return the same st_ino/st_dev for two +# different overlay files and will cause 'diff' to falsely report that +# content of files is the same when it is not. +# +# This test checks that overlayfs detects and fails lookup of a multiply +# referenced origin. +# +# The check for multiply referenced origin was a by-product of kernel +# commit 31747eda41ef ("ovl: hash directory inodes for fsnotify") +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Rename lower file to create copy up with origin xattr +create_origin_ref() +{ + local ref=$1 + + touch $lowerdir/origin + + # Enabling redirect_dir may seem irrelevant to rename of non-dir, + # but with upcoming 'metacopy' feature, redirects will be set also + # on non-dir and may also create multiple redirects. + _scratch_mount -o redirect_dir=on + mv $SCRATCH_MNT/origin $SCRATCH_MNT/$ref + + $UMOUNT_PROG $SCRATCH_MNT +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch_nocheck +_require_scratch_feature redirect_dir + +# remove all files from previous runs +_scratch_mkfs + +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER + +# Create copied up file with origin xattr +create_origin_ref ref1 +# Duplicate the copied up file +cp -a $upperdir/ref1 $upperdir/ref2 + +# Diverge the content of the two copies of file +# and the content of two copies of redirected dir +echo right >> $upperdir/ref1 +echo wrong >> $upperdir/ref2 + +_scratch_mount -o redirect_dir=on + +# If both copies of file use the same st_dev/st_ino in overlay +# diff won't detect that their content differs +diff -q $SCRATCH_MNT/ref1 $SCRATCH_MNT/ref2 &>/dev/null && \ + echo "diff on duplicated upper files doesn't know right from wrong!" + +# success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/overlay/059.out b/tests/overlay/059.out new file mode 100644 index 0000000..36ebeea --- /dev/null +++ b/tests/overlay/059.out @@ -0,0 +1,2 @@ +QA output created by 059 +Silence is golden diff --git a/tests/overlay/group b/tests/overlay/group index 359ed42..40445a0 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -61,3 +61,4 @@ 056 auto quick fsck 057 auto quick redirect 058 auto quick exportfs +059 auto quick copyup