Skip to content

Commit

Permalink
fs/sysv: Null check to prevent null-ptr-deref bug
Browse files Browse the repository at this point in the history
commit ea2b62f upstream.

sb_getblk(inode->i_sb, parent) return a null ptr and taking lock on
that leads to the null-ptr-deref bug.

Reported-by: syzbot+aad58150cbc64ba41bdc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=aad58150cbc64ba41bdc
Signed-off-by: Prince Kumar Maurya <princekumarmaurya06@gmail.com>
Message-Id: <20230531013141.19487-1-princekumarmaurya06@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Prince Kumar Maurya authored and gregkh committed Aug 11, 2023
1 parent e0a30f9 commit e28f376
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/sysv/itree.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ static int alloc_branch(struct inode *inode,
*/
parent = block_to_cpu(SYSV_SB(inode->i_sb), branch[n-1].key);
bh = sb_getblk(inode->i_sb, parent);
if (!bh) {
sysv_free_block(inode->i_sb, branch[n].key);
break;
}
lock_buffer(bh);
memset(bh->b_data, 0, blocksize);
branch[n].bh = bh;
Expand Down

0 comments on commit e28f376

Please sign in to comment.