All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged mm-nonmm-stable] fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage.patch removed from -mm tree
@ 2023-02-03  6:51 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2023-02-03  6:51 UTC (permalink / raw)
  To: mm-commits, willy, hch, jack, akpm


The quilt patch titled
     Subject: fs: gracefully handle ->get_block not mapping bh in __mpage_writepage
has been removed from the -mm tree.  Its filename was
     fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Jan Kara <jack@suse.cz>
Subject: fs: gracefully handle ->get_block not mapping bh in __mpage_writepage
Date: Thu, 26 Jan 2023 09:51:55 +0100

When filesystem's ->get_block function does not map the buffer head when
called from __mpage_writepage(), __mpage_writepage() will happily go and
pass bogus bdev and block number to bio allocation routines which leads to
crashes sooner or later.

E.g.  UDF can do this because it doesn't want to allocate blocks from
->writepages callbacks.  It allocates blocks on write or page fault but
writeback can still spot dirty buffers without underlying blocks allocated
e.g.  if blocksize < pagesize, the tail page is dirtied (which means all
its buffers are dirtied), and truncate extends the file so that some
buffer starts to be within i_size.

Link: https://lkml.kernel.org/r/20230126085155.26395-1-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---


--- a/fs/mpage.c~fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage
+++ a/fs/mpage.c
@@ -532,6 +532,8 @@ static int __mpage_writepage(struct page
 		map_bh.b_size = 1 << blkbits;
 		if (mpd->get_block(inode, block_in_file, &map_bh, 1))
 			goto confused;
+		if (!buffer_mapped(&map_bh))
+			goto confused;
 		if (buffer_new(&map_bh))
 			clean_bdev_bh_alias(&map_bh);
 		if (buffer_boundary(&map_bh)) {
_

Patches currently in -mm which might be from jack@suse.cz are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-03  6:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03  6:51 [merged mm-nonmm-stable] fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.