Received: by 10.223.185.116 with SMTP id b49csp213952wrg; Thu, 15 Feb 2018 20:12:58 -0800 (PST) X-Google-Smtp-Source: AH8x226NVS3ZmU8kEOkGuxvK6KWnz6dnd2gYXZBRsFdGj8o6ojLfBqiDh1KB7/b3wjyaHx+53w7K X-Received: by 10.101.72.136 with SMTP id n8mr4095013pgs.201.1518754378838; Thu, 15 Feb 2018 20:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518754378; cv=none; d=google.com; s=arc-20160816; b=BiIh8z3u/iJftTvj8uYBbl8xEuMm4tIS4vOhIxvTw04Pp4sOHA7CZPLh+GinLZnGpl EhW/wV/6Dd4NO5QixNHsuFU5FpNDeXFaymQIb7h096y+HQZRq6/gmgA84AnJNd/Qjugt KRfi3iBHvGzV5RiFD8eilwnEyrtJcgWaGEfZcHQdvpoIuBv+WB+iO9vegogbEhT7HDsw qdZ2HOdh8a2I50u4q437tSLqe1fd5Zr0n9HdpIQZB1FFNAltUfht3qbm4AEL0WY5alMy bhk1QWUtDnf9n2O5dqAze90HJZMenSnvNccAUwONEHMZrQ8bd+NYTCtJ7KVbqQjr29R3 rIHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4RuC3jC7TiNwW6/sUY/uE1m5IFaWpKTlvXBWWg9q7pw=; b=yISkXRSXRD93/NqmsfApRvVtYF0AbvIKKcA/4eBrMqS81Y4iPf2N9cUcQAjc6LY9ZV UrZ5TXoGKPyw6ggBS5FLjVHMDMhPUIx9r8fxmmj04Qdl1af4MvT+qsOy2awVu6W1Nsjc p224niVIjrT9On41/Xbspx2p2/LX+leHcHNZ2BIW3cMtAtZj4QfNghq8GChSkbDbrCS2 jt+RdUz2spb2kvIwXtPdrG2mBeDEE8XiFAaBIz3Gjj40iadgn0v5fYYaYvetfb9d/5xO ul6T5INgEBOKS+wsoDU7IaCfUAQNfYYulLnkxuYMHW3hsKegsuDdBm6jwUrbLP7w+WhY qzaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si985884pll.84.2018.02.15.20.12.44; Thu, 15 Feb 2018 20:12:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424931AbeBOPri (ORCPT + 99 others); Thu, 15 Feb 2018 10:47:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36264 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424903AbeBOPre (ORCPT ); Thu, 15 Feb 2018 10:47:34 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 503D01025; Thu, 15 Feb 2018 15:47:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amir Goldstein , Miklos Szeredi Subject: [PATCH 4.15 194/202] ovl: take mnt_want_write() for work/index dir setup Date: Thu, 15 Feb 2018 16:18:14 +0100 Message-Id: <20180215151722.839774477@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein commit 2ba9d57e65044859f7ff133bcb0a902769bf3bc6 upstream. There are several write operations on upper fs not covered by mnt_want_write(): - test set/remove OPAQUE xattr - test create O_TMPFILE - set ORIGIN xattr in ovl_verify_origin() - cleanup of index entries in ovl_indexdir_cleanup() Some of these go way back, but this patch only applies over the v4.14 re-factoring of ovl_fill_super(). Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/super.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -520,10 +520,6 @@ static struct dentry *ovl_workdir_create bool retried = false; bool locked = false; - err = mnt_want_write(mnt); - if (err) - goto out_err; - inode_lock_nested(dir, I_MUTEX_PARENT); locked = true; @@ -588,7 +584,6 @@ retry: goto out_err; } out_unlock: - mnt_drop_write(mnt); if (locked) inode_unlock(dir); @@ -930,12 +925,17 @@ out: static int ovl_make_workdir(struct ovl_fs *ofs, struct path *workpath) { + struct vfsmount *mnt = ofs->upper_mnt; struct dentry *temp; int err; + err = mnt_want_write(mnt); + if (err) + return err; + ofs->workdir = ovl_workdir_create(ofs, OVL_WORKDIR_NAME, false); if (!ofs->workdir) - return 0; + goto out; /* * Upper should support d_type, else whiteouts are visible. Given @@ -945,7 +945,7 @@ static int ovl_make_workdir(struct ovl_f */ err = ovl_check_d_type_supported(workpath); if (err < 0) - return err; + goto out; /* * We allowed this configuration and don't want to break users over @@ -969,6 +969,7 @@ static int ovl_make_workdir(struct ovl_f if (err) { ofs->noxattr = true; pr_warn("overlayfs: upper fs does not support xattr.\n"); + err = 0; } else { vfs_removexattr(ofs->workdir, OVL_XATTR_OPAQUE); } @@ -980,7 +981,9 @@ static int ovl_make_workdir(struct ovl_f pr_warn("overlayfs: upper fs does not support file handles, falling back to index=off.\n"); } - return 0; +out: + mnt_drop_write(mnt); + return err; } static int ovl_get_workdir(struct ovl_fs *ofs, struct path *upperpath) @@ -1027,8 +1030,13 @@ out: static int ovl_get_indexdir(struct ovl_fs *ofs, struct ovl_entry *oe, struct path *upperpath) { + struct vfsmount *mnt = ofs->upper_mnt; int err; + err = mnt_want_write(mnt); + if (err) + return err; + /* Verify lower root is upper root origin */ err = ovl_verify_origin(upperpath->dentry, oe->lowerstack[0].dentry, false, true); @@ -1056,6 +1064,7 @@ static int ovl_get_indexdir(struct ovl_f pr_warn("overlayfs: try deleting index dir or mounting with '-o index=off' to disable inodes index.\n"); out: + mnt_drop_write(mnt); return err; }