]> git.proxmox.com Git - grub2.git/commit
malloc: Use overflow checking primitives where we do complex allocations
authorPeter Jones <pjones@redhat.com>
Mon, 15 Jun 2020 16:28:27 +0000 (12:28 -0400)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 29 Jul 2020 14:55:47 +0000 (16:55 +0200)
commit3f05d693d1274965ffbe4ba99080dc2c570944c6
treedca63dca52bbb9f60848e94769654ade80036e5d
parentf725fa7cb2ece547c5af01eeeecfe8d95802ed41
malloc: Use overflow checking primitives where we do complex allocations

This attempts to fix the places where we do the following where
arithmetic_expr may include unvalidated data:

  X = grub_malloc(arithmetic_expr);

It accomplishes this by doing the arithmetic ahead of time using grub_add(),
grub_sub(), grub_mul() and testing for overflow before proceeding.

Among other issues, this fixes:
  - allocation of integer overflow in grub_video_bitmap_create()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_png_decode_image_header()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_squash_read_symlink()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_ext2_read_symlink()
    reported by Chris Coulson,
  - allocation of integer overflow in read_section_as_string()
    reported by Chris Coulson.

Fixes: CVE-2020-14309, CVE-2020-14310, CVE-2020-14311
Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
23 files changed:
grub-core/commands/legacycfg.c
grub-core/commands/wildcard.c
grub-core/disk/ldm.c
grub-core/font/font.c
grub-core/fs/btrfs.c
grub-core/fs/ext2.c
grub-core/fs/iso9660.c
grub-core/fs/sfs.c
grub-core/fs/squash4.c
grub-core/fs/udf.c
grub-core/fs/xfs.c
grub-core/fs/zfs/zfs.c
grub-core/fs/zfs/zfscrypt.c
grub-core/lib/arg.c
grub-core/loader/i386/bsd.c
grub-core/net/dns.c
grub-core/normal/charset.c
grub-core/normal/cmdline.c
grub-core/normal/menu_entry.c
grub-core/script/argv.c
grub-core/script/lexer.c
grub-core/video/bitmap.c
grub-core/video/readers/png.c