Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10795134imu; Thu, 6 Dec 2018 06:57:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/WeAwzy4rnwTqO3CL4OVKHxWNQu88NVyQPz9pPwDZsMOMP3U2XRycHV3vdHOCIwAUMpsTb9 X-Received: by 2002:a62:2292:: with SMTP id p18mr9021116pfj.9.1544108252364; Thu, 06 Dec 2018 06:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544108252; cv=none; d=google.com; s=arc-20160816; b=tLGMbJOxl9ctIVDKsdWbYlY2IVhziuPdMnugemcnxjUra9gu6p+2fEhWrsSRi5ixVJ 1KafzD2/eNhLy+46thTgt9krahSrXmgCkpch/84CCfTg+0c2FPtQpcWzkghcIDm7p9gL Z7VRK21hv3QQL/C6NL0yJztKvM30KIurdLSrFD8hG3xRugTUEjZvINQ0GTTdF9Gj974f pMUJSgkdRYUgZOzm2v7/afvKb5A8YaFoQy2eHHs0Gv3k5ALXZ1XPSqVPW0KL5q9m4Tqt leUwwEBoXgy1AaTcGmf4HC89W8UEjqoSF8+IR7FDbQq/fyoh1Vjouo09OvPjW/FOOIqr ryDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RbzOpgzW/jP/3WulMzY9WkPShL0kuAfxMFOjJ3c2Csg=; b=KSoMXH8XMSGEs5VMlKqRQkbGA7zNJ1Q+1503arQIYt8Daiz5YJ3LaA3pa943M2ydgk 4cMkSNPqWZy1pTbcIsN3rHP4VgLe9+PFuMLIav7LVVv+hYwjk2T21/qnTAk+8g4jz6r7 qXcfHg1aaouf7xlQkWNDnbfLzJ6pG19SEph504m3hO2WNq5h5yu+HMRxrz1Ku7pGlTs2 chqUx4d/45PtjYWUUvfse9P1UOnT9c5qebQdAfxL5VY8+BYxrVjbyp78pIznsDjJasNF W2D5b3iS9fcNFjCVDLTydAkpFPZpy/FcdY4HGHgrmmqAWzNQB+FEDOKxakmDekbllC23 nxTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VKbqIyNn; 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 f9si406672pgk.313.2018.12.06.06.57.17; Thu, 06 Dec 2018 06:57:32 -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; dkim=pass header.i=@kernel.org header.s=default header.b=VKbqIyNn; 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 S1726379AbeLFO4n (ORCPT + 99 others); Thu, 6 Dec 2018 09:56:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:47614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbeLFOnN (ORCPT ); Thu, 6 Dec 2018 09:43:13 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC1B220892; Thu, 6 Dec 2018 14:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107392; bh=/SkmE4jiFB+wb6RpolQ+aHRGctihERT2AYV9tXDKxUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VKbqIyNnNfLTVRwa9/NjglJfcumKRtixjnPUAXWwbujmsMh1et7DXXac0rLdPEojB 5gfE93TynvVx0Oq/JYQ6fNfD85BwjbB3fxNJ9RhWmcxLNIvrZPv8nMFO3TcFM9kfk3 NOruHdF3YIGOTuZGU4+dESmQtrI4V5hevYXoPdts= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Sudip Mukherjee Subject: [PATCH 4.14 44/55] udf: Allow mounting volumes with incorrect identification strings Date: Thu, 6 Dec 2018 15:39:18 +0100 Message-Id: <20181206143004.121072039@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143001.749982936@linuxfoundation.org> References: <20181206143001.749982936@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit b54e41f5efcb4316b2f30b30c2535cc194270373 upstream. Commit c26f6c615788 ("udf: Fix conversion of 'dstring' fields to UTF8") started to be more strict when checking whether converted strings are properly formatted. Sudip reports that there are DVDs where the volume identification string is actually too long - UDF reports: [ 632.309320] UDF-fs: incorrect dstring lengths (32/32) during mount and fails the mount. This is mostly harmless failure as we don't need volume identification (and even less volume set identification) for anything. So just truncate the volume identification string if it is too long and replace it with 'Invalid' if we just cannot convert it for other reasons. This keeps slightly incorrect media still mountable. CC: stable@vger.kernel.org Fixes: c26f6c615788 ("udf: Fix conversion of 'dstring' fields to UTF8") Reported-and-tested-by: Sudip Mukherjee Signed-off-by: Jan Kara Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- fs/udf/super.c | 16 ++++++++++------ fs/udf/unicode.c | 14 +++++++++++--- 2 files changed, 21 insertions(+), 9 deletions(-) --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -922,16 +922,20 @@ static int udf_load_pvoldesc(struct supe } ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32); - if (ret < 0) - goto out_bh; - - strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret); + if (ret < 0) { + strcpy(UDF_SB(sb)->s_volume_ident, "InvalidName"); + pr_warn("incorrect volume identification, setting to " + "'InvalidName'\n"); + } else { + strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret); + } udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); ret = udf_dstrCS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128); - if (ret < 0) + if (ret < 0) { + ret = 0; goto out_bh; - + } outstr[ret] = 0; udf_debug("volSetIdent[] = '%s'\n", outstr); --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c @@ -341,6 +341,11 @@ try_again: return u_len; } +/* + * Convert CS0 dstring to output charset. Warning: This function may truncate + * input string if it is too long as it is used for informational strings only + * and it is better to truncate the string than to refuse mounting a media. + */ int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len, const uint8_t *ocu_i, int i_len) { @@ -349,9 +354,12 @@ int udf_dstrCS0toUTF8(uint8_t *utf_o, in if (i_len > 0) { s_len = ocu_i[i_len - 1]; if (s_len >= i_len) { - pr_err("incorrect dstring lengths (%d/%d)\n", - s_len, i_len); - return -EINVAL; + pr_warn("incorrect dstring lengths (%d/%d)," + " truncating\n", s_len, i_len); + s_len = i_len - 1; + /* 2-byte encoding? Need to round properly... */ + if (ocu_i[0] == 16) + s_len -= (s_len - 1) & 2; } }