From patchwork Mon Oct 22 11:38:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 1625281 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6E87CDF2F5 for ; Mon, 22 Oct 2012 11:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582Ab2JVLiQ (ORCPT ); Mon, 22 Oct 2012 07:38:16 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:32345 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750991Ab2JVLiP (ORCPT ); Mon, 22 Oct 2012 07:38:15 -0400 X-IronPort-AV: E=Sophos;i="4.80,629,1344182400"; d="scan'208";a="6045052" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 22 Oct 2012 19:36:41 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q9MBcB7S007018 for ; Mon, 22 Oct 2012 19:38:11 +0800 Received: from [10.167.225.199] ([10.167.225.199]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012102219374276-658399 ; Mon, 22 Oct 2012 19:37:42 +0800 Message-ID: <50853040.1030404@cn.fujitsu.com> Date: Mon, 22 Oct 2012 19:38:40 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Linux Btrfs Subject: [PATCH 1/2] Btrfs: don't check the permission of the subvolume which we want to delete X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/10/22 19:37:42, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/10/22 19:37:43, Serialize complete at 2012/10/22 19:37:43 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Step to reproduce: # mkfs.btrfs # mount -o user_subvol_rm_allowed # mkdir /dir0 # chmod 777 /dir0 # btrfs sub snap /dir0/snap0 # su -c "btrfs sub del /dir0/snap0" -s /bin/bash nobody ERROR: cannot delete '/dir0/snap0' - Permission denied This is because we checked the permission of the subvolume that we want to delete, and found the user - nobody have no WRITE permission of this subvolume. I think we need not check the permission of the subvolume we want to delete, because we have the right to clean up the directory since we have WRITE and EXECUTE permission, just like rmdir command. Signed-off-by: Miao Xie --- fs/btrfs/ioctl.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index f5a2e6c..29fb07c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2062,10 +2062,6 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, if (root == dest) goto out_dput; - err = inode_permission(inode, MAY_WRITE | MAY_EXEC); - if (err) - goto out_dput; - /* check if subvolume may be deleted by a non-root user */ err = btrfs_may_delete(dir, dentry, 1); if (err)