linux-stable/fs/udf
Jan Kara 31136e5467 udf: Fix NULL ptr deref when converting from inline format
commit 7fc3b7c298 upstream.

udf_expand_file_adinicb() calls directly ->writepage to write data
expanded into a page. This however misses to setup inode for writeback
properly and so we can crash on inode->i_wb dereference when submitting
page for IO like:

  BUG: kernel NULL pointer dereference, address: 0000000000000158
  #PF: supervisor read access in kernel mode
...
  <TASK>
  __folio_start_writeback+0x2ac/0x350
  __block_write_full_page+0x37d/0x490
  udf_expand_file_adinicb+0x255/0x400 [udf]
  udf_file_write_iter+0xbe/0x1b0 [udf]
  new_sync_write+0x125/0x1c0
  vfs_write+0x28e/0x400

Fix the problem by marking the page dirty and going through the standard
writeback path to write the page. Strictly speaking we would not even
have to write the page but we want to catch e.g. ENOSPC errors early.

Reported-by: butt3rflyh4ck <butterflyhuangxx@gmail.com>
CC: stable@vger.kernel.org
Fixes: 52ebea749a ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-01 17:24:34 +01:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
balloc.c udf: prevent allocation beyond UDF partition 2019-07-31 18:41:37 +02:00
dir.c udf: Fix crash after seekdir 2021-11-26 10:47:21 +01:00
directory.c
ecma_167.h udf: Verify domain identifier fields 2019-09-04 18:19:25 +02:00
file.c udf: augment UDF permissions on new inodes 2019-08-27 15:38:46 +02:00
ialloc.c udf: augment UDF permissions on new inodes 2019-08-27 15:38:46 +02:00
inode.c udf: Fix NULL ptr deref when converting from inline format 2022-02-01 17:24:34 +01:00
lowlevel.c
misc.c udf_get_extendedattr() had no boundary checks. 2021-09-15 09:47:28 +02:00
namei.c udf: Fix crash after seekdir 2021-11-26 10:47:21 +01:00
osta_udf.h
partition.c
super.c udf: Fix crash after seekdir 2021-11-26 10:47:21 +01:00
symlink.c
truncate.c udf: Propagate errors from udf_truncate_extents() 2019-03-18 16:30:02 +01:00
udf_i.h udf: augment UDF permissions on new inodes 2019-08-27 15:38:46 +02:00
udf_sb.h udf: Fix iocharset=utf8 mount option 2021-09-15 09:47:27 +02:00
udfdecl.h udf: augment UDF permissions on new inodes 2019-08-27 15:38:46 +02:00
udfend.h
udftime.c udf: convert inode stamps to timespec64 2018-06-27 13:58:00 +02:00
unicode.c udf: Fix iocharset=utf8 mount option 2021-09-15 09:47:27 +02:00