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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 E3CFDC46478 for ; Mon, 1 Jul 2019 18:27:39 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C39402146F; Mon, 1 Jul 2019 18:27:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="PeWW2bu0"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="kHjJEtKV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="fdeR3+53" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C39402146F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hi11Q-0001b2-KC; Mon, 01 Jul 2019 18:27:24 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hi11O-0001aY-Sa for linux-f2fs-devel@lists.sourceforge.net; Mon, 01 Jul 2019 18:27:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Uta6Rdg5FrrItafgRZuTqlZPe2DJ5924X6i/Q2sxkAQ=; b=PeWW2bu0MQrRe9EyG/gOIVz/OV ZvsFTvFO0ftoB0IRI+fnC6ZAjeasnha+E3GlfxUa/IbV8B4ySnwW8VUUiPO9lzNsv3P5LDW7N6Wqn 3uyT0ob8d8X2jY/+sM2laseb6BkoPhKDeI9HS7fhh8fWQG7e4hKy4sxIpy5OrlpslS6c=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Uta6Rdg5FrrItafgRZuTqlZPe2DJ5924X6i/Q2sxkAQ=; b=kHjJEtKVFKm1KL3iTKaZ2cWxyO 1b52qSMJhrk1vVp1PsJL+U+oyyctU0M8524OalkbEfxsQIfiNf6nSzGxepMATa2K88aIWvEA04VgS ugfmd1pWQAhXsYo/wXTzzcYK6Dy5wL8qnOOQiJqR9dmBTZYT1NdqminSiE+h5EunA9nI=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hi11c-003hhU-Gi for linux-f2fs-devel@lists.sourceforge.net; Mon, 01 Jul 2019 18:27:37 +0000 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D28192184B; Mon, 1 Jul 2019 18:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562005649; bh=U7Gh8ir4OCdfKq36Q2cZ7i6ciRgLXwzUMHrcALWwhtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fdeR3+53dALQlSrstHrhaTNzqTtQy+1qRhfWxu06cMjNADYvl7kiGR6dfeeV9+3Fp JprVUMqM9SPxZ55N0ffcX6d9TYMdmfvX/mUB1/hu29zJhfv7YgiuRCMz/QJ3qslrN2 N42qnZa+sUDixEp+Owwo4UmjjXf5I4I8+UQVs1kU= From: Eric Biggers To: fstests@vger.kernel.org Date: Mon, 1 Jul 2019 11:25:43 -0700 Message-Id: <20190701182547.165856-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190701182547.165856-1-ebiggers@kernel.org> References: <20190701182547.165856-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Headers-End: 1hi11c-003hhU-Gi Subject: [f2fs-dev] [RFC PATCH v3 4/8] generic: test access controls on the fs-verity ioctls X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Theodore Y . Ts'o" , linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org, Jaegeuk Kim , linux-ext4@vger.kernel.org, Victor Hsieh Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Eric Biggers Test access controls on the fs-verity ioctls. FS_IOC_MEASURE_VERITY is allowed on any file, whereas FS_IOC_ENABLE_VERITY requires write access. Signed-off-by: Eric Biggers --- tests/generic/901 | 73 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/901.out | 14 +++++++++ tests/generic/group | 1 + 3 files changed, 88 insertions(+) create mode 100755 tests/generic/901 create mode 100644 tests/generic/901.out diff --git a/tests/generic/901 b/tests/generic/901 new file mode 100755 index 00000000..56dab587 --- /dev/null +++ b/tests/generic/901 @@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright 2018 Google LLC +# +# FS QA Test generic/901 +# +# Test access controls on the fs-verity ioctls. FS_IOC_MEASURE_VERITY is +# allowed on any file, whereas FS_IOC_ENABLE_VERITY requires write access. +# +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/verity + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs generic +_supported_os Linux +_require_scratch_verity +_require_user +_require_chattr ia + +_scratch_mkfs_verity &>> $seqres.full +_scratch_mount +fsv_file=$SCRATCH_MNT/file.fsv + +_fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY doesn't require root" +echo foo > $fsv_file +chmod 666 $fsv_file +_user_do "$FSVERITY_PROG enable $fsv_file" + +_fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires write access" +echo foo > $fsv_file >> $seqres.full +chmod 444 $fsv_file +_user_do "$FSVERITY_PROG enable $fsv_file" |& _filter_scratch + +_fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires !append-only" +echo foo > $fsv_file >> $seqres.full +$CHATTR_PROG +a $fsv_file +$FSVERITY_PROG enable $fsv_file |& _filter_scratch +$CHATTR_PROG -a $fsv_file + +_fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires !immutable" +echo foo > $fsv_file >> $seqres.full +$CHATTR_PROG +i $fsv_file +$FSVERITY_PROG enable $fsv_file |& _filter_scratch +$CHATTR_PROG -i $fsv_file + +_fsv_scratch_begin_subtest "FS_IOC_MEASURE_VERITY doesn't require root" +_fsv_create_enable_file $fsv_file >> $seqres.full +chmod 444 $fsv_file +su $qa_user -c "$FSVERITY_PROG measure $fsv_file" >> $seqres.full + +# success, all done +status=0 +exit diff --git a/tests/generic/901.out b/tests/generic/901.out new file mode 100644 index 00000000..a9e4c364 --- /dev/null +++ b/tests/generic/901.out @@ -0,0 +1,14 @@ +QA output created by 901 + +# FS_IOC_ENABLE_VERITY doesn't require root + +# FS_IOC_ENABLE_VERITY requires write access +Permission denied + +# FS_IOC_ENABLE_VERITY requires !append-only +ERROR: FS_IOC_ENABLE_VERITY failed on 'SCRATCH_MNT/file.fsv': Operation not permitted + +# FS_IOC_ENABLE_VERITY requires !immutable +ERROR: FS_IOC_ENABLE_VERITY failed on 'SCRATCH_MNT/file.fsv': Operation not permitted + +# FS_IOC_MEASURE_VERITY doesn't require root diff --git a/tests/generic/group b/tests/generic/group index 7f72b304..df074d86 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -561,3 +561,4 @@ 556 auto quick casefold 557 auto quick log 900 auto quick verity +901 auto quick verity -- 2.22.0.410.gd8fdbe21b5-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel