Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2676393ybl; Mon, 20 Jan 2020 07:21:20 -0800 (PST) X-Google-Smtp-Source: APXvYqyjncjWy6TAt90eqB4B/r5oJMxdtPj/dpD0DXVL+x1+oUlEXH/H8QN+vmCsC7cPc5txChiP X-Received: by 2002:a9d:6d10:: with SMTP id o16mr16832245otp.28.1579533680363; Mon, 20 Jan 2020 07:21:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579533680; cv=none; d=google.com; s=arc-20160816; b=ECjNwvAF777E3P4v1Ba7kQowxfubWejPxeRttEwpNz+tpys4pZAUeIzhOcllILey9Q iKUaUASWkTp0Z10vgw0e9sHLXm9tn11vp24g9dJpILfpQFjA4HnMrWWoT71ArTH0rU9x p9QGVK1gco169XclnciAmYNnQlbAM152kODas8RxnAZySGCq+T/KnTnMdnaT6IYmXEsF +/++77uuLkslE193YyP9xdsmBE9a0ojZjBNyvypnXPqLV31sGMAMqpr1f/o+Couk50DY B5TI4JQ2NRp6lCBhj5wqDRvQFeJplBBmkQDQ0Q9rLIzTh7yBGgYj8qikYKaHEUIyKkMY PqMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RzNA/B1zWOp+s3c1S4KTFzaLREFyMoeK9blIPOWv0tg=; b=UAJW/7MTYeZWHRWG+VzX0Hu06NTCfJgaCkXgUafGFj1lOsLTJgQZJiQrRMC1iOtrt8 /A8TQpD7QnjrlXjRoVfkh1NrImiihcbwneYa6ZGT1zJNr8dybhDzttU3iDAvtRW8dHYT mAKHBvWDh0UUZse3LUqloULh5QHXwJFYfBugIadmA6Dx7+F+Qz6qXXlxMX+Uajt5gtWw 6sytOPJ+ndaDz3h4hw3MKw19ZDWMKTx4CeNm5hpF7d+0dIxCl0gOL85sqBqeXbF9WDVn uTUpugedGytt0p3xEi6DigXHilUy2GZdz7YSfR0WDWEbSp7jEVUHdJTdLJdHRgHPlR7l flGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qz2BL8Dd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d140si18640250oig.269.2020.01.20.07.21.07; Mon, 20 Jan 2020 07:21:20 -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=@gmail.com header.s=20161025 header.b=qz2BL8Dd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728843AbgATPUN (ORCPT + 99 others); Mon, 20 Jan 2020 10:20:13 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39968 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgATPUN (ORCPT ); Mon, 20 Jan 2020 10:20:13 -0500 Received: by mail-wm1-f68.google.com with SMTP id t14so15081457wmi.5; Mon, 20 Jan 2020 07:20:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=RzNA/B1zWOp+s3c1S4KTFzaLREFyMoeK9blIPOWv0tg=; b=qz2BL8DdvCQ0lG9BBDK/zr1PYABbh7SfEbmME2/1/QZ1ZMh9WlmjZ4N+kA7rFvKSQh l6aObfsqeoS/IlgFFfkuQIa4wRYBB+PmcfUyo9GVawd4ItTj+uw5t9rYcpvUx10KAE5D kI56+DFVH3sD28X+1FGa2YuSSvF6Rb5bWauAhaAJbAOqk/j7RCxWza4qxSDTKi1KH55Y pIyjEvGRtZ5TEZK+SMK/lW2nkzuGrdPGjT/byPkhRa9z9e5uCQR2dfEWstcDDOT2TzA6 4drnG18gmIF4pYBqcLw68n81ibecINJ6ZxWR5kKVxkj4dIC/LyLqsq+KRcIW0uKgohyS +VeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=RzNA/B1zWOp+s3c1S4KTFzaLREFyMoeK9blIPOWv0tg=; b=XSfzJv9ZF8ZIjH1YweZosLuJnkIqKRE7q0wKJs+nz6EhySeGauHAIfi6nQF70VyvuW tb5dsGDWVeHZ+gO5fDJaBNWaUJqeZ6INqs1gpgYlWZwMmoOriDC9wPR3ua+6sG/IIMnX xB73FohCpBTzu9irIw4BfaTuWMJUbWyPu2L4VN7YwVKHAiNpL6Pn7HlHV52r/pXjKE+7 Lz9FE7dr0tyY82/IzXCYYK3VynffVJCB4tf0aMUx4uP64fe5TM40w55u7F4/mBMjF9Kt dplJ7xWQXq53Z7CigUGt/iy4oix9sgefa+ijpPk4kqeMuIpaRJr2nAYy29w8nhFN0rjp 8tvA== X-Gm-Message-State: APjAAAVSyPmFT/WOiAlSgi6ElH0FctRcGwWJoERSo1BtAQAye5S5buMW 6CyvTzHFOwKT9/eQwhVnsJs= X-Received: by 2002:a7b:c389:: with SMTP id s9mr18584278wmj.7.1579533611655; Mon, 20 Jan 2020 07:20:11 -0800 (PST) Received: from pali ([2a02:2b88:2:1::5cc6:2f]) by smtp.gmail.com with ESMTPSA id a1sm23528152wmj.40.2020.01.20.07.20.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 07:20:10 -0800 (PST) Date: Mon, 20 Jan 2020 16:20:09 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: David Laight Cc: OGAWA Hirofumi , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "Theodore Y. Ts'o" , Namjae Jeon , Gabriel Krisman Bertazi Subject: Re: vfat: Broken case-insensitive support for UTF-8 Message-ID: <20200120152009.5vbemgmvhke4qupq@pali> References: <20200119221455.bac7dc55g56q2l4r@pali> <87sgkan57p.fsf@mail.parknet.co.jp> <20200120110438.ak7jpyy66clx5v6x@pali> <89eba9906011446f8441090f496278d2@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <89eba9906011446f8441090f496278d2@AcuMS.aculab.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 20 January 2020 15:07:20 David Laight wrote: > From: Pali Rohár > > Sent: 20 January 2020 11:05 > > On Monday 20 January 2020 13:04:42 OGAWA Hirofumi wrote: > > > Pali Rohár writes: > > > > > > > Which means that fat_name_match(), vfat_hashi() and vfat_cmpi() are > > > > broken for vfat in UTF-8 mode. > > > > > > Right. It is a known issue. > > > > Could be this issue better documented? E.g. in mount(8) manpage where > > are written mount options for vfat? I think that people should be aware > > of this issue when they use "utf8=1" mount option. > > What happens if the filesystem has filenames that invalid UTF8 sequences Could you please describe what you mean by this question? VFAT filesystem stores file names in UTF-16. Therefore you cannot have UTF-8 on FS (and therefore also you cannot have invalid UTF-8). Ehm... UTF-16 is not fully truth, MS FAT32 implementations allows half of UTF-16 surrogate pair stored in FS. Therefore practically, on VFAT you can store any uint16_t[] sequence as filename, there is no invalid sequence (except those characters like :<>?... which are invalid in MS-DOS). If by "the filesystem has filenames" you do not mean filesystem file names, but rather Linux VFS file names (e.g. you call creat() call with invalid UTF-8 sequence) then function utf8s_to_utf16s() (called in namei_vfat.c) fails and returns error. Which should be propagated to open() / creat() call that it is not possible to create filename with such UTF-8 sequence. > or multiple filenames that decode from UTF8 to the same 'wchar' value. This is not possible. There is 1:1 mapping between UTF-8 sequence and Unicode code point. wchar_t in kernel represent either one Unicode code point (limited up to U+FFFF in NLS framework functions) or 2bytes in UTF-16 sequence (only in utf8s_to_utf16s() and utf16s_to_utf8s() functions). > Never mind ones that are just case-differences for the same filename. > > UTF8 is just so broken it should never have been allowed to become > a standard. Well, UTF-16 is worse then UTF-8... incompatible with ASCII, variable length and space consuming. -- Pali Rohár pali.rohar@gmail.com