ext4: make sure ext4_append() always allocates new block
authorLukas Czerner <lczerner@redhat.com>
Mon, 4 Jul 2022 14:27:21 +0000 (16:27 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 3 Aug 2022 03:56:17 +0000 (23:56 -0400)
commitb8a04fe77ef1360fbf73c80fddbdfeaa9407ed1b
tree504a79dafe61d776611aa4ea5715b2d18337b40f
parent65f8ea4cd57dbd46ea13b41dc8bac03176b04233
ext4: make sure ext4_append() always allocates new block

ext4_append() must always allocate a new block, otherwise we run the
risk of overwriting existing directory block corrupting the directory
tree in the process resulting in all manner of problems later on.

Add a sanity check to see if the logical block is already allocated and
error out if it is.

Cc: stable@kernel.org
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20220704142721.157985-2-lczerner@redhat.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/namei.c