]> git.baikalelectronics.ru Git - kernel.git/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)
committerJan Kara <jack@suse.cz>
Tue, 19 Oct 2021 10:51:02 +0000 (12:51 +0200)
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>
fs/isofs/inode.c

index 678e2c51b855c05718bba33f1f223c9c2ad931cb..0c6eacfcbeef1a5728b7a18d833cc5f6210c46e8 100644 (file)
@@ -1322,6 +1322,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;