[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241113.120420.319092919822964048.konishi.ryusuke@gmail.com>
Date: Wed, 13 Nov 2024 12:04:20 +0900 (JST)
From: Ryusuke Konishi <konishi.ryusuke@...il.com>
To: syzbot+96d5d14c47d97015c624@...kaller.appspotmail.com
Cc: linux-kernel@...r.kernel.org, linux-nilfs@...r.kernel.org,
syzkaller-bugs@...glegroups.com
Subject: Re: [syzbot] [nilfs?] KASAN: use-after-free Read in
nilfs_find_entry
Test a variation of the nilfs_last_byte() fix in which the type of
the local variable last_byte was changed from "loff_t" to "u64".
Since both PAGE_SIZE and the argument page_nr are unsigned, in
arithmetic and comparison, both are calculated as unsigned by implicit
type conversion, and the behavior is the same.
However, changing the type of last_byte from unsigned to signed
results in a new comparision between an unsigned integer and a signed
integer, which may introduce a new warning from the grammer checker
when using "make W=2", etc., so use the unsigned type in the
declaration.
#syz test
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index a8602729586a..f61c58fbf117 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -70,7 +70,7 @@ static inline unsigned int nilfs_chunk_size(struct inode *inode)
*/
static unsigned int nilfs_last_byte(struct inode *inode, unsigned long page_nr)
{
- unsigned int last_byte = inode->i_size;
+ u64 last_byte = inode->i_size;
last_byte -= page_nr << PAGE_SHIFT;
if (last_byte > PAGE_SIZE)
Powered by blists - more mailing lists