Skip to content
Tcl Source Code History Of Ticket 0ac9d06895
Login

History Of Ticket 0ac9d06895

Artifacts Associated With Ticket 0ac9d06895

  1. Ticket change [e70fbc08a0] (rid 163815) by stu on 2018-06-07 06:25:47:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/html"
    4. comment initialized to:
      Tcl_MakeFileChannel(3) checks if the given fd is a tty or a socket before assuming it's a file.
      <br>
      If there are <a href="https://man.openbsd.org/pledge">pledge(2)</a>es in effect that are restricting the usage of network functions then Tcl_MakeFileChannel will segfault when it tries to use getsockname(2) to check if the fd is a socket.
      <br>
      An important time when this happens is when tclsh is fed a script on stdin: tclsh will immediately segfault.
      <br>
      By using fstat(2) to first check if the fd is a socket, a call to getsockname might be avoided.
      <br>
      This may have security implications.
      <br><br>
      Attached is a patch.
      <br>
      The patch has the nice side effect of putting all the socket bits in one place.
      <br><br>
      Here is a test program:
      <pre>
      #include <unistd.h>
      #define TCLSH "/usr/local/bin/tclsh"
      int main (int argc, char *argv[]) {
              char *a[] = { TCLSH, NULL };
              char *e[] = { NULL };
      
      #ifdef DNS
              pledge(NULL, "stdio rpath getpw dns");
      #else
      # ifdef INET
              pledge(NULL, "stdio rpath getpw inet");
      # else
              pledge(NULL, "stdio rpath getpw");
      # endif
      #endif
      
              execve(TCLSH, a, e);
              return 0;
      }
      </pre>
      
      Build with no -D's:
      <pre>
      $ cc -o tpl tpl.c
      $ echo 'puts moo' | ./tpl
      Abort trap (core dumped) 
      </pre>
      
      Build with either -DINET or -DDNS:
      <pre>
      $ cc -o tpl tpl.c -DINET
      $ echo 'puts moo' | ./tpl
      moo
      </pre>
      
    5. foundin initialized to: "8.6.*"
    6. is_private initialized to: "0"
    7. login: "stu"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "702b65e835b7b4b4720d6e9d37fc582f82909394"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "stu"
    14. subsystem initialized to: "38. Init - Library - Autoload"
    15. title initialized to:
      Don't call getsockname(2) in Tcl_MakeFileChannel(3) unless absolutely necessary
      
    16. type initialized to: "RFE"
  2. Add attachment "patch-unix_tclUnixChan_c" [fd56a6851b] (rid 163817) by stu on 2018-06-07 06:27:08.

  3. Ticket change [a7b7e1ebfe] (rid 163818) by stu on 2018-06-07 06:28:26:

    1. comment changed to:
      Tcl_MakeFileChannel(3) checks if the given fd is a tty or a socket before assuming it's a file.
      <br>
      If there are <a href="https://man.openbsd.org/pledge">pledge(2)</a>es in effect that are restricting the usage of network functions then Tcl_MakeFileChannel will segfault when it tries to use getsockname(2) to check if the fd is a socket.
      <br>
      An important time when this happens is when tclsh is fed a script on stdin: tclsh will immediately segfault.
      <br>
      By using fstat(2) to first check if the fd is a socket, a call to getsockname might be avoided.
      <br>
      This may have security implications.
      <br><br>
      Attached is a patch afainst 8.6.8.
      <br>
      The patch has the nice side effect of putting all the socket bits in one place.
      <br><br>
      Here is a test program:
      <pre>
      #include <unistd.h>
      #define TCLSH "/usr/local/bin/tclsh"
      int main (int argc, char *argv[]) {
              char *a[] = { TCLSH, NULL };
              char *e[] = { NULL };
      
      #ifdef DNS
              pledge(NULL, "stdio rpath getpw dns");
      #else
      # ifdef INET
              pledge(NULL, "stdio rpath getpw inet");
      # else
              pledge(NULL, "stdio rpath getpw");
      # endif
      #endif
      
              execve(TCLSH, a, e);
              return 0;
      }
      </pre>
      
      Build with no -D's:
      <pre>
      $ cc -o tpl tpl.c
      $ echo 'puts moo' | ./tpl
      Abort trap (core dumped) 
      </pre>
      
      Build with either -DINET or -DDNS:
      <pre>
      $ cc -o tpl tpl.c -DINET
      $ echo 'puts moo' | ./tpl
      moo
      </pre>
      
    2. login: "stu"
    3. mimetype: "text/plain"
    4. subsystem changed to: "25. Channel System"
  4. Ticket change [cf4e37a582] (rid 163819) by stu on 2018-06-07 06:28:40:

    1. comment changed to:
      Tcl_MakeFileChannel(3) checks if the given fd is a tty or a socket before assuming it's a file.
      <br>
      If there are <a href="https://man.openbsd.org/pledge">pledge(2)</a>es in effect that are restricting the usage of network functions then Tcl_MakeFileChannel will segfault when it tries to use getsockname(2) to check if the fd is a socket.
      <br>
      An important time when this happens is when tclsh is fed a script on stdin: tclsh will immediately segfault.
      <br>
      By using fstat(2) to first check if the fd is a socket, a call to getsockname might be avoided.
      <br>
      This may have security implications.
      <br><br>
      Attached is a patch against 8.6.8.
      <br>
      The patch has the nice side effect of putting all the socket bits in one place.
      <br><br>
      Here is a test program:
      <pre>
      #include <unistd.h>
      #define TCLSH "/usr/local/bin/tclsh"
      int main (int argc, char *argv[]) {
              char *a[] = { TCLSH, NULL };
              char *e[] = { NULL };
      
      #ifdef DNS
              pledge(NULL, "stdio rpath getpw dns");
      #else
      # ifdef INET
              pledge(NULL, "stdio rpath getpw inet");
      # else
              pledge(NULL, "stdio rpath getpw");
      # endif
      #endif
      
              execve(TCLSH, a, e);
              return 0;
      }
      </pre>
      
      Build with no -D's:
      <pre>
      $ cc -o tpl tpl.c
      $ echo 'puts moo' | ./tpl
      Abort trap (core dumped) 
      </pre>
      
      Build with either -DINET or -DDNS:
      <pre>
      $ cc -o tpl tpl.c -DINET
      $ echo 'puts moo' | ./tpl
      moo
      </pre>
      
    2. login: "stu"
    3. mimetype: "text/plain"
  5. Ticket change [d481860082] (rid 163929) by stu on 2018-06-13 16:18:24:

    1. closedate changed to: "2458283.17944524"
    2. closer changed to: "stu"
    3. icomment: "Closed by [a23a536a48]."
    4. login: "stu"
    5. mimetype: "text/plain"
    6. resolution changed to: "Accepted"
    7. status changed to: "Closed"
    8. username: "stu"
  6. Ticket change [abf17c3476] (rid 163930) by stu on 2018-06-13 16:20:03:

    1. closedate changed to: "2458283.18059733"
    2. icomment: "[a23a536a48e68141]"
    3. login: "stu"
    4. mimetype: "text/x-fossil-wiki"
    5. username: "stu"