From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385643; b=LPpo5WB25BdDpV5LfzK5WI94tE+v2j1k9gGjaqb9TTxBfPvtOuq1NvcMCdlO2/cxUHno hBwP/5Se0TTKA3KUADNUud+HmxcR9vDhJmFOgt5BfjUs9J6iL60kwpCMWX0QF0zEZ0lsd rIPf2mTWTo8PH1t64XTkgrUxTfpiBu8yyvXtRvBb0lpYbrdrcVS5fTIE6nCKrP0Ry+UzT D+Pgvkg4N3L41ZkXQBRJstTWzHVJRvLlyhoBXpl6EYxSfP/rlhS477zf9SiMMjGrrR4LZ z7Um38LuuAAm2OhMGGFOYhMa5722nVo+0OH6wIiO14oTZwiXNUQkg7ujw5Ka7VdxNnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385643; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=gaZytH52M87cwqBzq6UT+zNXyTBU5MC+hNfGYDf99RA=; b=sVIpt3bsGtSPUE0B9xJ0qCWc9JtUOH97tNSQuuQhv2y2mDeTvtWrmNrPqz0VciX9X7wg YJU+a3JaICxwCs2VAASBEK5gzdi/ATc5n3qai5Cm3/ougzUAUxJJTESLbKPKimxRDFMQC iCfVV1dZJPfaQ8YFNZxB/hwktWPCKwQ0Ly9eFUzQDZ6+wBAUwuyryYQP0dJ3phEVu9cnm hAvABolbYmOb5n379n89pli3907CyBGo3UuAqRfIAf1lf2TQQ0EmCR5Ect04peGpd8pXV xaVMfEVLQxeTlQxI94inG7mqfgZtTeMbCVYFmLD/NJLVFVjx68HpbnZvCJTqZ1PUVqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fgOWCBfF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59241606A322; Fri, 4 Dec 2026 12:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fgOWCBfF Received: by smtp.kernel.org (Postfix) with ESMTPSA id C87AC1F000C2; Fri, 4 Dec 2026 12:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385643; bh=gaZytH52M87cwqBzq6UT+zNXyTBU5MC+hNfGYDf99RA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fgOWCBfFIzEUwoJZ9CNwg7iqJ15J4WOdQV1rYNPY/7D7QjGGoDPQkYZ6fjzHIDk1G RCivI19NHOy4OEfLeSePcEZyJMWsYdnmNATTOw4kI0YjAzClARGs+G8/UK6MhELgGy +Y80FXSbARH23e9hImlksLNnmaQAkFLEnP+Xfky4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Amir Goldstein Subject: [PATCH 6.6 0591/1167] ovl: report the requested redirect_dir mode in conflicting options Date: Fri, 4 Dec 2026 19:00:18 +0900 Message-ID: <20261204100717.448133356@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein commit 248503755b3cab89742edcc3cfd53adbcf7bfec2 upstream. Since the redirect_dir mode is stored as an enum, "off" is translated to "follow" or "nofollow" when parsing the option and redirect_dir=follow is translated to "on" for a non-upper mount, so the errors about options that conflict with an explicit redirect_dir= report a mode that the user did not request. Translate "off" when verifying the mount options instead of when parsing them and report the requested mode in those errors. Fixes: af5f2396b671 ("ovl: store enum redirect_mode in config instead of a string") Cc: stable@vger.kernel.org Signed-off-by: Amir Goldstein Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/overlayfs.h | 10 +++++++--- fs/overlayfs/params.c | 43 ++++++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 16 deletions(-) --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -62,9 +62,13 @@ enum ovl_entry_flag { }; enum { - OVL_REDIRECT_OFF, /* "off" mode is never used. In effect */ - OVL_REDIRECT_FOLLOW, /* ...it translates to either "follow" */ - OVL_REDIRECT_NOFOLLOW, /* ...or "nofollow". */ + /* + * "off" mode is never used after mount options are verified. In effect + * it translates to either "follow" or "nofollow". + */ + OVL_REDIRECT_OFF, + OVL_REDIRECT_FOLLOW, + OVL_REDIRECT_NOFOLLOW, OVL_REDIRECT_ON, }; --- a/fs/overlayfs/params.c +++ b/fs/overlayfs/params.c @@ -110,18 +110,28 @@ const struct constant_table ovl_paramete {} }; +static const char *ovl_redirect_mode_name(int redirect_mode) +{ + return ovl_parameter_redirect_dir[redirect_mode].name; +} + static const char *ovl_redirect_mode(struct ovl_config *config) { - return ovl_parameter_redirect_dir[config->redirect_mode].name; + return ovl_redirect_mode_name(config->redirect_mode); } -static int ovl_redirect_mode_def(void) +static int ovl_redirect_follow_mode(void) { - return ovl_redirect_dir_def ? OVL_REDIRECT_ON : - ovl_redirect_always_follow ? OVL_REDIRECT_FOLLOW : + return ovl_redirect_always_follow ? OVL_REDIRECT_FOLLOW : OVL_REDIRECT_NOFOLLOW; } +static int ovl_redirect_mode_def(void) +{ + return ovl_redirect_dir_def ? OVL_REDIRECT_ON : + ovl_redirect_follow_mode(); +} + static const struct constant_table ovl_parameter_verity[] = { { "off", OVL_VERITY_OFF }, { "on", OVL_VERITY_ON }, @@ -566,11 +576,6 @@ static int ovl_parse_param(struct fs_con break; case Opt_redirect_dir: config->redirect_mode = result.uint_32; - if (config->redirect_mode == OVL_REDIRECT_OFF) { - config->redirect_mode = ovl_redirect_always_follow ? - OVL_REDIRECT_FOLLOW : - OVL_REDIRECT_NOFOLLOW; - } ctx->set.redirect = true; break; case Opt_index: @@ -700,7 +705,13 @@ int ovl_init_fs_context(struct fs_contex if (!ofs) goto out_err; - ofs->config.redirect_mode = ovl_redirect_mode_def(); + /* + * The module default determines only if new redirects are created in + * upper dir. If they are not, the redirect follow mode will be + * determined after parsing mount options. + */ + ofs->config.redirect_mode = ovl_redirect_dir_def ? + OVL_REDIRECT_ON : OVL_REDIRECT_OFF; ofs->config.index = ovl_index_def; ofs->config.uuid = ovl_uuid_def(); ofs->config.nfs_export = ovl_nfs_export_def; @@ -757,6 +768,8 @@ int ovl_fs_params_verify(const struct ov struct ovl_config *config) { struct ovl_opt_set set = ctx->set; + /* The requested redirect_dir=, for reporting conflicts with it */ + int redirect_opt = config->redirect_mode; /* Workdir/index are useless in non-upper mount */ if (!config->upperdir) { @@ -795,6 +808,10 @@ int ovl_fs_params_verify(const struct ov config->metacopy = true; } + /* Resolve redirect_dir=off to the default redirect follow mode */ + if (config->redirect_mode == OVL_REDIRECT_OFF) + config->redirect_mode = ovl_redirect_follow_mode(); + /* * This is to make the logic below simpler. It doesn't make any other * difference, since redirect_dir=on is only used for upper. @@ -806,7 +823,7 @@ int ovl_fs_params_verify(const struct ov if (config->metacopy && config->redirect_mode != OVL_REDIRECT_ON) { if (set.metacopy && set.redirect) { pr_err("conflicting options: metacopy=on,redirect_dir=%s\n", - ovl_redirect_mode(config)); + ovl_redirect_mode_name(redirect_opt)); return -EINVAL; } if (config->verity_mode && set.redirect) { @@ -820,7 +837,7 @@ int ovl_fs_params_verify(const struct ov * in this conflict. */ pr_info("disabling metacopy due to redirect_dir=%s\n", - ovl_redirect_mode(config)); + ovl_redirect_mode_name(redirect_opt)); config->metacopy = false; } else { /* Automatically enable redirect otherwise. */ @@ -887,7 +904,7 @@ int ovl_fs_params_verify(const struct ov if (set.redirect && config->redirect_mode != OVL_REDIRECT_NOFOLLOW) { pr_err("conflicting options: userxattr,redirect_dir=%s\n", - ovl_redirect_mode(config)); + ovl_redirect_mode_name(redirect_opt)); return -EINVAL; } if (config->metacopy && set.metacopy) {