+ fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage.patch added to mm-nonmm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: fs: gracefully handle ->get_block not mapping bh in __mpage_writepage
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Jan Kara <jack@xxxxxxx>
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@xxxxxxx
Signed-off-by: Jan Kara <jack@xxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 fs/mpage.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fs/mpage.c~fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage
+++ a/fs/mpage.c
@@ -533,6 +533,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@xxxxxxx are

fs-gracefully-handle-get_block-not-mapping-bh-in-__mpage_writepage.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux