From patchwork Mon May 18 16:11:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11555689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B222E60D for ; Mon, 18 May 2020 16:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BB07207FB for ; Mon, 18 May 2020 16:11:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LZS3kCGH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbgERQLi (ORCPT ); Mon, 18 May 2020 12:11:38 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50646 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727005AbgERQLi (ORCPT ); Mon, 18 May 2020 12:11:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589818296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=4GUks1QQqQvNLSr3ECEV+Bzs3hdGdAR04m1gn7tT14Y=; b=LZS3kCGHCfsxOycxOz8zca7fuCUcQ8+QBYIbQfhL6zy+3wTdpya540x4/uk30vsPMJ87cZ MWTYlRQkEAUdGYfcaLO+KkCOCDuM0ZrxwH+kp3slOFGvXah5QI84c1dbRz+7M5W5BbX7oI f9kGL54RXVBhlxatuknxByEiQsPejGY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-HwT-zCDrOUepqzPe0G41jQ-1; Mon, 18 May 2020 12:11:34 -0400 X-MC-Unique: HwT-zCDrOUepqzPe0G41jQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92C82835B50 for ; Mon, 18 May 2020 16:11:33 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 103B71057FA7 for ; Mon, 18 May 2020 16:11:32 +0000 (UTC) Subject: [PATCH 1/5] fstests: add _require_sysctl_variable helper From: Eric Sandeen To: fstests References: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Autocrypt: addr=sandeen@redhat.com; prefer-encrypt=mutual; keydata= mQINBE6x99QBEADMR+yNFBc1Y5avoUhzI/sdR9ANwznsNpiCtZlaO4pIWvqQJCjBzp96cpCs nQZV32nqJBYnDpBDITBqTa/EF+IrHx8gKq8TaSBLHUq2ju2gJJLfBoL7V3807PQcI18YzkF+ WL05ODFQ2cemDhx5uLghHEeOxuGj+1AI+kh/FCzMedHc6k87Yu2ZuaWF+Gh1W2ix6hikRJmQ vj5BEeAx7xKkyBhzdbNIbbjV/iGi9b26B/dNcyd5w2My2gxMtxaiP7q5b6GM2rsQklHP8FtW ZiYO7jsg/qIppR1C6Zr5jK1GQlMUIclYFeBbKggJ9mSwXJH7MIftilGQ8KDvNuV5AbkronGC sEEHj2khs7GfVv4pmUUHf1MRIvV0x3WJkpmhuZaYg8AdJlyGKgp+TQ7B+wCjNTdVqMI1vDk2 BS6Rg851ay7AypbCPx2w4d8jIkQEgNjACHVDU89PNKAjScK1aTnW+HNUqg9BliCvuX5g4z2j gJBs57loTWAGe2Ve3cMy3VoQ40Wt3yKK0Eno8jfgzgb48wyycINZgnseMRhxc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0jUDKcviOOfhbQxKJelYNTD5+wE4+TpqH XQLj5HUlzt3JSwqSwx+++FFfWFMheG2HzkfXrvTpud5NrJkGGVn+ErXy6pNf6zSicb+bUXe9 i92UTina2zWaaLEwXspqM338TlFC2JICu8pNt+wHpPCjgy2Ei4u5/4zSYjiA+X1I+V99YJhU +FpT2jzfLUoVsP/6WHWmM/tsS79i50G/PsXYzKOHj/0ZQCKOsJM14NMMCC8gkONe4tek Message-ID: <594b47bd-26b6-5156-9200-cc4c4d51d05d@redhat.com> Date: Mon, 18 May 2020 11:11:31 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org New _require_sysctl_variable test to ensure that the sysctl we wish to test is available on the system. Signed-off-by: Eric Sandeen --- Next 2 patches will use this. V2: rename to "_require_sysctl_variable" (sysctl man page calls these "variables") common/rc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/rc b/common/rc index b25cad0e..62952036 100644 --- a/common/rc +++ b/common/rc @@ -4209,6 +4209,12 @@ _require_bsd_process_accounting() $ACCTON_PROG off >> $seqres.full } +_require_sysctl_variable() +{ + local name=$1 + sysctl $name &>/dev/null || _notrun "$name sysctl unavailable" +} + init_rc ################################################################################ From patchwork Mon May 18 16:14:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11555695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5C4960D for ; Mon, 18 May 2020 16:14:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9947D207D8 for ; Mon, 18 May 2020 16:14:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DL5MSW7i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbgERQOu (ORCPT ); Mon, 18 May 2020 12:14:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50167 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726958AbgERQOt (ORCPT ); Mon, 18 May 2020 12:14:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589818486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=7TJefXKcAkVIG8BHiJMGC0i8JX4aYKZuA5PkXcpUx7s=; b=DL5MSW7iAMD6LEj837rdGDdB923YywtUu7gX2rTI6t5ecdNOHG6BPm6kPYY+e0M4VYvqVV s+9f1C9UOCN3LYoNoAV0PT05CKZpuJ+RlrzOSDGMHJXY3v7m1CwWzzcvYq26XRzN91Cldk BSu30kACh8ZjFEBprcSaeawKYXnQN7k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-bwoeJ9jsMiChI0XuPPfQkw-1; Mon, 18 May 2020 12:14:45 -0400 X-MC-Unique: bwoeJ9jsMiChI0XuPPfQkw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4DAE2EC1A0 for ; Mon, 18 May 2020 16:14:44 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CC6C78B54 for ; Mon, 18 May 2020 16:14:44 +0000 (UTC) Subject: [PATCH 2/5] fstests: test restricted symlinks & hardlinks sysctls From: Eric Sandeen To: fstests References: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Autocrypt: addr=sandeen@redhat.com; prefer-encrypt=mutual; keydata= mQINBE6x99QBEADMR+yNFBc1Y5avoUhzI/sdR9ANwznsNpiCtZlaO4pIWvqQJCjBzp96cpCs nQZV32nqJBYnDpBDITBqTa/EF+IrHx8gKq8TaSBLHUq2ju2gJJLfBoL7V3807PQcI18YzkF+ WL05ODFQ2cemDhx5uLghHEeOxuGj+1AI+kh/FCzMedHc6k87Yu2ZuaWF+Gh1W2ix6hikRJmQ vj5BEeAx7xKkyBhzdbNIbbjV/iGi9b26B/dNcyd5w2My2gxMtxaiP7q5b6GM2rsQklHP8FtW ZiYO7jsg/qIppR1C6Zr5jK1GQlMUIclYFeBbKggJ9mSwXJH7MIftilGQ8KDvNuV5AbkronGC sEEHj2khs7GfVv4pmUUHf1MRIvV0x3WJkpmhuZaYg8AdJlyGKgp+TQ7B+wCjNTdVqMI1vDk2 BS6Rg851ay7AypbCPx2w4d8jIkQEgNjACHVDU89PNKAjScK1aTnW+HNUqg9BliCvuX5g4z2j gJBs57loTWAGe2Ve3cMy3VoQ40Wt3yKK0Eno8jfgzgb48wyycINZgnseMRhxc2c8hd51tftK LKhPj4c7uqjnBjrgOVaVBupGUmvLiePlnW56zJZ51BR5igWnILeOJ1ZIcf7KsaHyE6B1mG+X dmYtjDhjf3NAcoBWJuj8euxMB6TcQN2MrSXy5wSKaw40evooGwARAQABtCRFcmljIFIuIFNh bmRlZW4gPHNhbmRlZW5AcmVkaGF0LmNvbT6JAjgEEwECACIFAk6yrl4CGwMGCwkIBwMCBhUI AgkKCwQ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C8gkONe4tek Message-ID: <8640243b-8056-a81a-9c23-d19c4e0dc426@redhat.com> Date: Mon, 18 May 2020 11:14:43 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org This tests the fs.protected_symlinks and fs.protected_hardlinks sysctls which restrict links behavior in sticky world-writable directories as documented in the kernel at Documentation/admin-guide/sysctl/fs.rst Signed-off-by: Eric Sandeen --- V2: many fixes requested by Eryu update copyright reset sysctl only if saved switch to _user_do fix test description in comments tests/generic/900 | 115 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/900.out | 14 +++++ tests/generic/group | 1 + 3 files changed, 130 insertions(+) create mode 100755 tests/generic/900 create mode 100644 tests/generic/900.out diff --git a/tests/generic/900 b/tests/generic/900 new file mode 100755 index 00000000..fd54fa4e --- /dev/null +++ b/tests/generic/900 @@ -0,0 +1,115 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 900 +# +# Test protected_symlink and protected_hardlink sysctls +# +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() +{ + rm -rf $TEST_DIR/$seq + [ ! -z "$SYMLINK_PROTECTION" ] \ + && sysctl -qw fs.protected_symlinks=$SYMLINK_PROTECTION + [ ! -z "$HARDLINK_PROTECTION" ] \ + && sysctl -qw fs.protected_hardlinks=$HARDLINK_PROTECTION + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test +_require_sysctl_variable fs.protected_symlinks +_require_sysctl_variable fs.protected_hardlinks +_require_user 123456-fsgqa +# Do this SECOND so that qa_user is fsgqa, and _do_user uses that account +_require_user fsgqa + +OWNER=123456-fsgqa +OTHER=fsgqa + +# Save current system state to reset when done +SYMLINK_PROTECTION=`sysctl -n fs.protected_symlinks` +HARDLINK_PROTECTION=`sysctl -n fs.protected_hardlinks` + +test_symlink() +{ + ln -s $TEST_DIR/$seq/target $TEST_DIR/$seq/sticky_dir/symlink + chown $OTHER.$OTHER $TEST_DIR/$seq/sticky_dir + chown $OWNER.$OWNER $TEST_DIR/$seq/sticky_dir/symlink + # If we can read the target, we followed the link + _user_do "cat $TEST_DIR/$seq/sticky_dir/symlink" | _filter_test_dir + rm -f $TEST_DIR/$seq/sticky_dir/symlink +} + +test_hardlink() +{ + chown $OWNER.$OWNER $TEST_DIR/$seq/target + chmod go-rw $TEST_DIR/$seq/target + _user_do "ln $TEST_DIR/$seq/target $TEST_DIR/$seq/sticky_dir/hardlink" \ + | _filter_test_dir + test -f $TEST_DIR/$seq/sticky_dir/hardlink \ + && echo "successfully created hardlink" + rm -f $TEST_DIR/$seq/sticky_dir/hardlink +} + +setup_tree() +{ + # Create world-writable sticky dir + mkdir -p $TEST_DIR/$seq/sticky_dir + chmod 1777 $TEST_DIR/$seq/sticky_dir + # And a file elsewhere that will be linked to from that sticky dir + mkdir -p $TEST_DIR/$seq + # If we can read it, we followed the link. + echo "successfully followed symlink" > $TEST_DIR/$seq/target +} + +setup_tree + +# First test fs.protected_symlinks +# With protection on, symlink follows should fail if the +# link owner != the sticky directory owner, and the process +# is not the link owner. +echo "== Test symlink follow protection when" +echo "== process != link owner and dir owner != link owner" +sysctl -w fs.protected_symlinks=0 +test_symlink +sysctl -w fs.protected_symlinks=1 +test_symlink + +echo + +# Now test fs.protected_hardlinks +# With protection on, hardlink creation should fail if the +# process does not own the target file, and the process does not have +# read-write access to the target +echo "== Test hardlink create protection when" +echo "== process != target owner and process cannot read target" +sysctl -w fs.protected_hardlinks=0 +test_hardlink +sysctl -w fs.protected_hardlinks=1 +test_hardlink + +# success, all done +status=0 +exit diff --git a/tests/generic/900.out b/tests/generic/900.out new file mode 100644 index 00000000..7adf97ed --- /dev/null +++ b/tests/generic/900.out @@ -0,0 +1,14 @@ +QA output created by 900 +== Test symlink follow protection when +== process != link owner and dir owner != link owner +fs.protected_symlinks = 0 +successfully followed symlink +fs.protected_symlinks = 1 +Permission denied + +== Test hardlink create protection when +== process != target owner and process cannot read target +fs.protected_hardlinks = 0 +successfully created hardlink +fs.protected_hardlinks = 1 +ln: failed to create hard link 'TEST_DIR/900/sticky_dir/hardlink' => 'TEST_DIR/900/target': Operation not permitted diff --git a/tests/generic/group b/tests/generic/group index e82004e8..fd2360ea 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -599,3 +599,4 @@ 594 auto quick quota 595 auto quick encrypt 596 auto quick +900 auto quick perms From patchwork Mon May 18 16:15:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11555697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AE1460D for ; Mon, 18 May 2020 16:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5075C207D8 for ; Mon, 18 May 2020 16:15:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LXmu7jVc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727973AbgERQPl (ORCPT ); Mon, 18 May 2020 12:15:41 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52849 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727782AbgERQPk (ORCPT ); Mon, 18 May 2020 12:15:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589818538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=RgWtGio7PbXM46gR/MOQAHF5vazi9PUJKZvk0jgA2lk=; b=LXmu7jVcPwYPjb65C/ok/t5mEoaL1DBmkl0YUlnhSU2kmKl3rywE1gm7IOqugGikn3x+7e fDB4R5S/fASCOCCv81Y70cObIm4HxWCo46fAI8ZYugyana07WKAZcX6aBBz+s2Si/OxFAe LRvFUT3OKQRncqoSIXKsBlJTCerci4Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-92-cdcY2I95MPWnZ38N8u2hiA-1; Mon, 18 May 2020 12:15:36 -0400 X-MC-Unique: cdcY2I95MPWnZ38N8u2hiA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B304A107ACF5 for ; Mon, 18 May 2020 16:15:35 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B6325C1B2 for ; Mon, 18 May 2020 16:15:35 +0000 (UTC) Subject: [PATCH 3/5] fstests: test restricted file access sysctls From: Eric Sandeen To: fstests References: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Autocrypt: addr=sandeen@redhat.com; prefer-encrypt=mutual; keydata= mQINBE6x99Q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/fGzE3l62F4sw6BHBak ufrI0Wr/G2Cz4QKAb6BHvzJdDIDuIKzm0WzY6sypXmO5IwaafSTElQARAQABiQIfBBgBAgAJ BQJOsffUAhsMAAoJECCuFpLhPd7gErAP/Rk46ZQ05kJI4sAyNnHea1i2NiB9Q0qLSSJg+94a hFZOpuKzxSK0+02sbhfGDMs6KNJ04TNDCR04in9CdmEY2ywx6MKeyW4rQZB35GQVVY2ZxBPv yEF4ZycQwBdkqrtuQgrO9zToYWaQxtf+ACXoOI0a/RQ0Bf7kViH65wIllLICnewD738sqPGd N51fRrKBcDquSlfRjQW83/11+bjv4sartYCoE7JhNTcTr/5nvZtmgb9wbsA0vFw+iiUs6tTj eioWcPxDBw3nrLhV8WPf+MMXYxffG7i/Y6OCVWMwRgdMLE/eanF6wYe6o6K38VH6YXQw/0kZ +PrH5uP/0kwG0JbVtj9o94x08ZMm9eMa05VhuUZmtKNdGfn75S7LfoK+RyuO7OJIMb4kR7Eb FzNbA3ias5BaExPknJv7XwI74JbEl8dpheIsRbt0jUDKcviOOfhbQxKJelYNTD5+wE4+TpqH XQLj5HUlzt3JSwqSwx+++FFfWFMheG2HzkfXrvTpud5NrJkGGVn+ErXy6pNf6zSicb+bUXe9 i92UTina2zWaaLEwXspqM338TlFC2JICu8pNt+wHpPCjgy2Ei4u5/4zSYjiA+X1I+V99YJhU +FpT2jzfLUoVsP/6WHWmM/tsS79i50G/PsXYzKOHj/0ZQCKOsJM14NMMCC8gkONe4tek Message-ID: <9de038fc-1c35-db0b-3576-cd4bfbe4a70f@redhat.com> Date: Mon, 18 May 2020 11:15:34 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org This tests the fs.protected_regular and fs.protected_fifos sysctls which restrict access behavior in sticky world-writable directories as documented in the kernel at Documentation/admin-guide/sysctl/fs.rst Signed-off-by: Eric Sandeen --- V2: Same fixes as prior patch tests/generic/901 | 126 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/901.out | 28 ++++++++++ tests/generic/group | 1 + 3 files changed, 155 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..4e04155e --- /dev/null +++ b/tests/generic/901 @@ -0,0 +1,126 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 901 +# +# Test protected_regular and protected_fifos sysctls +# +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() +{ + rm -rf $TEST_DIR/$seq + [ ! -z "$REGULAR_PROTECTION" ] \ + && sysctl -qw fs.protected_regular=$REGULAR_PROTECTION + [ ! -z "$FIFO_PROTECTION" ] \ + && sysctl -qw fs.protected_fifos=$FIFO_PROTECTION + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test +_require_sysctl_variable fs.protected_regular +_require_sysctl_variable fs.protected_fifos +_require_user 123456-fsgqa +# Do this SECOND so that qa_user is fsgqa, and _do_user uses that account +_require_user fsgqa + +USER1=123456-fsgqa +USER2=fsgqa + +# Save current system state to reset when done +REGULAR_PROTECTION=`sysctl -n fs.protected_regular` +FIFO_PROTECTION=`sysctl -n fs.protected_fifos` + +test_access() +{ + FILENAME=$1 + + # sticky dir is world & group writable: + echo "= group & world writable dir" + chmod og+w $TEST_DIR/$seq/sticky_dir + # "open -f" opens O_CREAT + _user_do "$XFS_IO_PROG -c \"open -f $TEST_DIR/$seq/sticky_dir/$FILENAME\"" + # sticky dir is only group writable: + echo "= only group writable dir" + chmod o-w $TEST_DIR/$seq/sticky_dir + _user_do "$XFS_IO_PROG -c \"open -f $TEST_DIR/$seq/sticky_dir/$FILENAME\"" +} + +setup_tree() +{ + # Create sticky dir owned by $USER2 + mkdir -p $TEST_DIR/$seq + mkdir -p $TEST_DIR/$seq/sticky_dir + chmod 1777 $TEST_DIR/$seq/sticky_dir + chown $USER2.$USER2 $TEST_DIR/$seq/sticky_dir + + # Create file & fifo in that dir owned by $USER1, and open + # normal read/write privs for world & group + $XFS_IO_PROG -c "open -f $TEST_DIR/$seq/sticky_dir/file" + chown $USER1.$USER1 $TEST_DIR/$seq/sticky_dir/file + chmod o+rw $TEST_DIR/$seq/sticky_dir/file + + mkfifo $TEST_DIR/$seq/sticky_dir/fifo + chown $USER1.$USER1 $TEST_DIR/$seq/sticky_dir/fifo + chmod o+rw $TEST_DIR/$seq/sticky_dir/fifo +} + +setup_tree + +# First test fs.protected_regular +# With protection set to 1, O_CREAT opens in a world-writable sticky +# directory should fail if the file exists, is owned by another, and +# file owner != dir owner +# +# With protection set to 2, the same goes for group-writable +# sticky directories + +echo "== Test file open when owned by another and file owner != dir owner" +sysctl -w fs.protected_regular=0 +test_access file +sysctl -w fs.protected_regular=1 +test_access file +sysctl -w fs.protected_regular=2 +test_access file + +echo + +# Now test fs.protected_fifos +# With protection set to 1, O_CREAT opens in a world-writable sticky +# directory should fail if the fifo exists, is owned by another, and +# file owner != dir owner +# +# With protection set to 2, the same goes for group-writable +# sticky directories +echo "== Test fifo open when owned by another and fifo owner != dir owner" +sysctl -w fs.protected_fifos=0 +test_access fifo +sysctl -w fs.protected_fifos=1 +test_access fifo +sysctl -w fs.protected_fifos=2 +test_access fifo + +# success, all done +status=0 +exit diff --git a/tests/generic/901.out b/tests/generic/901.out new file mode 100644 index 00000000..5f95d9be --- /dev/null +++ b/tests/generic/901.out @@ -0,0 +1,28 @@ +QA output created by 901 +== Test file open when owned by another and file owner != dir owner +fs.protected_regular = 0 += group & world writable dir += only group writable dir +fs.protected_regular = 1 += group & world writable dir +Permission denied += only group writable dir +fs.protected_regular = 2 += group & world writable dir +Permission denied += only group writable dir +Permission denied + +== Test fifo open when owned by another and fifo owner != dir owner +fs.protected_fifos = 0 += group & world writable dir += only group writable dir +fs.protected_fifos = 1 += group & world writable dir +Permission denied += only group writable dir +fs.protected_fifos = 2 += group & world writable dir +Permission denied += only group writable dir +Permission denied diff --git a/tests/generic/group b/tests/generic/group index fd2360ea..50c340a6 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -600,3 +600,4 @@ 595 auto quick encrypt 596 auto quick 900 auto quick perms +901 auto quick perms From patchwork Mon May 18 16:16:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11555699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7066912 for ; Mon, 18 May 2020 16:16:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB01B207D8 for ; Mon, 18 May 2020 16:16:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i2DE0oQp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbgERQQy (ORCPT ); Mon, 18 May 2020 12:16:54 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57241 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726958AbgERQQy (ORCPT ); Mon, 18 May 2020 12:16:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589818612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=i2JZyEB5WU/zHbClWF2rTgCJGJ8RuiVVx0Xcz2lXh7o=; b=i2DE0oQp0kjrv6MAK1Li8Q4mhlvfEfpRVlVoG3f73ipp+/9jFq0Nklp5ZLnnywIsEzT0kf IyHMw5xTIOd2i3iahiU85uLB2/3A2foYfX62/4xJrvMmrb9Cw71gGE9Gmk9bGz53qP+dFs G2g9fmzJCDR7KYGdMuoHNlB1NJdIxx8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-NKPeyQQLPESMmgkjq1Cy3Q-1; Mon, 18 May 2020 12:16:49 -0400 X-MC-Unique: NKPeyQQLPESMmgkjq1Cy3Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F079C835B75 for ; Mon, 18 May 2020 16:16:48 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E3A25D9DD for ; Mon, 18 May 2020 16:16:48 +0000 (UTC) Subject: [PATCH 4/5] fstests: add _require_mknod From: Eric Sandeen To: fstests References: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Autocrypt: addr=sandeen@redhat.com; prefer-encrypt=mutual; keydata= mQINBE6x99QBEADMR+yNFBc1Y5avoUhzI/sdR9ANwznsNpiCtZlaO4pIWvqQJCjBzp96cpCs nQZV32nqJBYnDpBDITBqTa/EF+IrHx8gKq8TaSBLHUq2ju2gJJLfB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Pd7gErAP/Rk46ZQ05kJI4sAyNnHea1i2NiB9Q0qLSSJg+94a hFZOpuKzxSK0+02sbhfGDMs6KNJ04TNDCR04in9CdmEY2ywx6MKeyW4rQZB35GQVVY2ZxBPv yEF4ZycQwBdkqrtuQgrO9zToYWaQxtf+ACXoOI0a/RQ0Bf7kViH65wIllLICnewD738sqPGd N51fRrKBcDquSlfRjQW83/11+bjv4sartYCoE7JhNTcTr/5nvZtmgb9wbsA0vFw+iiUs6tTj eioWcPxDBw3nrLhV8WPf+MMXYxffG7i/Y6OCVWMwRgdMLE/eanF6wYe6o6K38VH6YXQw/0kZ +PrH5uP/0kwG0JbVtj9o94x08ZMm9eMa05VhuUZmtKNdGfn75S7LfoK+RyuO7OJIMb4kR7Eb FzNbA3ias5BaExPknJv7XwI74JbEl8dpheIsRbt0jUDKcviOOfhbQxKJelYNTD5+wE4+TpqH XQLj5HUlzt3JSwqSwx+++FFfWFMheG2HzkfXrvTpud5NrJkGGVn+ErXy6pNf6zSicb+bUXe9 i92UTina2zWaaLEwXspqM338TlFC2JICu8pNt+wHpPCjgy2Ei4u5/4zSYjiA+X1I+V99YJhU +FpT2jzfLUoVsP/6WHWmM/tsS79i50G/PsXYzKOHj/0ZQCKOsJM14NMMCC8gkONe4tek Message-ID: <5c99e460-11bf-ade8-c2bd-afaccabf4b9f@redhat.com> Date: Mon, 18 May 2020 11:16:47 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Add a _require_mknod test so that filesystems with no ->mknod operation will _notrun instead of fail, and add the helper to all necessary tests. Signed-off-by: Eric Sandeen --- common/rc | 7 +++++++ tests/generic/062 | 1 + tests/generic/184 | 1 + tests/generic/306 | 1 + tests/generic/401 | 1 + tests/generic/434 | 1 + tests/generic/479 | 1 + tests/generic/564 | 3 +++ 8 files changed, 16 insertions(+) diff --git a/common/rc b/common/rc index 62952036..310fdc46 100644 --- a/common/rc +++ b/common/rc @@ -4215,6 +4215,13 @@ _require_sysctl_variable() sysctl $name &>/dev/null || _notrun "$name sysctl unavailable" } +_require_mknod() +{ + mknod $TEST_DIR/$seq.null c 1 3 \ + || _notrun "$FSTYP does not support mknod/mkfifo" + rm -f $TEST_DIR/$seq.null +} + init_rc ################################################################################ diff --git a/tests/generic/062 b/tests/generic/062 index ba744885..d2a0ac9a 100755 --- a/tests/generic/062 +++ b/tests/generic/062 @@ -60,6 +60,7 @@ _supported_os Linux _require_scratch _require_attrs _require_symlinks +_require_mknod rm -f $tmp.backup1 $tmp.backup2 $seqres.full diff --git a/tests/generic/184 b/tests/generic/184 index 8aca1a0d..94f4d0e1 100755 --- a/tests/generic/184 +++ b/tests/generic/184 @@ -29,6 +29,7 @@ _cleanup() _supported_fs generic _supported_os Linux _require_test +_require_mknod rm -f $TEST_DIR/null mknod $TEST_DIR/null c 1 3 diff --git a/tests/generic/306 b/tests/generic/306 index 046f4516..6f16a5f5 100755 --- a/tests/generic/306 +++ b/tests/generic/306 @@ -34,6 +34,7 @@ _supported_os Linux _require_scratch _require_test _require_symlinks +_require_mknod DEVNULL=$SCRATCH_MNT/devnull DEVZERO=$SCRATCH_MNT/devzero diff --git a/tests/generic/401 b/tests/generic/401 index 00e9bbe0..f8b1fd21 100755 --- a/tests/generic/401 +++ b/tests/generic/401 @@ -38,6 +38,7 @@ _supported_fs generic _supported_os Linux _require_scratch _require_symlinks +_require_mknod _require_test_program "t_dir_type" rm -f $seqres.full diff --git a/tests/generic/434 b/tests/generic/434 index edbf49d3..131c5d99 100755 --- a/tests/generic/434 +++ b/tests/generic/434 @@ -30,6 +30,7 @@ _supported_os Linux _require_xfs_io_command "copy_range" _require_test +_require_mknod testdir=$TEST_DIR/test-$seq rm -rf $testdir diff --git a/tests/generic/479 b/tests/generic/479 index aaf864a4..fc0b3b6c 100755 --- a/tests/generic/479 +++ b/tests/generic/479 @@ -33,6 +33,7 @@ _supported_fs generic _supported_os Linux _require_scratch _require_symlinks +_require_mknod _require_dm_target flakey rm -f $seqres.full diff --git a/tests/generic/564 b/tests/generic/564 index 4958b3b5..b9b21134 100755 --- a/tests/generic/564 +++ b/tests/generic/564 @@ -37,6 +37,9 @@ rm -f $seqres.full _require_test _require_loop +# for mkfifo +_require_mknod + # # This test effectively requires xfs_io with these commits # 2a42470b xfs_io: copy_file_range length is a size_t From patchwork Mon May 18 16:18:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11555701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90E2F912 for ; Mon, 18 May 2020 16:18:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79AB5207ED for ; Mon, 18 May 2020 16:18:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MEf2UMjS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728286AbgERQSN (ORCPT ); Mon, 18 May 2020 12:18:13 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57233 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728283AbgERQSM (ORCPT ); Mon, 18 May 2020 12:18:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589818692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=BG2s4CkLghCs0GxCCEXf3eVz5i2xfrSvtJep0n3EnXk=; b=MEf2UMjS4YG02rOkdp8A7NpNt0WTcdxxQlhToqMi5HtbhgMQVDmS8g76IcjOFyo2osotAd F640s8tzxGJbJ2jcL9SY2n0K/fUbF0z2jS8WlKaNLDdKiOC/Bt/HhnbVkMJgASX9YtK/M8 oZMtDDrq/aqyJg8l4zKqmF69k62RWxQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-KdYIQz8IMPq6-0FBQGVZZg-1; Mon, 18 May 2020 12:18:09 -0400 X-MC-Unique: KdYIQz8IMPq6-0FBQGVZZg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13FD080B700 for ; Mon, 18 May 2020 16:18:09 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DBBFD82A1C for ; Mon, 18 May 2020 16:18:08 +0000 (UTC) Subject: [PATCH 5/5] xfstests: check for unknown flag result in _require_xfs_io_command From: Eric Sandeen To: fstests References: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Autocrypt: addr=sandeen@redhat.com; prefer-encrypt=mutual; keydata= mQINBE6x99QBEADMR+yNFBc1Y5avoUhzI/sdR9ANwznsNpiCtZlaO4pIWvqQJCjBzp96cpCs nQZV32nqJBYnDpBDITBqTa/EF+IrHx8gKq8TaSBLHUq2ju2gJJLfBoL7V3807PQcI18YzkF+ WL05ODFQ2cemDhx5uLghHEeOxuGj+1AI+kh/FCzMedHc6k87Yu2ZuaWF+Gh1W2ix6hikRJmQ v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ywx6MKeyW4rQZB35GQVVY2ZxBPv yEF4ZycQwBdkqrtuQgrO9zToYWaQxtf+ACXoOI0a/RQ0Bf7kViH65wIllLICnewD738sqPGd N51fRrKBcDquSlfRjQW83/11+bjv4sartYCoE7JhNTcTr/5nvZtmgb9wbsA0vFw+iiUs6tTj eioWcPxDBw3nrLhV8WPf+MMXYxffG7i/Y6OCVWMwRgdMLE/eanF6wYe6o6K38VH6YXQw/0kZ +PrH5uP/0kwG0JbVtj9o94x08ZMm9eMa05VhuUZmtKNdGfn75S7LfoK+RyuO7OJIMb4kR7Eb FzNbA3ias5BaExPknJv7XwI74JbEl8dpheIsRbt0jUDKcviOOfhbQxKJelYNTD5+wE4+TpqH XQLj5HUlzt3JSwqSwx+++FFfWFMheG2HzkfXrvTpud5NrJkGGVn+ErXy6pNf6zSicb+bUXe9 i92UTina2zWaaLEwXspqM338TlFC2JICu8pNt+wHpPCjgy2Ei4u5/4zSYjiA+X1I+V99YJhU +FpT2jzfLUoVsP/6WHWmM/tsS79i50G/PsXYzKOHj/0ZQCKOsJM14NMMCC8gkONe4tek Message-ID: <77631ab5-9354-549e-bd20-71e15c26cc52@redhat.com> Date: Mon, 18 May 2020 11:18:08 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <91639515-d639-c155-7cc8-660536b75257@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org If we are testing for "xfs_io -c chattr $FOO" be sure to catch any unknown flag output and _notrun Signed-off-by: Eric Sandeen --- common/rc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/rc b/common/rc index 310fdc46..a6967831 100644 --- a/common/rc +++ b/common/rc @@ -2255,6 +2255,8 @@ _require_xfs_io_command() _notrun "xfs_io $command $param_checked not supported on $FSTYP" echo $testio | grep -q "Function not implemented" && \ _notrun "xfs_io $command $param_checked support is missing (missing syscall?)" + echo $testio | grep -q "unknown flag" && \ + _notrun "xfs_io $command $param_checked support is missing (unknown flag)" [ -n "$param" ] || return