buglwIP - A Lightweight TCP/IP stack - Bugs: bug #32648, PPP code crashes when terminating...

 
 

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

bug #32648: PPP code crashes when terminating a link

Submitter:  Yoav <djinng>
Submitted:  Wed 02 Mar 2011 10:31:18 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  Other

Tue 22 Mar 2011 09:05:25 PM UTC, comment #1: 


> 1. Removed the pppRecvWakeup() call from pppSigHup()


We don't strictly need that, do we? Anyway, since it now does nothing there's no point in keeping it...

> 2. Added a conditional to pppRecvWakeup() -
> if (pppControl[pd].openFlag)
> sio_read_abort(pppControl[pd].fd);


Done that. I hope it doesn't introduce any problems, but from reading the code, it's a good thing to check the fd before using it :-)

-> Fixed, thanks for reporting and thanks for the analysis and fix.

Simon Goldschmidt <goldsimon>
Group administrator
Wed 02 Mar 2011 10:31:18 AM UTC, original submission:  

<--BEGIN description-->

According to Simon:
"The old PPP code was really broken regarding multithreading. The modifications() that were necessary include that *none of the PPP functions may be called from any other thread than the tcpip_thread".

(*) modifications refer to version 1.4.0

When adjusting our code to call PPP APIs (pppOverSerialOpen, pppSigHup, pppClose) using tcpip_callback_with_block(), PPP code started crashing upon link termination.

<--END description-->

<--BEGIN our analysis-->

"pppLinkTerminated is always called after lcp phase is set to PHASE_DEAD. In it, the pppInput thread is "released" by calling pppRecvWakeup, the application callback is called with PPPERR_PROTOCOL, and openFlag is set to 0.

Since PPP does not manage the sio_fd (it simply receives an open handle and does not close it), there must be a point in which PPP lets me know I can have my sio_fd back. This point AFAICT is when my link_status_cb is called with PPPERR_PROTOCOL.

The problem (the crash actually) occurs because both pppClose and pppHup call pppRecvWakeup AFTER calling pppLinkTerminated. Since I release my resources on pppLinkTerminated, the call to pppRecvWakeup references a nonexistent sio_fd object.

Ideally this sio_fd would simply be an invalid handle (which is why I did not report this as a crash error), but in our case it is a real pointer.
<--END our analysis-->


<--BEGIN our fix-->

1. Removed the pppRecvWakeup() call from pppSigHup()
2. Added a conditional to pppRecvWakeup() -
   if (pppControl[pd].openFlag)
     sio_read_abort(pppControl[pd].fd);

<--END our fix-->


NOTE: have not checked against original ppp code.

Yoav <djinng>

 

(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 djinng (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
    2011-03-22 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code