buglwIP - A Lightweight TCP/IP stack - Bugs: bug #20237, pbuf memory corruption

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #20237: pbuf memory corruption

Submitted by:  Spark Jon <sparkjon>
Submitted on:  Fri 22 Jun 2007 08:48:37 AM UTC  
 
Category: pbufsSeverity: 3 - Normal
Item Group: Crash ErrorStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: None

Fri 22 Jun 2007 10:37:59 AM UTC, comment #3:

There is also an assert for checking it doesn't overflow.

Closing this as invalid.

Simon Goldschmidt <goldsimon>
Project Administrator
Fri 22 Jun 2007 10:03:51 AM UTC, comment #2:

Sorry, Yes, I'm using v1.2.0.

Spark Jon <sparkjon>
Fri 22 Jun 2007 08:57:40 AM UTC, comment #1:

As far as I know, this is already fixed in CVS HEAD:

>>> code from CVS HEAD >>>

p->len = length > PBUF_POOL_BUFSIZE - LWIP_MEM_ALIGN_SIZE(offset)? PBUF_POOL_BUFSIZE - LWIP_MEM_ALIGN_SIZE(offset): length;
<<< code from CVS HEAD <<<

I'm guessing you are using v1.2.0 or previous, not CVS HEAD?

Simon Goldschmidt <goldsimon>
Project Administrator
Fri 22 Jun 2007 08:48:37 AM UTC, original submission:

pbuf.c - pbuf_alloc()

The pbuf corrupts the next pbuf under the following conditions,
1. If the p->payload been aligned and moved.
p->payload = MEM_ALIGN((void )((u8_t )p + (sizeof(struct pbuf) + offset)));

2. length > PBUF_POOL_BUFSIZE - offset
p->len = length > PBUF_POOL_BUFSIZE - offset ?
PBUF_POOL_BUFSIZE - offset : length;

The following code fragment fixed the alignment problem which cause the p->payload + p->len over the range of pbuf, and the later data write to p->payload address with p->len will overwrite the p->next value.

/* set the length of the first pbuf in the chain */
pbuf_end = (u32)p + sizeof(struct pbuf) + PBUF_POOL_BUFSIZE;
p->len = length > pbuf_end - (u32)p->payload ? pbuf_end - (u32)p->payload : length;

Spark Jon <sparkjon>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by sparkjon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 22 Jun 2007 10:37:59 AM UTCgoldsimonStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1