linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Jeongjun Park <aha310510@gmail.com>
Cc: shaggy@kernel.org,
	syzbot+241c815bda521982cb49@syzkaller.appspotmail.com,
	brauner@kernel.org, jlayton@kernel.org, eadavis@qq.com,
	jfs-discussion@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] jfs: Fix array-index-out-of-bounds in diFree
Date: Wed, 24 Apr 2024 18:41:48 +0100	[thread overview]
Message-ID: <ZilEXC3qLiqMTs29@casper.infradead.org> (raw)
In-Reply-To: <20240424172240.148883-1-aha310510@gmail.com>

On Thu, Apr 25, 2024 at 02:22:40AM +0900, Jeongjun Park wrote:
> Due to overflow, a value that is too large is entered into the agno 
> value. Therefore, we need to add code to check the agno value.

This is clearly wrong.

#define BLKTOAG(b,sbi)  ((b) >> ((sbi)->bmap->db_agl2size))

I'd suggest that something has either corrupted the sbi->bmap
pointer or the sbi->bmap->db_agl2size value.

All your patch does is cover up the problem, not fix it.

> Reported-by: syzbot+241c815bda521982cb49@syzkaller.appspotmail.com
> Signed-off-by: Jeongjun Park <aha310510@gmail.com>
> ---
>  fs/jfs/jfs_imap.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
> index 2ec35889ad24..0aac083bc0db 100644
> --- a/fs/jfs/jfs_imap.c
> +++ b/fs/jfs/jfs_imap.c
> @@ -881,6 +881,11 @@ int diFree(struct inode *ip)
>  	 */
>  	agno = BLKTOAG(JFS_IP(ip)->agstart, JFS_SBI(ip->i_sb));
>  
> +	if(agno >= MAXAG || agno < 0){
> +		jfs_error(ip->i_sb, "invalid array index (0 <= agno < MAXAG), agno = %d\n", agno);
> +		return -ENOMEM;
> +	}
> +
>  	/* Lock the AG specific inode map information
>  	 */
>  	AG_LOCK(imap, agno);
> -- 
> 2.34.1
> 

  reply	other threads:[~2024-04-24 17:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 22:25 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in diFree syzbot
2024-04-24 17:22 ` [PATCH] jfs: Fix " Jeongjun Park
2024-04-24 17:41   ` Matthew Wilcox [this message]
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
2024-04-25 14:37             ` Jeongjun Park

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=ZilEXC3qLiqMTs29@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=aha310510@gmail.com \
    --cc=brauner@kernel.org \
    --cc=eadavis@qq.com \
    --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 \
    /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;
as well as URLs for NNTP newsgroup(s).