From patchwork Sun Jan 31 21:24:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 8174941 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 081E4BEEE5 for ; Sun, 31 Jan 2016 21:25:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9C132012E for ; Sun, 31 Jan 2016 21:24:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF4242011B for ; Sun, 31 Jan 2016 21:24:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757437AbcAaVY5 (ORCPT ); Sun, 31 Jan 2016 16:24:57 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:36452 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757294AbcAaVY4 (ORCPT ); Sun, 31 Jan 2016 16:24:56 -0500 Received: by mail-lb0-f175.google.com with SMTP id dx2so64888760lbd.3; Sun, 31 Jan 2016 13:24:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=OzuexoMg13qhWOW/e9JyvtwQb+GRmzsBDdJ8OKtJkCw=; b=wP77CBLomsSUUNQACZLPs8Bj+oQgsA8Z+devEGy8jp5vDUwTYG915ytfHuRssHRCtv vHtTU3+NRP2bpsvzI6oVFKmBJouzG5UiFYAQz+azOhFLPemv65+pLczsvG8g5OcqCgnf /uKtYZwJSOQARTSlgcj9NgyguO0ikSuRb+AtugKjaKtF6tmYzQcVYHDmY7EmmEKRaLwJ Fner3QKdEAOVTWJRRhxB2+ftd2JGg5pKVsc78b95775cTxu3SiIuSiaP+xNxdPYqHQJP LxIUJJmEu1LP+MSe45ZT2L/XXIeAA3tRPRCJ7ZDMlzWtwnmNIL4DHi+tzASnao97+4ls KgTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:to:cc:date:message-id:user-agent :mime-version:content-type:content-transfer-encoding; bh=OzuexoMg13qhWOW/e9JyvtwQb+GRmzsBDdJ8OKtJkCw=; b=L0MmOvL+qcxl907X6RaNZ2jho7JFET0Bp/l7GUjMDxDP/+60+VDUcI2f90wzDOeHer dUnDu+Q7CVggrtHrMifCxOpipsUWcwowl+GwIXOfJt5EvAIqmqMPZPvLWydAGuuIL2Ud GoDE3xJsj5Io09zr2p26ddGDx/tuYbGjMSmz1y8LD1Bv0zH8Crl+veOj886RRFYuHswD dFgiUqsDxvLzyngVLIVldv3N7dzhXG81jh/VVgMPhyk3Nn4DeITdeGnVaGDtw/sqM04S 7Yc/ZInzBhXwww89NHyEu2yT26O5BSs/Q2Qc3W4BOAvB4Qk6++2PTyYGY+0JKM7k2O5V 7EHA== X-Gm-Message-State: AG10YOQB6sqyapiVTMBEV94jjJ9MiIuRphF6Km9f9zgDzaC2vXBTOaaFg9mKZEmwdZj2IA== X-Received: by 10.112.199.197 with SMTP id jm5mr5573837lbc.109.1454275494192; Sun, 31 Jan 2016 13:24:54 -0800 (PST) Received: from localhost (ppp79-139-147-94.pppoe.spdop.ru. [79.139.147.94]) by smtp.gmail.com with ESMTPSA id k65sm455545lfe.41.2016.01.31.13.24.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Jan 2016 13:24:52 -0800 (PST) Subject: [PATCH] overlay: test permission checks within upper layer From: Konstantin Khlebnikov To: fstests@vger.kernel.org Cc: Miklos Szeredi , Eryu Guan , linux-unionfs@vger.kernel.org Date: Mon, 01 Feb 2016 00:24:49 +0300 Message-ID: <145427548927.28315.7391257381640174593.stgit@zurg> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Verify that unpriveleged user cannot copy-up and change file mode. Signed-off-by: Konstantin Khlebnikov --- tests/overlay/001 | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/001.out | 2 + tests/overlay/group | 6 +++ 3 files changed, 95 insertions(+) create mode 100755 tests/overlay/001 create mode 100644 tests/overlay/001.out create mode 100644 tests/overlay/group -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tests/overlay/001 b/tests/overlay/001 new file mode 100755 index 000000000000..28fdf2af2b57 --- /dev/null +++ b/tests/overlay/001 @@ -0,0 +1,87 @@ +#! /bin/bash +# FS QA Test 001 +# +# Test permission checks for operations within upper layer +# +# Ubuntu CVE-2015-1328 +# acff81ec2c79 ("ovl: fix permission checking for setattr") +# cf9a6784f7c1 ("ovl: setattr: check permissions before copy-up") +# +#----------------------------------------------------------------------- +# Copyright (c) 2016 Konstantin Khlebnikov. All Rights Reserved. +# +# 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/$$ +runas=$here/src/runas +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* + rm -fr $TEST_DEV/lower/$seq.dir + rm -fr $TEST_DEV/upper/$seq.dir +} + +# 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 overlay +_supported_os Linux +_require_test +_need_to_be_root + +echo "Silence is golden." + +[ -x $runas ] || _notrun "$runas executable not found" + +cd $TEST_DEV/lower +mkdir $seq.dir +touch $seq.dir/file +chmod 444 $seq.dir/file + +cd $TEST_DEV/upper +mkdir $seq.dir +chmod 555 $seq.dir + +cd $TEST_DIR +$runas -u 99 -g 99 chmod 777 $seq.dir/file >/dev/null 2>&1 + +cd $TEST_DEV/upper +if [ -e $seq.dir/file ] ; then + echo "FAIL: unpriveleged user copied-up file into upper" + if [ `stat -c '%a' $seq.dir/file` != 444 ] ; then + echo "FAIL: unpriveleged user changed file attributes" + fi +fi + +# success, all done +status=0 +exit diff --git a/tests/overlay/001.out b/tests/overlay/001.out new file mode 100644 index 000000000000..2d86e35be2fb --- /dev/null +++ b/tests/overlay/001.out @@ -0,0 +1,2 @@ +QA output created by 001 +Silence is golden. diff --git a/tests/overlay/group b/tests/overlay/group new file mode 100644 index 000000000000..51a62cf64b89 --- /dev/null +++ b/tests/overlay/group @@ -0,0 +1,6 @@ +# QA groups control +# +# define groups and default group owners +# do not start group name with a digit +# +001 perms auto quick