linux/fs/exfat
Yuezhang Mo 3a7845041e exfat: fix appending discontinuous clusters to empty file
Eric Hong found that when using ftruncate to expand an empty file,
exfat_ent_set() will fail if discontinuous clusters are allocated.
The reason is that the empty file does not have a cluster chain,
but exfat_ent_set() attempts to append the newly allocated cluster
to the cluster chain. In addition, exfat_find_last_cluster() only
supports finding the last cluster in a non-empty file.

So this commit adds a check whether the file is empty. If the file
is empty, exfat_find_last_cluster() and exfat_ent_set() are no longer
called as they do not need to be called.

Fixes: f55c096f62 ("exfat: do not zero the extended part")
Reported-by: Eric Hong <erichong@qnap.com>
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
2024-02-18 14:41:18 +09:00
..
balloc.c exfat: using ffs instead of internal logic 2024-01-08 21:57:21 +09:00
cache.c exfat: fix use of uninitialized spinlock on error path 2020-10-07 14:27:13 +09:00
dir.c exfat: support create zero-size directory 2023-10-31 10:01:45 +09:00
exfat_fs.h exfat: change to get file size from DataLength 2024-01-08 21:57:22 +09:00
exfat_raw.h exfat: add ioctls for accessing attributes 2023-10-31 10:00:51 +09:00
fatent.c exfat: fix the newly allocated clusters are not freed in error handling 2023-02-28 20:01:40 +09:00
file.c exfat: fix appending discontinuous clusters to empty file 2024-02-18 14:41:18 +09:00
inode.c exfat: fix zero the unwritten part for dio read 2024-01-18 23:01:51 +09:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
Makefile exfat: add Kconfig and Makefile 2020-03-05 21:00:40 -05:00
misc.c exfat: convert to new timestamp accessors 2023-10-18 13:26:21 +02:00
namei.c exfat: change to get file size from DataLength 2024-01-08 21:57:22 +09:00
nls.c exfat: Drop superfluous new line for error messages 2022-08-01 10:14:07 +09:00
super.c exfat: support create zero-size directory 2023-10-31 10:01:45 +09:00