buglwIP - A Lightweight TCP/IP stack - Bugs: bug #53200, Suspect issue with iphdr in...

 
 

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

bug #53200: Suspect issue with iphdr in ip4_output_if_opt_src() (Causing a stack corruption)

Submitter:  Brian <mofosyne>
Submitted:  Wed 21 Feb 2018 06:36:12 AM UTC
   
 
Category:  IPv4 Severity:  3 - Normal
Item Group:  Crash Error Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  2.0.3

Sun 25 Feb 2018 11:36:43 PM UTC, comment #3: 

I think just close it for now. I suspect its a different issue as you thought. Possibly allocated a bad pbuff pointer.

I'll let you know if it needs reopening. But I think it most likely be a seperate issue if I found a real cause.

Brian <mofosyne>
Fri 23 Feb 2018 10:23:12 AM UTC, comment #2: 

Any update or should I close this as invalid/works for me?

Simon Goldschmidt <goldsimon>
Group administrator
Wed 21 Feb 2018 01:51:26 PM UTC, comment #1: 

I don't get where the error is thrown. Your line numbers don't seem to match the 2.0.3 release nor git master.

Keeping that aside, 'iphdr' is assigned just some lines before 'IPH_TOS_SET()', so I assume you have local changes, not compiling our code.

Simon Goldschmidt <goldsimon>
Group administrator
Wed 21 Feb 2018 06:36:12 AM UTC, original submission:  

I was using `-Og` for debugger friendly optimisation level, when previously I was using `-Os` which worked fine with no issue.

However it led to a stack corruption as soon as it reaches `PH_TOS_SET(iphdr, tos)` in ip4_output_if_opt_src()

This could be either an issue with my initialisation or with this function. I'm not yet sure at this stage.

After further probing I found that there is this error message:

```
In file included from ./thirdparty/lwip/src/include/lwip/ip4.h:49:0,
                 from ./thirdparty/lwip/src/include/lwip/ip.h:47,
                 from thirdparty/lwip/src/core/ipv4/ip4.c:45:
thirdparty/lwip/src/core/ipv4/ip4.c: In function 'ip4_output_if_src':
./thirdparty/lwip/src/include/lwip/prot/ip4.h:118:43: error: 'iphdr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 #define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl)
                                           ^
thirdparty/lwip/src/core/ipv4/ip4.c:823:18: note: 'iphdr' was declared here
   struct ip_hdr *iphdr;
                  ^
cc1: all warnings being treated as errors
make: * [build/GRIDTHINGS-CORE-G1-004/debug/./thirdparty/lwip/src/core/ipv4/ip4.o] Error 1
```

Adding to ip4_output_if_opt_src() in `~/thirdparty/lwip/src/core/ipv4/ip4.c` stops the stack corruption.

```
  struct ip_hdr iphdr_guard = {0}; // See if this helps stop stack crash when at gcc debugger friendly optimisation level `-Og`
  struct ip_hdr *iphdr = &iphdr_guard;
```

Still not sure whats the intention of the `struct ip_hdr *iphdr` but just letting you guys know, while I'll try and understand this function further... in case you got a idea whats going on here.

Brian <mofosyne>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-02-26 goldsimon StatusWorks For Me Invalid
        Open/ClosedOpen Closed
    2018-02-21 goldsimon StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code