This project is mirrored from https://git.samba.org/socket_wrapper.git. Pull mirroring updated .
  1. 17 Mar, 2021 1 commit
  2. 15 Mar, 2021 11 commits
  3. 10 Feb, 2021 2 commits
  4. 09 Feb, 2021 3 commits
  5. 08 Feb, 2021 8 commits
  6. 05 Feb, 2021 6 commits
    • Stefan Metzmacher's avatar
      swrap: fix copy on write leak of ~38M for every fork. · 13a6aca3
      Stefan Metzmacher authored
      commit 0f8e90dd
      
      
      (src/socket_wrapper.c: fix mutex fork handling)
      let us touch the whole sockets array on every fork,
      because each element in the array has it's own mutex.
      
      max_sockets=65535 * sizeof(struct socket_info_container)=592 = 38796720
      
      This was designed for the use of robust shared mutexes
      when moving the sockets array into a shared memory file.
      
      Until we really move to shared memory, we can use a single
      global mutex in order to avoid the copy on write leaking.
      Signed-off-by: Stefan Metzmacher's avatarStefan Metzmacher <metze@samba.org>
      Reviewed-by: Andreas Schneider's avatarAndreas Schneider <asn@samba.org>
      13a6aca3
    • Stefan Metzmacher's avatar
      swrap: abort on mutex errors · 92a4fce9
      Stefan Metzmacher authored
      
      
      There's no way to continue in a reliable way...
      Signed-off-by: Stefan Metzmacher's avatarStefan Metzmacher <metze@samba.org>
      Reviewed-by: Andreas Schneider's avatarAndreas Schneider <asn@samba.org>
      92a4fce9
    • Stefan Metzmacher's avatar
      swrap: fallback to libc_getpeername() when we get an empty sun_path from accept() · affaf424
      Stefan Metzmacher authored
      
      
      This hopefully hides the strange behaviour of FreeBSD (at least 12.1)
      for already disconnected AF_UNIX sockets.
      
      The race is triggered when the following detects the usage of 'getpeername':
      
      truss -o ./truss.out -f -H -a -e -D -s 160 ctest -V -R test_thread_echo_tcp_connect;
      grep getpeername truss.out
      
      In a simplified log the following is happening:
      
       ECHO_SRV(parent): socket(PF_LOCAL,SOCK_STREAM,0) = 4 (0x4)
       ECHO_SRV(parent): unlink("/tmp/w_E37bkf/T0A0007") ERR#2 'No such file or directory'
       ECHO_SRV(parent): bind(4,{ AF_UNIX "/tmp/w_E37bkf/T0A0007" },106) = 0 (0x0)
       ECHO_SRV(parent): listen(4,16)		 = 0 (0x0)
       ...
       ECHO_SRV(parent): write(2,"SWRAP_ERROR[echo_srv (9792)] - swrap_accept: before accept(sa_socklen=106)\n",75) = 75 (0x4b)
       ECHO_SRV(parent): accept4(0x4,0x7ffffffde158,0x7ffffffde150,0x0) = 5 (0x5)
       ECHO_SRV(parent): write(2,"SWRAP_ERROR[echo_srv (9792)] - swrap_accept: after accept(sa_socklen=106, family=1)\n",84) = 84 (0x54)
       ECHO_SRV(parent): getsockname(5,{ AF_UNIX "/tmp/w_E37bkf/T0A0007" },0x7ffffffde0c0) = 0 (0x0)
      
       ECHO_SRV(parent): swrap_accept() returned a valid connection and a per connection child (pid=9793) handles it
      
       TEST_THREAD:      socket(PF_LOCAL,SOCK_STREAM,0) = 7 (0x7)
       TEST_THREAD:      bind(7,{ AF_UNIX "/tmp/w_E37bkf/T014D4F" },106) = 0 (0x0)
       TEST_THREAD:      connect(7,{ AF_UNIX "/tmp/w_E37bkf/T0A0007" },106) = 0 (0x0)
       TEST_THREAD:      close(7)		 = 0 (0x0)
      
       ECHO_SRV(parent): wait4(-1,0x0,0x0,0x0)	 = 9793 (0x2641)
       ECHO_SRV(parent): close(5)		 = 0 (0x0)
       ECHO_SRV(parent): write(2,"SWRAP_ERROR[echo_srv (9792)] - swrap_accept: before accept(sa_socklen=106)\n",75) = 75 (0x4b)
       ECHO_SRV(parent): accept4(0x4,0x7ffffffde158,0x7ffffffde150,0x0) = 5 (0x5)
      
       TEST_THREAD:      unlink("/tmp/w_E37bkf/T014D4F") = 0 (0x0)
      
       ECHO_SRV(parent): write(2,"SWRAP_ERROR[echo_srv (9792)] - swrap_accept: after accept(sa_socklen=16, family=1)\n",83) = 83 (0x53)
       ECHO_SRV(parent): getpeername(5,0x7ffffffde158,0x7ffffffde150) ERR#57 'Socket is not connected'
       ECHO_SRV(parent): getsockname(5,{ AF_UNIX "/tmp/w_E37bkf/T0A0007" },0x7ffffffde0c0) = 0 (0x0)
       ECHO_SRV(parent): getpeername(5,0x7ffffffde158,0x7ffffffde150) ERR#57 'Socket is not connected'
      Signed-off-by: Stefan Metzmacher's avatarStefan Metzmacher <metze@samba.org>
      Reviewed-by: Andreas Schneider's avatarAndreas Schneider <asn@samba.org>
      affaf424
    • Stefan Metzmacher's avatar
      swrap: make swrap_accept() more resilient against races related to already disconnected sockets · e72898ad
      Stefan Metzmacher authored
      
      
      Callers of accept() expect to get ECONNABORTED instead of a disconnected
      socket.
      
      Even on Linux we have a potential race calling libc_getsockname()
      after accept(), so we map ENOTCONN to ECONNABORTED.
      
      We should do all syscalls in order to have peer and sockname, before
      doing in memory things like calling sockaddr_convert_from_un().
      Signed-off-by: Stefan Metzmacher's avatarStefan Metzmacher <metze@samba.org>
      Reviewed-by: Andreas Schneider's avatarAndreas Schneider <asn@samba.org>
      e72898ad
    • Stefan Metzmacher's avatar
      c3f7465f
    • Stefan Metzmacher's avatar
      tests/echo_srv: make the main server logic resilient to ECONNABORTED from accept() · fa7a9b7a
      Stefan Metzmacher authored
      
      
      That should fix a race where the connect() directly followed by close()
      in test_thread_echo_tcp_connect will cause the echo_srv to terminate
      early, which results in connect() returning ECONNREFUSED in for other
      threads.
      
      This mainly happens on FreeBSD, but it can also happen on Linux.
      Signed-off-by: Stefan Metzmacher's avatarStefan Metzmacher <metze@samba.org>
      Reviewed-by: Andreas Schneider's avatarAndreas Schneider <asn@samba.org>
      fa7a9b7a
  7. 02 Feb, 2021 9 commits