buglwIP - A Lightweight TCP/IP stack - Bugs: bug #43361, select() crashes with stale FDs

 
 

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

bug #43361: select() crashes with stale FDs

Submitted by:  Joel Cunningham <jcunningham>
Submitted on:  Sun 05 Oct 2014 09:01:14 PM UTC  
 
Category: sockets/netconnSeverity: 3 - Normal
Item Group: Crash ErrorStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: 1.4.1

Sat 17 Jan 2015 08:13:34 PM UTC, comment #1:

Fixed by checking the return value of tryget_socket(): if one socket fails, the function is aborted after decreasing 'select_waiting' of the lower sockets.

There is however still one possible bug of a lower socket getting closed and reused between 'select_waiting++' and 'select_waiting--', but that's a more advanced use case than this one...

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Sun 05 Oct 2014 09:01:14 PM UTC, original submission:

If an application calls select() with FDs set that do not correspond to valid open sockets, a data abort will occur.

There are two spots where calls to tryget_socket() returns a NULL and it is dereferenced: when increasing and decreasing the sock->select_waiting value. Other uses of tryget_socket() handle the NULL gracefully.

Just handling the NULL wouldn't technically be correct behavior of select according to the Open Group specification:

http://pubs.opengroup.org/onlinepubs/007908799/xsh/select.html

We could add a single spin through the set FDs and check the validity of the sockets. Or as the sockets are processed via tryget_socket(), if a failure is encountered, set errno and cleanup.

My project uses LwIP 1.4.1, but the NULL don't appear to be handled on head of master branch either

Joel Cunningham <jcunningham>
Project Member

 

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 jcunningham (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
    Sat 17 Jan 2015 08:13:34 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1