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> Patch-Name: safe-alloc-4.patch
Showing
- grub-core/commands/legacycfg.c 24 additions, 5 deletionsgrub-core/commands/legacycfg.c
- grub-core/commands/wildcard.c 31 additions, 5 deletionsgrub-core/commands/wildcard.c
- grub-core/disk/ldm.c 23 additions, 9 deletionsgrub-core/disk/ldm.c
- grub-core/font/font.c 6 additions, 1 deletiongrub-core/font/font.c
- grub-core/fs/btrfs.c 19 additions, 9 deletionsgrub-core/fs/btrfs.c
- grub-core/fs/ext2.c 9 additions, 1 deletiongrub-core/fs/ext2.c
- grub-core/fs/iso9660.c 36 additions, 15 deletionsgrub-core/fs/iso9660.c
- grub-core/fs/sfs.c 22 additions, 5 deletionsgrub-core/fs/sfs.c
- grub-core/fs/squash4.c 34 additions, 11 deletionsgrub-core/fs/squash4.c
- grub-core/fs/udf.c 27 additions, 14 deletionsgrub-core/fs/udf.c
- grub-core/fs/xfs.c 7 additions, 4 deletionsgrub-core/fs/xfs.c
- grub-core/fs/zfs/zfs.c 15 additions, 7 deletionsgrub-core/fs/zfs/zfs.c
- grub-core/fs/zfs/zfscrypt.c 6 additions, 1 deletiongrub-core/fs/zfs/zfscrypt.c
- grub-core/lib/arg.c 18 additions, 2 deletionsgrub-core/lib/arg.c
- grub-core/loader/i386/bsd.c 7 additions, 1 deletiongrub-core/loader/i386/bsd.c
- grub-core/net/dns.c 8 additions, 1 deletiongrub-core/net/dns.c
- grub-core/normal/charset.c 8 additions, 2 deletionsgrub-core/normal/charset.c
- grub-core/normal/cmdline.c 12 additions, 2 deletionsgrub-core/normal/cmdline.c
- grub-core/normal/menu_entry.c 11 additions, 2 deletionsgrub-core/normal/menu_entry.c
- grub-core/script/argv.c 14 additions, 2 deletionsgrub-core/script/argv.c
Loading
Please register or sign in to comment