2018-09-04 15:46:30 -07:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2021-11-08 18:35:01 -08:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-23 16:23:09 -07:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-04 18:04:48 +01:00
|
|
|
|
2016-08-02 14:05:30 -07:00
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-30 14:42:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-27 02:41:11 +09:00
|
|
|
|
2012-07-30 14:42:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-01 11:28:18 -07:00
|
|
|
|
2012-07-30 14:42:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-27 02:41:11 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
2010-07-10 20:52:09 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-01 11:28:18 -07:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-23 16:23:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-25 17:45:44 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-10 20:52:09 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-23 16:23:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
2014-10-13 15:53:22 -07:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2024-08-27 02:41:11 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
2010-06-28 17:49:33 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-15 16:44:07 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-02 14:05:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2016-08-02 14:05:28 -07:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2011-03-09 11:05:08 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
nilfs2: fix inode number range checks
Patch series "nilfs2: fix potential issues related to reserved inodes".
This series fixes one use-after-free issue reported by syzbot, caused by
nilfs2's internal inode being exposed in the namespace on a corrupted
filesystem, and a couple of flaws that cause problems if the starting
number of non-reserved inodes written in the on-disk super block is
intentionally (or corruptly) changed from its default value.
This patch (of 3):
In the current implementation of nilfs2, "nilfs->ns_first_ino", which
gives the first non-reserved inode number, is read from the superblock,
but its lower limit is not checked.
As a result, if a number that overlaps with the inode number range of
reserved inodes such as the root directory or metadata files is set in the
super block parameter, the inode number test macros (NILFS_MDT_INODE and
NILFS_VALID_INODE) will not function properly.
In addition, these test macros use left bit-shift calculations using with
the inode number as the shift count via the BIT macro, but the result of a
shift calculation that exceeds the bit width of an integer is undefined in
the C specification, so if "ns_first_ino" is set to a large value other
than the default value NILFS_USER_INO (=11), the macros may potentially
malfunction depending on the environment.
Fix these issues by checking the lower bound of "nilfs->ns_first_ino" and
by preventing bit shifts equal to or greater than the NILFS_USER_INO
constant in the inode number test macros.
Also, change the type of "ns_first_ino" from signed integer to unsigned
integer to avoid the need for type casting in comparisons such as the
lower bound check introduced this time.
Link: https://lkml.kernel.org/r/20240623051135.4180-1-konishi.ryusuke@gmail.com
Link: https://lkml.kernel.org/r/20240623051135.4180-2-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-06-23 14:11:33 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
nilfs2: fix inode number range checks
Patch series "nilfs2: fix potential issues related to reserved inodes".
This series fixes one use-after-free issue reported by syzbot, caused by
nilfs2's internal inode being exposed in the namespace on a corrupted
filesystem, and a couple of flaws that cause problems if the starting
number of non-reserved inodes written in the on-disk super block is
intentionally (or corruptly) changed from its default value.
This patch (of 3):
In the current implementation of nilfs2, "nilfs->ns_first_ino", which
gives the first non-reserved inode number, is read from the superblock,
but its lower limit is not checked.
As a result, if a number that overlaps with the inode number range of
reserved inodes such as the root directory or metadata files is set in the
super block parameter, the inode number test macros (NILFS_MDT_INODE and
NILFS_VALID_INODE) will not function properly.
In addition, these test macros use left bit-shift calculations using with
the inode number as the shift count via the BIT macro, but the result of a
shift calculation that exceeds the bit width of an integer is undefined in
the C specification, so if "ns_first_ino" is set to a large value other
than the default value NILFS_USER_INO (=11), the macros may potentially
malfunction depending on the environment.
Fix these issues by checking the lower bound of "nilfs->ns_first_ino" and
by preventing bit shifts equal to or greater than the NILFS_USER_INO
constant in the inode number test macros.
Also, change the type of "ns_first_ino" from signed integer to unsigned
integer to avoid the need for type casting in comparisons such as the
lower bound check introduced this time.
Link: https://lkml.kernel.org/r/20240623051135.4180-1-konishi.ryusuke@gmail.com
Link: https://lkml.kernel.org/r/20240623051135.4180-2-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-06-23 14:11:33 +09:00
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2024-06-23 14:11:34 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-23 16:23:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
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|
2023-11-27 23:30:31 +09:00
|
|
|
|
2024-10-04 12:35:31 +09:00
|
|
|
|
2023-11-27 23:30:31 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nilfs2: handle errors that nilfs_prepare_chunk() may return
Patch series "nilfs2: fix issues with rename operations".
This series fixes BUG_ON check failures reported by syzbot around rename
operations, and a minor behavioral issue where the mtime of a child
directory changes when it is renamed instead of moved.
This patch (of 2):
The directory manipulation routines nilfs_set_link() and
nilfs_delete_entry() rewrite the directory entry in the folio/page
previously read by nilfs_find_entry(), so error handling is omitted on the
assumption that nilfs_prepare_chunk(), which prepares the buffer for
rewriting, will always succeed for these. And if an error is returned, it
triggers the legacy BUG_ON() checks in each routine.
This assumption is wrong, as proven by syzbot: the buffer layer called by
nilfs_prepare_chunk() may call nilfs_get_block() if necessary, which may
fail due to metadata corruption or other reasons. This has been there all
along, but improved sanity checks and error handling may have made it more
reproducible in fuzzing tests.
Fix this issue by adding missing error paths in nilfs_set_link(),
nilfs_delete_entry(), and their caller nilfs_rename().
Link: https://lkml.kernel.org/r/20250111143518.7901-1-konishi.ryusuke@gmail.com
Link: https://lkml.kernel.org/r/20250111143518.7901-2-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+32c3706ebf5d95046ea1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=32c3706ebf5d95046ea1
Reported-by: syzbot+1097e95f134f37d9395c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1097e95f134f37d9395c
Fixes: 2ba466d74ed7 ("nilfs2: directory entry operations")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-01-11 23:26:35 +09:00
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
2011-07-16 20:44:56 -04:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
2025-07-03 09:36:41 +02:00
|
|
|
|
2023-01-13 12:49:21 +01:00
|
|
|
|
2025-07-03 09:36:41 +02:00
|
|
|
|
2009-04-06 19:01:53 -07:00
|
|
|
|
2011-02-03 21:26:17 +09:00
|
|
|
|
2009-05-10 22:41:43 +09:00
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
2011-03-05 00:19:32 +09:00
|
|
|
|
|
|
|
|
|
2011-07-26 03:07:14 -04:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-22 23:01:55 +09:00
|
|
|
|
|
|
|
|
|
2010-09-13 11:16:34 +09:00
|
|
|
|
|
|
|
|
|
2010-09-05 12:20:59 +09:00
|
|
|
|
|
|
|
|
|
2010-08-25 17:45:44 +09:00
|
|
|
|
|
|
|
|
|
2010-08-20 19:06:11 +09:00
|
|
|
|
|
|
|
|
|
2022-04-01 11:28:18 -07:00
|
|
|
|
|
|
|
|
|
2022-04-01 11:28:21 -07:00
|
|
|
|
2014-10-13 15:53:22 -07:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2010-06-07 11:55:00 -04:00
|
|
|
|
2023-01-13 12:49:11 +01:00
|
|
|
|
2021-01-21 14:19:43 +01:00
|
|
|
|
2012-12-15 11:57:37 +01:00
|
|
|
|
2023-01-13 12:49:22 +01:00
|
|
|
|
2021-01-21 14:19:43 +01:00
|
|
|
|
2010-12-27 00:05:49 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2016-05-23 16:23:39 -07:00
|
|
|
|
2014-10-13 15:53:22 -07:00
|
|
|
|
2011-05-27 06:53:02 -04:00
|
|
|
|
2010-12-26 16:38:43 +09:00
|
|
|
|
|
|
|
|
|
2014-10-13 15:53:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-02 14:05:00 -07:00
|
|
|
|
2020-08-11 18:35:46 -07:00
|
|
|
|
|
|
|
|
|
2011-10-31 17:11:33 -07:00
|
|
|
|
2016-08-02 14:05:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-02 14:05:02 -07:00
|
|
|
|
2020-08-11 18:35:46 -07:00
|
|
|
|
2016-08-02 14:05:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-02 14:05:02 -07:00
|
|
|
|
2016-08-02 14:05:14 -07:00
|
|
|
|
2020-08-11 18:35:46 -07:00
|
|
|
|
2016-08-02 14:05:14 -07:00
|
|
|
|
|
|
|
|
|
2016-08-02 14:05:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-11 18:35:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2009-04-06 19:01:59 -07:00
|
|
|
|
2024-04-25 03:27:16 +09:00
|
|
|
|
|
|
|
|
|
2010-07-22 03:22:20 +09:00
|
|
|
|
|
|
|
|
|
2010-06-28 17:49:31 +09:00
|
|
|
|
|
|
|
|
|
2011-03-09 11:05:08 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-05-05 01:23:58 +09:00
|
|
|
|
2011-03-09 11:05:08 +09:00
|
|
|
|
2010-08-25 17:45:44 +09:00
|
|
|
|
2010-09-13 11:16:34 +09:00
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-20 19:06:11 +09:00
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
2014-08-08 14:20:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-01 15:43:56 -07:00
|
|
|
|
2009-09-21 17:01:11 -07:00
|
|
|
|
2009-10-01 15:43:56 -07:00
|
|
|
|
2009-09-21 17:01:10 -07:00
|
|
|
|
nilfs2: fix buffer head leaks in calls to truncate_inode_pages()
When block_invalidatepage was converted to block_invalidate_folio, the
fallback to block_invalidatepage in folio_invalidate() if the
address_space_operations method invalidatepage (currently
invalidate_folio) was not set, was removed.
Unfortunately, some pseudo-inodes in nilfs2 use empty_aops set by
inode_init_always_gfp() as is, or explicitly set it to
address_space_operations. Therefore, with this change,
block_invalidatepage() is no longer called from folio_invalidate(), and as
a result, the buffer_head structures attached to these pages/folios are no
longer freed via try_to_free_buffers().
Thus, these buffer heads are now leaked by truncate_inode_pages(), which
cleans up the page cache from inode evict(), etc.
Three types of caches use empty_aops: gc inode caches and the DAT shadow
inode used by GC, and b-tree node caches. Of these, b-tree node caches
explicitly call invalidate_mapping_pages() during cleanup, which involves
calling try_to_free_buffers(), so the leak was not visible during normal
operation but worsened when GC was performed.
Fix this issue by using address_space_operations with invalidate_folio set
to block_invalidate_folio instead of empty_aops, which will ensure the
same behavior as before.
Link: https://lkml.kernel.org/r/20241212164556.21338-1-konishi.ryusuke@gmail.com
Fixes: 7ba13abbd31e ("fs: Turn block_invalidatepage into block_invalidate_folio")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org> [5.18+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-12-13 01:43:28 +09:00
|
|
|
|
2009-09-21 17:01:11 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 19:01:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|