mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Matthew Wilcox <willy@infradead.org>,
	Jeongjun Park <aha310510@gmail.com>
Cc: brauner@kernel.org, jfs-discussion@lists.sourceforge.net,
	jlayton@kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, shaggy@kernel.org,
	syzbot+241c815bda521982cb49@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] jfs: Fix array-index-out-of-bounds in diFree
Date: Thu, 25 Apr 2024 09:24:43 -0500	[thread overview]
Message-ID: <674f1ee0-4b7a-41c2-8bc5-82bb0f490565@oracle.com> (raw)
In-Reply-To: <Zipl4PQ9Q7sBlMCt@casper.infradead.org>

On 4/25/24 9:17AM, Matthew Wilcox wrote:
> On Thu, Apr 25, 2024 at 11:10:38PM +0900, Jeongjun Park wrote:
>> Matthew Wilcox wrote:
>>> If that's the problem then the correct place to detect & reject this is
>>> during mount, not at inode free time.
>>
>> I fixed the patch as you said. If you patch in this way, the
>> file system will not be affected by the vulnerability at all
>> due to the code structure.
> 
> It should be checked earlier than this.

Right. This is preferable.

>  There's this code in
> dbMount().  Why isn't this catching it?

db_agstart is not checked in this code. That may be the bad data in this 
case.

There are probably dozens more sanity checks that are missing when data 
is first read from the disk.

Shaggy

> 
>          bmp->db_agl2size = le32_to_cpu(dbmp_le->dn_agl2size);
>          if (bmp->db_agl2size > L2MAXL2SIZE - L2MAXAG ||
>              bmp->db_agl2size < 0) {
>                  err = -EINVAL;
>                  goto err_release_metapage;
>          }
> 
>          if (((bmp->db_mapsize - 1) >> bmp->db_agl2size) > MAXAG) {
>                  err = -EINVAL;
>                  goto err_release_metapage;
>          }
> 
> 
>> Thanks.
>>
>> ---
>>   fs/jfs/jfs_imap.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
>> index 2ec35889ad24..ba0aa2f145cc 100644
>> --- a/fs/jfs/jfs_imap.c
>> +++ b/fs/jfs/jfs_imap.c
>> @@ -290,7 +290,7 @@ int diSync(struct inode *ipimap)
>>   int diRead(struct inode *ip)
>>   {
>>   	struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
>> -	int iagno, ino, extno, rc;
>> +	int iagno, ino, extno, rc, agno;
>>   	struct inode *ipimap;
>>   	struct dinode *dp;
>>   	struct iag *iagp;
>> @@ -339,6 +339,9 @@ int diRead(struct inode *ip)
>>   
>>   	/* get the ag for the iag */
>>   	agstart = le64_to_cpu(iagp->agstart);
>> +	agno = BLKTOAG(agstart, JFS_SBI(ip->i_sb));
>> +	if(agno >= MAXAG || agno < 0)
>> +		return -EIO;
>>   
>>   	release_metapage(mp);
>>   
>> -- 
>> 2.34.1

  parent reply	other threads:[~2024-04-25 14:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 22:25 [syzbot] [jfs?] UBSAN: " syzbot
2024-04-24  4:11 ` Jeongjun Park
2024-04-24  4:39   ` syzbot
2024-04-24 17:22 ` [PATCH] jfs: Fix " Jeongjun Park
2024-04-24 17:41   ` Matthew Wilcox
2024-04-25 12:44     ` Jeongjun Park
2024-04-25 12:53       ` Matthew Wilcox
2024-04-25 14:10         ` Jeongjun Park
2024-04-25 14:14           ` Dave Kleikamp
2024-04-25 14:17           ` Matthew Wilcox
2024-04-25 14:24             ` Jeongjun Park
2024-04-25 17:04               ` Matthew Wilcox
2024-04-26  1:42                 ` Jeongjun Park
2024-04-26  2:34                 ` Jeongjun Park
2024-04-26  3:27                   ` Matthew Wilcox
2024-04-26  3:41                     ` Jeongjun Park
2024-05-30 13:28                       ` Jeongjun Park
2024-06-26 17:40                         ` Dave Kleikamp
2024-04-25 14:24             ` Dave Kleikamp [this message]
2024-04-25 14:37             ` Jeongjun Park
2024-04-25  3:15 ` [syzbot] [jfs?] UBSAN: " Jeongjun Park
2024-04-25  4:33   ` syzbot
2024-04-25  4:59 ` Jeongjun Park
2024-04-25  5:50   ` syzbot
2024-04-25  8:56 ` Jeongjun Park
2024-04-25  9:23   ` syzbot
2024-04-25  9:04 ` Jeongjun Park
2024-04-25  9:39   ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=674f1ee0-4b7a-41c2-8bc5-82bb0f490565@oracle.com \
    --to=dave.kleikamp@oracle.com \
    --cc=aha310510@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaggy@kernel.org \
    --cc=syzbot+241c815bda521982cb49@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®