udf: Avoid using stale lengthOfImpUse
authorJan Kara <jack@suse.cz>
Tue, 10 May 2022 10:36:04 +0000 (12:36 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 15 May 2022 18:18:52 +0000 (20:18 +0200)
commit9e951f2d85c9430ea8ae0c8448e47e3c234f1580
tree6525b28a1648370a47d9d73b2b6c5f0165c4fa8a
parent3d9c1d39237eb0495616447a82a312ee957d60f8
udf: Avoid using stale lengthOfImpUse

commit c1ad35dd0548ce947d97aaf92f7f2f9a202951cf upstream.

udf_write_fi() uses lengthOfImpUse of the entry it is writing to.
However this field has not yet been initialized so it either contains
completely bogus value or value from last directory entry at that place.
In either case this is wrong and can lead to filesystem corruption or
kernel crashes.

Reported-by: butt3rflyh4ck <butterflyhuangxx@gmail.com>
CC: stable@vger.kernel.org
Fixes: 979a6e28dd96 ("udf: Get rid of 0-length arrays in struct fileIdentDesc")
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/udf/namei.c