Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5ed4b110a32ed4b5dd196ee548d58dd904b1fa9c5935286171920f2dc0cbc8bc
Ticket: c6897e6e6a8a65a995ec35c9c297b926bf1b6783
select notifier crashes/misbehaves on fd >= FD_SETSIZE
User & Date: obj on 2019-11-05 04:31:45
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    The select notifier crashes or misbehaves if given a file descriptor that's >=
    FD_SETSIZE. This is because it's using the FD_* macros blindly without checking
    whether the descriptor is in range, which trashes the stack.
    
    This has security implications. The overrun doesn't seem directly exploitable,
    but it is at a minimum a cheap DoS attack against a typical server that's
    accepting connections on a socket - establish ~1000 connections and the process
    will crash unavoidably.
    
    To reproduce on Linux (FD_SETSIZE is 1024):
    
    $ ulimit -n 4096
    $ ./crashme.tcl 600      # 600*2 > 1024
    [...]
    *** buffer overflow detected ***: tclsh terminated
    Aborted (core dumped)
    
    On FreeBSD, there's no immediate crash but the notifier starts spinning without
    making progress.
    
    From inspection it looks like the select notifier code in 8.7 still has the
    same problem.
    
    --- 8< ---
    
    #!/usr/bin/env tclsh
    
    proc dummy {args} {}
    
    proc accept_one {sock addr port} {
        fileevent $sock readable dummy
        puts -nonewline stderr "+"
    }
    
    proc crashme {count} {
        puts -nonewline stderr "connecting $count sockets "
    
        set listener [socket -server accept_one 0]
        lassign [chan configure $listener -sockname] listenIp listenHost listenPort
    
        for {set i 0} {$i < $count} {incr i} {
            set client [socket -async $listenIp $listenPort]
            fileevent $client readable dummy
            puts -nonewline stderr "."
            update
        }
    
        puts stderr " done."
    }
    
    if {!$tcl_interactive} {
        crashme [lindex $::argv 0]
    }
    
    --- 8< ---
    
  5. foundin changed to: "8.6.9"
  6. is_private changed to: "0"
  7. login: "obj"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "900fc5ce35b9c7638101bd1f61914637995d3ab3"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "obj"
  14. subsystem changed to: "01. Notifier"
  15. title changed to:
    select notifier crashes/misbehaves on fd >= FD_SETSIZE
    
  16. type changed to: "Bug"