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

Submitted by:  Yoav <djinng>
Submitted on:  Wed 02 Mar 2011 10:31:18 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned 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>
Project AdministratorIn charge of this item.
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>

 

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 djinng (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 22 Mar 2011 09:05:25 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1