]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nilfs2: fix data corruption in dsync block recovery for small block sizes
authorRyusuke Konishi <konishi.ryusuke@gmail.com>
Wed, 24 Jan 2024 12:19:36 +0000 (21:19 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Feb 2024 07:42:28 +0000 (08:42 +0100)
commit364a66be2abdcd4fd426ffa44d9b8f40aafb3caa
treeeecb78d1a7ef4191f827b5f5ce2809b6e7589588
parenta643d8d179479886786e11cac799fd11996da98a
nilfs2: fix data corruption in dsync block recovery for small block sizes

commit 67b8bcbaed4777871bb0dcc888fb02a614a98ab1 upstream.

The helper function nilfs_recovery_copy_block() of
nilfs_recovery_dsync_blocks(), which recovers data from logs created by
data sync writes during a mount after an unclean shutdown, incorrectly
calculates the on-page offset when copying repair data to the file's page
cache.  In environments where the block size is smaller than the page
size, this flaw can cause data corruption and leak uninitialized memory
bytes during the recovery process.

Fix these issues by correcting this byte offset calculation on the page.

Link: https://lkml.kernel.org/r/20240124121936.10575-1-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nilfs2/recovery.c