All of lore.kernel.org
 help / color / mirror / Atom feed
* [CHECKER] 3 kmalloc underallocation bugs
@ 2001-04-05 22:45 Dawson Engler
  2001-04-05 23:13 ` André Dahlqvist
  2001-04-06  3:33 ` Ben Pfaff
  0 siblings, 2 replies; 4+ messages in thread
From: Dawson Engler @ 2001-04-05 22:45 UTC (permalink / raw)
  To: linux-kernel

enclosed are three bugs found in the 2.4.1 kernel by an extension
that checks that kmalloc calls allocate enough memory.  It examines all
callsites of the form:
	p = [kv]malloc(nbytes);
and issues an error if
	sizeof *p < nbytes

I think they're all currently harmless because of kmalloc & friends
exuberant approach to padding.

Dawson

drivers/sound/emu10k1/midi.c
drivers/telephony/ixj.c
---------------------------------------------------------
[BUG]  should allocate sizeof *midihdr

/u2/engler/mc/oses/linux/2.4.1/drivers/sound/emu10k1/midi.c:59:midiin_add_buffer
: ERROR:SIZE-CHECK:59:59: midihdr = 'kmalloc'(4 bytes), need 32


static int midiin_add_buffer(struct emu10k1_mididevice *midi_dev, struct midi_hd
r **midihdrptr)
{
        struct midi_hdr *midihdr;

Error --->
        if ((midihdr = (struct midi_hdr *) kmalloc(sizeof(struct midi_hdr *), GF
P_KERNEL)) == NULL) {
                ERROR();
                return -EINVAL;
        }

---------------------------------------------------------
[BUG] same
/u2/engler/mc/oses/linux/2.4.1/drivers/sound/emu10k1/midi.c:331:emu10k1_midi_wri
te: ERROR:SIZE-CHECK:331:331: midihdr = 'kmalloc'(4 bytes), need 32

        struct midi_hdr *midihdr;
        ssize_t ret = 0;
        unsigned long flags;

        DPD(4, "emu10k1_midi_write(), count=%x\n", (u32) count);

        if (pos != &file->f_pos)
                return -ESPIPE;

        if (!access_ok(VERIFY_READ, buffer, count))
                return -EFAULT;

Error --->
        if ((midihdr = (struct midi_hdr *) kmalloc(sizeof(struct midi_hdr *), GF
P_KERNEL)) == NULL)
                return -EINVAL;

---------------------------------------------------------
[BUG]  should be sizeof(IXJ_FILTER_CADENCE) as with the copy_from_user

/u2/engler/mc/oses/linux/2.4.1/drivers/telephony/ixj.c:4511:ixj_build_filter_cad
ence: ERROR:SIZE-CHECK:4511:4511: lcp = 'kmalloc'(12 bytes), need 32


        ... DELETED 7 lines ...

        IXJ_FILTER_CADENCE *lcp;
        IXJ *j = &ixj[board];
Error --->
        lcp = kmalloc(sizeof(IXJ_CADENCE), GFP_KERNEL);
        if (lcp == NULL)
                return -ENOMEM;
        if (copy_from_user(lcp, (char *) cp, sizeof(IXJ_FILTER_CADENCE)))
                return -EFAULT;
----------------------------------------



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-04-06  3:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-05 22:45 [CHECKER] 3 kmalloc underallocation bugs Dawson Engler
2001-04-05 23:13 ` André Dahlqvist
     [not found]   ` <3ACCFF07.5AF0A74A@resilience.com>
2001-04-05 23:27     ` Jeff Golds
2001-04-06  3:33 ` Ben Pfaff

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.