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

Submitter:  Joel Cunningham <jcunningham>
Submitted:  Sun 05 Oct 2014 09:01:14 PM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Crash Error Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned 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>
Group administrator
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:


Under the following conditions, select() fails and sets errno to:

[EBADF]
    One or more of the file descriptor sets specified a file descriptor that is not a valid open file descriptor.


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>
Group Member

 

(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 jcunningham (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
    2015-01-17 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code