From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f67.google.com ([74.125.83.67]:33746 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751462AbdILNmx (ORCPT ); Tue, 12 Sep 2017 09:42:53 -0400 Received: by mail-pg0-f67.google.com with SMTP id i130so4179005pgc.0 for ; Tue, 12 Sep 2017 06:42:52 -0700 (PDT) Received: from gopher.gmail.com (58-189-215-38f1.hyg2.eonet.ne.jp. [58.189.215.38]) by smtp.gmail.com with ESMTPSA id l27sm20214660pfg.172.2017.09.12.06.42.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 06:42:51 -0700 (PDT) Date: Tue, 12 Sep 2017 22:42:52 +0900 Message-ID: <87mv60vxr7.wl-satoru.takeuchi@gmail.com> From: Satoru Takeuchi To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: prevent to set invalid default subvolid MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-btrfs-owner@vger.kernel.org List-ID: `btrfs sub set-default` succeeds to set an ID which isn't corresponding to any fs/file tree. If such the bad ID is set to a filesystem, we can't mount this filesystem without specifying `subvol` or `subvolid` mount options. Signed-off-by: Satoru Takeuchi --- fs/btrfs/ioctl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index ae8fbf9..8e1bc19 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4057,6 +4057,10 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) ret = PTR_ERR(new_root); goto out; } + if (!is_fstree(new_root->objectid)) { + ret = -ENOENT; + goto out; + } path = btrfs_alloc_path(); if (!path) { -- 2.7.4