Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2563842lkm; Mon, 20 Sep 2021 18:49:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgosrw+b8ftEPpQa83AsWh8RByT/dTYrEN1vUWs5bfWjLPZ0lQBK0nD166p3md2pK8iRDz X-Received: by 2002:a5e:d80a:: with SMTP id l10mr20505315iok.36.1632188892065; Mon, 20 Sep 2021 18:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188892; cv=none; d=google.com; s=arc-20160816; b=IqttEsAS4f+Wot+vjEqjP30QgYCpXpXwAYmZJNTWSAad1vviR4gV8EreM347JSHh1f 4zW7r2HS8+J8ir0fGNJlhlov6YApmDJsF700CD9ZBTqkVmU9rz4gHzieFQ3ANNvku4xc +RdFnK99PElUAS8i4/HyAkA20arbjNG5N20m8ES1K6gtaHeG452AjiGtzYTPwjlOmvIq gDnNjeoCpPOvPTPtTrVz9dgEj4Bk2uNQ0qdhd82mJ/C6r8Weqr6wvmr8GC9dbrzDwvzK uz8RjZUM3KxoU0BTjf+CXZk+x1ywe11P0uRCOzWIZsWSRMqGQU7I2NSiZJb7mvS1M9+8 /qjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5xzbnrhlunF4CgAt8PR6WPIUNGnakFzdABNA4NWfvDY=; b=jwI8ZCLE6TtDqmopKJSQSqho+5dpMTZI3kCW4WgWcSl/wYNZVYH64G4GXBV6U4ZRnR wzIvZ8bLf/4P84jG+6/jNYSSJS1+j+TrXRZFIdqhz6+2glZ+pHXijo9yKJIqR8tiI4vg 2RihFNsY+U1IsRZqFBfLuZeHmyq4346rB3aF2bmg6HYEYII/k4BcL1IPyFlizuAnsDBZ j3n6QeMakjbO11Si9SFfyK3Jh85StfC6Dxa1j/K6xYa6sim6JDvU8tw0LzOPk0Ti9MUd 4iOA6Qs+Hso/R4gsNaKrXgMiahBjBfewjcm4x1keLCtTtsatJQfjX8I0DRKmFsjteXwq skkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M2kecIlH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e43si4330504jaf.97.2021.09.20.18.47.59; Mon, 20 Sep 2021 18:48:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M2kecIlH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348666AbhITRkI (ORCPT + 99 others); Mon, 20 Sep 2021 13:40:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:42382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242547AbhITRhb (ORCPT ); Mon, 20 Sep 2021 13:37:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84FCC61B30; Mon, 20 Sep 2021 17:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157618; bh=QeAN0Royt6Nj2hOWr3xe61aG/pFXYz+1x53hNKSbeME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2kecIlH+EmduIMrVDGA1uYgatc4K/8d7to6yC0We1dYuhEeIOggCsf/1wmpJ7OSu 4auDfdZvTeIxQJs+FKS9Iky0dyWBu2d9dg6/88bU1sGAxmg3EnBu1TFY0j1Hia2x/B x0O/zCiirM4mpvxXFzzI4z6FVNzfpJBp/wIW59TQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Jan Kara , Sasha Levin Subject: [PATCH 4.19 041/293] isofs: joliet: Fix iocharset=utf8 mount option Date: Mon, 20 Sep 2021 18:40:03 +0200 Message-Id: <20210920163934.676610536@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Rohár [ Upstream commit 28ce50f8d96ec9035f60c9348294ea26b94db944 ] Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset, it is required to use utf8 mount option. Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount option. If UTF-8 as iocharset is used then s_nls_iocharset is set to NULL. So simplify code around, remove s_utf8 field as to distinguish between UTF-8 and non-UTF-8 it is needed just to check if s_nls_iocharset is set to NULL or not. Link: https://lore.kernel.org/r/20210808162453.1653-5-pali@kernel.org Signed-off-by: Pali Rohár Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/isofs/inode.c | 27 +++++++++++++-------------- fs/isofs/isofs.h | 1 - fs/isofs/joliet.c | 4 +--- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 488a9e7f8f66..2355ad62b81f 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -157,7 +157,6 @@ struct iso9660_options{ unsigned int overriderockperm:1; unsigned int uid_set:1; unsigned int gid_set:1; - unsigned int utf8:1; unsigned char map; unsigned char check; unsigned int blocksize; @@ -357,7 +356,6 @@ static int parse_options(char *options, struct iso9660_options *popt) popt->gid = GLOBAL_ROOT_GID; popt->uid = GLOBAL_ROOT_UID; popt->iocharset = NULL; - popt->utf8 = 0; popt->overriderockperm = 0; popt->session=-1; popt->sbsector=-1; @@ -390,10 +388,13 @@ static int parse_options(char *options, struct iso9660_options *popt) case Opt_cruft: popt->cruft = 1; break; +#ifdef CONFIG_JOLIET case Opt_utf8: - popt->utf8 = 1; + kfree(popt->iocharset); + popt->iocharset = kstrdup("utf8", GFP_KERNEL); + if (!popt->iocharset) + return 0; break; -#ifdef CONFIG_JOLIET case Opt_iocharset: kfree(popt->iocharset); popt->iocharset = match_strdup(&args[0]); @@ -496,7 +497,6 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root) if (sbi->s_nocompress) seq_puts(m, ",nocompress"); if (sbi->s_overriderockperm) seq_puts(m, ",overriderockperm"); if (sbi->s_showassoc) seq_puts(m, ",showassoc"); - if (sbi->s_utf8) seq_puts(m, ",utf8"); if (sbi->s_check) seq_printf(m, ",check=%c", sbi->s_check); if (sbi->s_mapping) seq_printf(m, ",map=%c", sbi->s_mapping); @@ -519,9 +519,10 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root) seq_printf(m, ",fmode=%o", sbi->s_fmode); #ifdef CONFIG_JOLIET - if (sbi->s_nls_iocharset && - strcmp(sbi->s_nls_iocharset->charset, CONFIG_NLS_DEFAULT) != 0) + if (sbi->s_nls_iocharset) seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset); + else + seq_puts(m, ",iocharset=utf8"); #endif return 0; } @@ -865,14 +866,13 @@ root_found: sbi->s_nls_iocharset = NULL; #ifdef CONFIG_JOLIET - if (joliet_level && opt.utf8 == 0) { + if (joliet_level) { char *p = opt.iocharset ? opt.iocharset : CONFIG_NLS_DEFAULT; - sbi->s_nls_iocharset = load_nls(p); - if (! sbi->s_nls_iocharset) { - /* Fail only if explicit charset specified */ - if (opt.iocharset) + if (strcmp(p, "utf8") != 0) { + sbi->s_nls_iocharset = opt.iocharset ? + load_nls(opt.iocharset) : load_nls_default(); + if (!sbi->s_nls_iocharset) goto out_freesbi; - sbi->s_nls_iocharset = load_nls_default(); } } #endif @@ -888,7 +888,6 @@ root_found: sbi->s_gid = opt.gid; sbi->s_uid_set = opt.uid_set; sbi->s_gid_set = opt.gid_set; - sbi->s_utf8 = opt.utf8; sbi->s_nocompress = opt.nocompress; sbi->s_overriderockperm = opt.overriderockperm; /* diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index 055ec6c586f7..dcdc191ed183 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h @@ -44,7 +44,6 @@ struct isofs_sb_info { unsigned char s_session; unsigned int s_high_sierra:1; unsigned int s_rock:2; - unsigned int s_utf8:1; unsigned int s_cruft:1; /* Broken disks with high byte of length * containing junk */ unsigned int s_nocompress:1; diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c index be8b6a9d0b92..c0f04a1e7f69 100644 --- a/fs/isofs/joliet.c +++ b/fs/isofs/joliet.c @@ -41,14 +41,12 @@ uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls) int get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, struct inode * inode) { - unsigned char utf8; struct nls_table *nls; unsigned char len = 0; - utf8 = ISOFS_SB(inode->i_sb)->s_utf8; nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset; - if (utf8) { + if (!nls) { len = utf16s_to_utf8s((const wchar_t *) de->name, de->name_len[0] >> 1, UTF16_BIG_ENDIAN, outname, PAGE_SIZE); -- 2.30.2