[SCM] Socket Wrapper Repository - branch master updated

2021-02-05 Thread Andreas Schneider
The branch, master has been updated
   via  13a6aca swrap: fix copy on write leak of ~38M for every fork.
   via  92a4fce swrap: abort on mutex errors
   via  affaf42 swrap: fallback to libc_getpeername() when we get an empty 
sun_path from accept()
   via  e72898a swrap: make swrap_accept() more resilient against races 
related to already disconnected sockets
   via  c3f7465 swrap: add better logging to convert_un_in()
   via  fa7a9b7 tests/echo_srv: make the main server logic resilient to 
ECONNABORTED from accept()
  from  cd51d80 Bump version to 1.3.0

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -
commit 13a6aca342120383776251247c72170c142bf017
Author: Stefan Metzmacher 
Date:   Thu Feb 4 05:02:32 2021 +0100

swrap: fix copy on write leak of ~38M for every fork.

commit 0f8e90dd7e59c473be615dee08d445dca98fdab9
(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 
Reviewed-by: Andreas Schneider 

commit 92a4fce9df55e4c1a3b75325baa0f4b0988eeb6c
Author: Stefan Metzmacher 
Date:   Fri Feb 5 11:50:17 2021 +0100

swrap: abort on mutex errors

There's no way to continue in a reliable way...

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Andreas Schneider 

commit affaf4248c0cc2056081f56199109e4a94348b82
Author: Stefan Metzmacher 
Date:   Fri Feb 5 13:13:44 2021 +0100

swrap: fallback to libc_getpeername() when we get an empty sun_path from 
accept()

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,0x7ffde158,0x7ffde150,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" 
},0x7ffde0c0) = 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,0x7ffde158,0x7ffde150,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,0x7ffde158,0x7ffde150) ERR#57 
'Socket is not connected'
 ECHO_SRV(parent): getsockname(5,{ AF_UNIX "/tmp/w_E37bkf/T0A0007" 
},0x7ffde0c0) = 0 (0x0)
 ECHO_SRV(parent): getpeername(5,0x7ffde158,0x7ffde150) ERR#57 
'Socket is not connected'

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Andreas Schneider 

commit e72898ad92a52a595d4733210483e9689cb5d390
Author: Stefan Metzmacher 
Date:   Fri Feb 5 12:13:12 2021 +0100

swrap: make swrap_accept() more resilient against races related to already 
disconnected sockets

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 

[SCM] Samba Shared Repository - branch v4-12-test updated

2021-02-05 Thread Karolin Seeger
The branch, v4-12-test has been updated
   via  40e503732dc lib:util: Avoid free'ing our own pointer
   via  65b3648c553 lib:util: Add cache oversize test for memcache
   via  a658dd19627 lib:util: Add basic memcache unit test
   via  6e6aa90b87b s3: libsmb: cli_state_save_tcon(). Don't deepcopy tcon 
struct when temporarily swapping out a connection on a cli_state.
   via  bab7f2ae28e s3: torture: Change the SMB1-only UID-REGRESSION-TEST 
to do an explicit copy of the tcon struct in use.
   via  a19f94c644d s3: smbtorture3: Ensure run_tcon_test() always replaces 
any saved tcon and shuts down correctly even in error paths.
   via  80d2c3e4725 s3: smbtorture3: Ensure we *always* replace the saved 
saved_tcon even in an error condition.
   via  a00ff434515 s3: tests: Add regression test for bug 13992.
  from  8c846741a45 s3/auth: implement "winbind:ignore domains"

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-12-test


- Log -
commit 40e503732dc0129b8e5f7bc84ca027514d2ef02e
Author: Andreas Schneider 
Date:   Tue Feb 2 18:10:38 2021 +0100

lib:util: Avoid free'ing our own pointer

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14625

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 
(cherry picked from commit 0bdbe50fac680be3fe21043246b8c75005611351)

Autobuild-User(v4-12-test): Karolin Seeger 
Autobuild-Date(v4-12-test): Fri Feb  5 12:14:09 UTC 2021 on sn-devel-184

commit 65b3648c55332d6186c6a03c0ef56e683a7afa46
Author: Andreas Schneider 
Date:   Wed Feb 3 10:37:12 2021 +0100

lib:util: Add cache oversize test for memcache

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14625

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 
(cherry picked from commit 00543ab3b29e3fbfe8314e51919629803e14ede6)

commit a658dd19627ebe43d4e4fc494ff0d60507554a84
Author: Andreas Schneider 
Date:   Wed Feb 3 10:30:08 2021 +0100

lib:util: Add basic memcache unit test

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14625

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 
(cherry picked from commit bebbf621d6052f797c5cf19a2a9bbc13e699d3f0)

commit 6e6aa90b87b5ddaa6b92160eb467090705e25ff6
Author: Jeremy Allison 
Date:   Thu Jan 28 11:08:48 2021 -0800

s3: libsmb: cli_state_save_tcon(). Don't deepcopy tcon struct when 
temporarily swapping out a connection on a cli_state.

This used to make a deep copy of either
cli->smb2.tcon or cli->smb1.tcon, but this leaves
the original tcon pointer in place which will then get
TALLOC_FREE()'d when the new tree connection is made on
this cli_state.

As there may be pipes open on the old tree connection with
talloc'ed state allocated using the original tcon pointer as a
talloc parent we can't deep copy and then free this pointer
as that will fire the destructors on the pipe memory and
mark them as not connected.

This call is used to temporarily swap out a tcon pointer
(whilst keeping existing pipes open) to allow a new tcon
on the same cli_state and all users correctly call
cli_state_restore_tcon() once they are finished with
the new tree connection.

Just return the existing pointer and set the old value to NULL.
We know we MUST be calling cli_state_restore_tcon() below
to restore the original tcon tree connection pointer before
closing the session.

Remove the knownfail.d entry.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13992

Signed-off-by: Jeremy Allison 
Reviewed-by: Andreas Schneider 

Autobuild-User(master): Jeremy Allison 
Autobuild-Date(master): Tue Feb  2 21:05:25 UTC 2021 on sn-devel-184

(cherry picked from commit 4f80f5f9046b64a9e5e0503b1cb54f1492c4faec)

commit bab7f2ae28e5bd0a44e121c9b7e9d868271fac70
Author: Jeremy Allison 
Date:   Thu Jan 28 17:35:55 2021 -0800

s3: torture: Change the SMB1-only UID-REGRESSION-TEST to do an explicit 
copy of the tcon struct in use.

For this test only, explicitly copy the SMB1 tcon struct,
don't use cli_state_save_tcon()//cli_state_restore_tcon()
as these calls will soon change to just manipulate the pointer
to avoid TALLOC_FREE() on the tcon struct which calls
destructors on child pipe data.

In SMB1 this test calls cli_tdis() twice with an invalid
vuid and expects the SMB1 tcon struct to be preserved
across the calls.

SMB1 cli_tdis() frees cli->smb1.tcon so we must put back
a deep copy into cli->smb1.tcon to be able to safely call
cli_tdis() again.

This is a test-only hack. Real client code
uses cli_state_save_tcon()/cli_state_restore_tcon()
if it needs to temporarily swap out the active
tcon on a client connection.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13992