]> git.hungrycats.org Git - linux/commitdiff
isofs: Fix out of bound access for corrupted isofs image
authorJan Kara <jack@suse.cz>
Mon, 18 Oct 2021 10:37:41 +0000 (12:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Nov 2021 13:40:50 +0000 (14:40 +0100)
commit e96a1866b40570b5950cda8602c2819189c62a48 upstream.

When isofs image is suitably corrupted isofs_read_inode() can read data
beyond the end of buffer. Sanity-check the directory entry length before
using it.

Reported-and-tested-by: syzbot+6fc7fb214625d82af7d1@syzkaller.appspotmail.com
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/isofs/inode.c

index 2355ad62b81faa0a7511a6cca182dc2b8dda4386..6e4e2cfd40b9e2a61c7a002815d6842dce376328 100644 (file)
@@ -1326,6 +1326,8 @@ static int isofs_read_inode(struct inode *inode, int relocated)
 
        de = (struct iso_directory_record *) (bh->b_data + offset);
        de_len = *(unsigned char *) de;
+       if (de_len < sizeof(struct iso_directory_record))
+               goto fail;
 
        if (offset + de_len > bufsize) {
                int frag1 = bufsize - offset;