Received: by 10.223.185.116 with SMTP id b49csp2194476wrg; Thu, 15 Feb 2018 07:56:27 -0800 (PST) X-Google-Smtp-Source: AH8x224bmhuFJ06FNOHU/9kvT2gTsKV7OMPwIEMu3MmcxCFrYbqm2HdAQYeALfgciNo+ar91nXDy X-Received: by 2002:a17:902:9343:: with SMTP id g3-v6mr2995616plp.319.1518710186939; Thu, 15 Feb 2018 07:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518710186; cv=none; d=google.com; s=arc-20160816; b=d3f0f+3ym6qDk+9XV3SR09bwL3Yur1uxS9628KeKMO70yqfjVlAJn21cwRaJp8HCM7 H3JRLYL06kx+DLlH1+4vsgZlZKma0zisk74WNZH6x4NgDb97+rce4Dj0JV1NppeIbmM9 +6KDVdvhMwfz9bm7C6FIPqxifBUn52Vex5EOkxiy0/r7UchU5/ubruLf+fuX7WWgD3jg hQh61wPPgG2xVi2k3UFc2Qumd8t9hIz3LAnBJKKgk61tPDgwsT7p1X8+GIqmYauQr2RX t22sEr1gAzkK2sJPJu4mZDEtZcZCAnRSUNw0FOScYR0GxEnx7Rq1QxN/3EtqJEnShdog y6qA== 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=G3wUDcPGf8FLa6PUPaH0CJp0Hw0hUH7lpQAhV2Pso1k=; b=hCg9hIKK4oGb49d1zEsO6ED5x2HcjzvKULHG3GttAP/44xrrusDH/IFY77gn77vtLo 97DAWMhnrtJeOw5G+8ZBe4QR9XpU3W6K5igl5fERb9flXe4LDOPawNSzVpJKAlvRY6T0 zeRWfe92PkrX5wlCFXJd/D3DBrswBxqofRML1cmtQZZFUZr+VLkjvnaQk7GNqpVXRKka XH+fqtHvy3/I8uEFTm1ZVLQnNPOumlPuKFFW2azPIsnuAqUtYN0wUpbJbYQsC2oKedZh 4vtQvLjAXVY/vqds4iWP3dfislfFtaqKMHvjQ8VnsnxTffKV/n014Lu/mCZFH+rJqJ2K SUYA== 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 e3-v6si691450plk.542.2018.02.15.07.56.12; Thu, 15 Feb 2018 07:56:26 -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 S1425275AbeBOPy6 (ORCPT + 99 others); Thu, 15 Feb 2018 10:54:58 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36218 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424460AbeBOPr0 (ORCPT ); Thu, 15 Feb 2018 10:47:26 -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 446551025; Thu, 15 Feb 2018 15:47:25 +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 192/202] ovl: force r/o mount when index dir creation fails Date: Thu, 15 Feb 2018 16:18:12 +0100 Message-Id: <20180215151722.765961034@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 972d0093c2f7b1bd57e47a1780a552dde528fd16 upstream. When work dir creation fails, a warning is emitted and overlay is mounted r/o. Trying to remount r/w will fail with no work dir. When index dir creation fails, the same warning is emitted and overlay is mounted r/o, but trying to remount r/w will succeed. This may cause unintentional corruption of filesystem consistency. Adjust the behavior of index dir creation failure to that of work dir creation failure and do not allow to remount r/w. User needs to state an explicitly intention to work without an index by mounting with option 'index=off' to allow r/w mount with no index dir. When mounting with option 'index=on' and no 'upperdir', index is implicitly disabled, so do not warn about no file handle support. The issue was introduced with inodes index feature in v4.13, but this patch will not apply cleanly before ovl_fill_super() re-factoring in v4.15. Fixes: 02bcd1577400 ("ovl: introduce the inodes index dir feature") Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/super.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -703,7 +703,8 @@ static int ovl_lower_dir(const char *nam * The inodes index feature needs to encode and decode file * handles, so it requires that all layers support them. */ - if (ofs->config.index && !ovl_can_decode_fh(path->dentry->d_sb)) { + if (ofs->config.index && ofs->config.upperdir && + !ovl_can_decode_fh(path->dentry->d_sb)) { ofs->config.index = false; pr_warn("overlayfs: fs on '%s' does not support file handles, falling back to index=off.\n", name); } @@ -1257,11 +1258,16 @@ static int ovl_fill_super(struct super_b if (err) goto out_free_oe; - if (!ofs->indexdir) + /* Force r/o mount with no index dir */ + if (!ofs->indexdir) { + dput(ofs->workdir); + ofs->workdir = NULL; sb->s_flags |= SB_RDONLY; + } + } - /* Show index=off/on in /proc/mounts for any of the reasons above */ + /* Show index=off in /proc/mounts for forced r/o mount */ if (!ofs->indexdir) ofs->config.index = false;