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

Jule Anger janger at samba.org
Tue Aug 23 08:58:01 UTC 2022


The branch, v4-17-test has been updated
       via  fbcb8db069c WHATSNEW: document new volume serial number smb.conf parameter
       via  0b15ebced78 s3:smbd: let delay_for_oplock_fn() only call leases_db_get() once
       via  cb63afbda1b s3:smbd: lease_match_break_fn() only needs leases_db_get() once
       via  e764e40ad55 s3:smbd: inline fsp_lease_type_is_exclusive() logic into contend_level2_oplocks_begin_default
       via  fa8d19056bd s3:locking: move get_existing_share_mode_lock() to share_mode_lock.[ch]
       via  411af5fb48c s3:locking: pass lease_key explicitly to set_share_mode()
       via  6bf37ba4538 s3:smbd: only run validate_oplock_types() with smbd:validate_oplock_types = yes
       via  f207ef33224 s3:g_lock: avoid useless talloc_array(0) in g_lock_dump()
       via  e4538e70cbe s3:g_lock: add some const to the shared array passed via g_lock_dump*()
       via  208037a7eea lib/util: add unlikely() to SMB_ASSERT()
       via  76bff90824a s3: smbd: Plumb close_type parameter through close_file_in_loop(), file_close_conn()
       via  91273a969ab s3: smbd: Add "enum file_close_type close_type" parameter to file_close_conn().
       via  5fc9bf0f63c s3: smbd: Add "enum file_close_type close_type" parameter to close_cnum().
       via  c47b7479e74 s3/smbd: Use after free when iterating smbd_server_connection->connections
       via  0b33961e71a s3/smbd: Use after free when iterating smbd_server_connection->connections
       via  0725e1ea851 s3:utils remove documentation of -l as alias for --long
       via  c4c99397c56 s3:smbd: only clear LEASE_READ if there's no read lease is left
       via  0529214b3cc s4:torture/smb2: add smb2.lease.v[1,2]_bug_15148
       via  6ac28f43868 s3:smbd: share_mode_flags_set() takes SMB2_LEASE_* values
       via  e3ee5197a6d libcli/smb: Set error status if 'iov' pointer is NULL
       via  dee2505716d libcli/smb: Ensure we call tevent_req_nterror() on failure
      from  877287e6b4e VERSION: Bump version up to Samba 4.17.0rc3...

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


- Log -----------------------------------------------------------------
commit fbcb8db069c865cfa002d69b224bd3dfc6f9b840
Author: Christian Ambach <ambi at samba.org>
Date:   Wed Aug 17 13:17:29 2022 +0200

    WHATSNEW: document new volume serial number smb.conf parameter
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    
    Autobuild-User(v4-17-test): Jule Anger <janger at samba.org>
    Autobuild-Date(v4-17-test): Tue Aug 23 08:57:28 UTC 2022 on sn-devel-184

commit 0b15ebced782382bef77877524d45197332e4488
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 15 09:56:15 2022 +0200

    s3:smbd: let delay_for_oplock_fn() only call leases_db_get() once
    
    get_lease_type() will just call leases_db_get() again for leases,
    so only call it for oplocks.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Aug 19 19:39:18 UTC 2022 on sn-devel-184
    
    (cherry picked from commit d4f18f99d3a40a8df00beb006e2731959aa6fad9)

commit cb63afbda1b07b5fafe09a28a03aeedbd353346c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 15 09:45:43 2022 +0200

    s3:smbd: lease_match_break_fn() only needs leases_db_get() once
    
    get_lease_type() will just call leases_db_get() again...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 60ae7a5a2ed9a03d8693b9b455b7b3696386aeb1)

commit e764e40ad5569b2976d7a891d868a30281e73f44
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 18 12:52:54 2022 +0200

    s3:smbd: inline fsp_lease_type_is_exclusive() logic into contend_level2_oplocks_begin_default
    
    SMB2_LEASE_WRITE is the indication for an exclusive lease,
    the fact that a SMB2_LEASE_WRITE can't exists without
    SMB2_LEASE_READ is not important here.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 76da56aa65bb9fe7f2f8c4a2e30e278a61db1ff5)

commit fa8d19056bd71d0581a5a66d2ea9bab38b8af768
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 18 14:14:20 2022 +0200

    s3:locking: move get_existing_share_mode_lock() to share_mode_lock.[ch]
    
    This should be where get_share_mode_lock() is located.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit bf8f2258497f7d2a5a5f8d1cacf1a30899ed455c)

commit 411af5fb48c076500be41b795b7627edf3554b8e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 10 08:27:15 2022 +0000

    s3:locking: pass lease_key explicitly to set_share_mode()
    
    We should avoid accessing fsp->lease if possible.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 8b3b316680221487f84a7cfe14f52e8ffd64ba85)

commit 6bf37ba4538b309bf455c26ab0aeca6ba376d552
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 19 15:17:41 2022 +0000

    s3:smbd: only run validate_oplock_types() with smbd:validate_oplock_types = yes
    
    This is really expensive as share_mode_forall_entries() is currently
    doing a talloc_memdup() of the whole record...
    
    This is mainly used to avoid regressions, so only
    use smbd:validate_oplock_types = yes in make test,
    but skip it for production.
    
    This improves the following test:
    
     time smbtorture //127.0.0.1/m -Uroot%test \
            smb2.create.bench-path-contention-shared \
            --option='torture:bench_path=file.dat' \
            --option="torture:timelimit=60" \
            --option="torture:nprocs=256" \
            --option="torture:qdepth=1"
    
    From:
    
       open[num/s=8852,avslat=0.014999,minlat=0.000042,maxlat=0.054600]
       close[num/s=8850,avslat=0.014136,minlat=0.000025,maxlat=0.054537]
    
    to:
    
       open[num/s=11377,avslat=0.012075,minlat=0.000041,maxlat=0.054107]
       close[num/s=11375,avslat=0.010594,minlat=0.000023,maxlat=0.053620]
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 0fbca175ae4763d82f8a414ee3d6354c95d5294e)

commit f207ef332244c0bc935dfbbe668d78617803994c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 18 17:32:43 2022 +0200

    s3:g_lock: avoid useless talloc_array(0) in g_lock_dump()
    
    In the common case we don't have any shared lock holders,
    so there's no need to allocate memory for the empty array.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit c75de325710c0fbbd50a0acd3af55404165440d6)

commit e4538e70cbe603ce2f26e1efa456aed9afae71b1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 18 17:52:33 2022 +0200

    s3:g_lock: add some const to the shared array passed via g_lock_dump*()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit bb3dddcdf11e6c2f5319d64bf2ef20636d0ed82f)

commit 208037a7eeab373154773056ac8ecab5f7e49de3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 18 16:06:02 2022 +0200

    lib/util: add unlikely() to SMB_ASSERT()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit bf1dd1a188c096093bedc628a14bb037e3209630)

commit 76bff90824aabf95147470b2f5877a4853a45de8
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 11:43:47 2022 -0700

    s3: smbd: Plumb close_type parameter through close_file_in_loop(), file_close_conn()
    
    Allows close_file_in_loop() to differentiate between SHUTDOWN_CLOSE
    (previously it only used this close type) and ERROR_CLOSE - called
    on error from smbXsrv_tcon_disconnect() in the error path. In that
    case we want to close the fd, but not run any delete-on-close actions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15128
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reivewed-by: Noel Power <npower at samba.org>
    
    Autobuild-User(master): Noel Power <npower at samba.org>
    Autobuild-Date(master): Thu Aug 18 14:10:18 UTC 2022 on sn-devel-184
    
    (cherry picked from commit cf5f7b1489930f6d64c3e3512f116ccf286d4605)

commit 91273a969abcfc717b87e0a019341e78ac77b975
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 11:39:36 2022 -0700

    s3: smbd: Add "enum file_close_type close_type" parameter to file_close_conn().
    
    Not yet used.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15128
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>
    (cherry picked from commit 7005a6354df5522d9f665fb30052c458dfc93124)

commit 5fc9bf0f63cca19a25b26d64175746431e45a47f
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 11:35:29 2022 -0700

    s3: smbd: Add "enum file_close_type close_type" parameter to close_cnum().
    
    Not yet used, but needed so we can differentiate between
    SHUTDOWN_CLOSE and ERROR_CLOSE in smbXsrv_tcon_disconnect()
    if we fail to chdir. In that case we want to close the fd,
    but not run any delete-on-close actions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15128
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>
    (cherry picked from commit 9203d17106c0e55a30813ff1ed76869c7581a343)

commit c47b7479e74944d20a82bc109dcf35aeb099eed0
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Jul 22 16:28:03 2022 +0100

    s3/smbd: Use after free when iterating smbd_server_connection->connections
    
    Change conn_free() to just use a destructor. We now
    catch any other places where we may have forgetten to
    call conn_free() - it's implicit on talloc_free(conn).
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15128
    
    Based on code from Noel Power <noel.power at suse.com>.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>
    
    Autobuild-User(master): Noel Power <npower at samba.org>
    Autobuild-Date(master): Wed Aug 17 09:54:06 UTC 2022 on sn-devel-184
    
    (cherry picked from commit f92bacbe216d2d74ea3ccf3fe0df5c1cc9860996)

commit 0b33961e71a563835241c8beeae379151742e6f1
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 16 13:51:27 2022 -0700

    s3/smbd: Use after free when iterating smbd_server_connection->connections
    
    In SMB2 smbd_smb2_tree_connect() we create a new conn struct
    inside make_connection_smb2() then move the ownership to tcon using:
    
            tcon->compat = talloc_move(tcon, &compat_conn);
    
    so the lifetime of tcon->compat is tied directly to tcon.
    
    Inside smbXsrv_tcon_disconnect() we have:
    
     908                 ok = chdir_current_service(tcon->compat);
     909                 if (!ok) {
     910                         status = NT_STATUS_INTERNAL_ERROR;
     911                         DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): "
     912                                   "chdir_current_service() failed: %s\n",
     913                                   tcon->global->tcon_global_id,
     914                                   tcon->global->share_name,
     915                                   nt_errstr(status)));
     916                         tcon->compat = NULL;
     917                         return status;
     918                 }
     919
     920                 close_cnum(tcon->compat, vuid);
     921                 tcon->compat = NULL;
    
    If chdir_current_service(tcon->compat) fails, we return status without ever having
    called close_cnum(tcon->compat, vuid), leaving the conn pointer left in the linked
    list sconn->connections.
    
    The caller frees tcon and (by ownership) tcon->compat, still leaving the
    freed tcon->compat pointer on the sconn->connections linked list.
    
    When deadtime_fn() fires and walks the sconn->connections list it
    indirects this freed pointer. We must call close_cnum() on error also.
    
    Valgrind trace from Noel Power <noel.power at suse.com> is:
    
    ==6432== Invalid read of size 8
    ==6432==    at 0x52CED3A: conn_lastused_update (conn_idle.c:38)
    ==6432==    by 0x52CEDB1: conn_idle_all (conn_idle.c:54)
    ==6432==    by 0x5329971: deadtime_fn (smb2_process.c:1566)
    ==6432==    by 0x5DA2339: smbd_idle_event_handler (util_event.c:45)
    ==6432==    by 0x685F2F8: tevent_common_invoke_timer_handler (tevent_timed.c:376)
    
    ==6432==  Address 0x19074b88 is 232 bytes inside a block of size 328 free'd
    ==6432==    at 0x4C3451B: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==6432==    by 0x5B38521: _tc_free_internal (talloc.c:1222)
    ==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
    ==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
    ==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
    ==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
    ==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
    ==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
    ==6432==    by 0x5B39463: _tc_free_children_internal (talloc.c:1669)
    ==6432==    by 0x5B38404: _tc_free_internal (talloc.c:1184)
    ==6432==    by 0x5B385C5: _talloc_free_internal (talloc.c:1248)
    ==6432==    by 0x5B3988D: _talloc_free (talloc.c:1792)
    ==6432==    by 0x5349B22: smbd_smb2_flush_send_queue (smb2_server.c:4828)
    
    ==6432==  Block was alloc'd at
    ==6432==    at 0x4C332EF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==6432==    by 0x5B378D9: __talloc_with_prefix (talloc.c:783)
    ==6432==    by 0x5B37A73: __talloc (talloc.c:825)
    ==6432==    by 0x5B37E0C: _talloc_named_const (talloc.c:982)
    ==6432==    by 0x5B3A8ED: _talloc_zero (talloc.c:2421)
    ==6432==    by 0x539873A: conn_new (conn.c:70)
    ==6432==    by 0x532D692: make_connection_smb2 (smb2_service.c:909)
    ==6432==    by 0x5352B5E: smbd_smb2_tree_connect (smb2_tcon.c:344)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15128
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>
    (cherry picked from commit 0bdfb5a5e60df214c088df0782c4a1bcc2a4944a)

commit 0725e1ea851b6e8c37fbdf754e95844bf40c1fcb
Author: Christian Ambach <ambi at samba.org>
Date:   Mon Aug 15 23:30:23 2022 +0200

    s3:utils remove documentation of -l as alias for --long
    
    This was removed in 94fc9ca4c506468ab1907d501c0964d67b9d963c, so remove it from
    the usage output and manpage.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15145
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Wed Aug 17 07:14:21 UTC 2022 on sn-devel-184
    
    (cherry picked from commit 123f1c07c41b40de6a9d53599d3d9a42f1a5e92b)

commit c4c99397c568e1ebd8c67865147a2b01031d0445
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 15 22:45:17 2022 +0200

    s3:smbd: only clear LEASE_READ if there's no read lease is left
    
    If contend_level2_oplocks_begin_default() skips break it's
    own lease, we should not clear SHARE_MODE_LEASE_READ
    in share_mode_data->flags.
    
    Otherwise that lease won't see any lease break notifications
    for writes from other clients (file handles not using the same lease
    key).
    
    So we need to count the number existing read leases (including
    the one with the same lease key) in order to know it's
    safe to clear SMB2_LEASE_READ/SHARE_MODE_LEASE_READ.
    
    Otherwise the next run (likely from another client)
    will get the wrong result from file_has_read_lease().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15148
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Aug 18 19:41:33 UTC 2022 on sn-devel-184
    
    (cherry picked from commit 96e2a82760ea06a89b7387b5cd3e864732afded3)

commit 0529214b3cc63f24cb7401360fc0d35b9c18ed49
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 17 17:07:08 2022 +0200

    s4:torture/smb2: add smb2.lease.v[1,2]_bug_15148
    
    This demonstrates the bug that happens with a
    write to a file handle holding an R lease,
    while there are other openers without any lease.
    
    When one of the other openers writes to the file,
    the R lease of the only lease holder isn't broken to NONE.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15148
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 9e5ff607eb1b9c45c8836d3cff9d51b418740b87)

commit 6ac28f4386867455dfcfc669a75e80f8c49a5386
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 15 10:49:13 2022 +0200

    s3:smbd: share_mode_flags_set() takes SMB2_LEASE_* values
    
    We currently only ever pass SMB2_LEASE_READ and both
    have the same value of 0x1, so for now it's only cosmetic,
    but that will change soon.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15148
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 7592aad4d7a84d0ac66a156a22af3ad77803e55c)

commit e3ee5197a6d7555173ed9372aae839f23667c487
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Mon Aug 22 16:56:46 2022 +1200

    libcli/smb: Set error status if 'iov' pointer is NULL
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15152
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Mon Aug 22 09:03:29 UTC 2022 on sn-devel-184
    
    (cherry picked from commit 75e03ea021afa66842b6e0dea21072b1b8026d58)

commit dee2505716df4b6b08cee42816ed34708e158459
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Mon Aug 22 15:50:02 2022 +1200

    libcli/smb: Ensure we call tevent_req_nterror() on failure
    
    Commit 3594c3ae202688fd8aae5f7f5e20464cb23feea9 added a NULL check for
    'inhdr', but it meant we didn't always call tevent_req_nterror() when we
    should.
    
    Now we handle connection errors. We now also set an error status if the
    NULL check fails.
    
    I noticed this when an ECONNRESET error from a server refusing SMB1
    wasn't handled, and the client subsequently hung in epoll_wait().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15152
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 40d4912d841e6bcd7cd37810ef101d5f89268ee7)

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                      |   1 +
 docs-xml/manpages/net.8.xml       |  14 +--
 lib/util/fault.h                  |   2 +-
 libcli/smb/smbXcli_base.c         |  12 ++-
 selftest/target/Samba3.pm         |   1 +
 selftest/target/Samba4.pm         |   1 +
 source3/include/g_lock.h          |   4 +-
 source3/lib/g_lock.c              |  20 ++--
 source3/locking/leases_util.c     |  17 ----
 source3/locking/locking.c         |  11 --
 source3/locking/proto.h           |   3 -
 source3/locking/share_mode_lock.c |  30 ++++--
 source3/locking/share_mode_lock.h |   4 +
 source3/smbd/conn.c               |  36 +++++--
 source3/smbd/files.c              |  17 ++--
 source3/smbd/open.c               |  34 +++++--
 source3/smbd/proto.h              |   6 +-
 source3/smbd/server.c             |   2 +-
 source3/smbd/smb2_oplock.c        |  16 +--
 source3/smbd/smb2_service.c       |   6 +-
 source3/smbd/smbXsrv_tcon.c       |  11 +-
 source3/smbd/smbd.h               |   1 +
 source3/torture/test_g_lock.c     |  12 +--
 source3/utils/net_g_lock.c        |   2 +-
 source3/utils/net_usershare.c     |  16 +--
 source4/torture/smb2/lease.c      | 208 ++++++++++++++++++++++++++++++++++++++
 26 files changed, 374 insertions(+), 113 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 988c4c66ed8..60e71d4f79e 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -204,6 +204,7 @@ smb.conf changes
   --------------                          -----------     -------
   dns port                                New default     53
   nt hash store				  New parameter   always
+  volume serial number			  New parameter   -1
 
 CHANGES SINCE 4.17.0rc1
 =======================
diff --git a/docs-xml/manpages/net.8.xml b/docs-xml/manpages/net.8.xml
index 557cf0d0883..497a8114057 100644
--- a/docs-xml/manpages/net.8.xml
+++ b/docs-xml/manpages/net.8.xml
@@ -118,7 +118,7 @@
 		</varlistentry>
 
 		<varlistentry>
-		<term>-l|--long</term>
+		<term>--long</term>
 		<listitem><para>
 		When listing data, give more information on each item.
 		</para></listitem>
@@ -2139,8 +2139,8 @@ can create user defined shares on demand using the commands below.
 <simplelist>
 <member>net usershare add sharename path [comment [acl] [guest_ok=[y|n]]] - to add or change a user defined share.</member>
 <member>net usershare delete sharename - to delete a user defined share.</member>
-<member>net usershare info [-l|--long] [wildcard sharename] - to print info about a user defined share.</member>
-<member>net usershare list [-l|--long] [wildcard sharename] - to list user defined shares.</member>
+<member>net usershare info [--long] [wildcard sharename] - to print info about a user defined share.</member>
+<member>net usershare list [--long] [wildcard sharename] - to list user defined shares.</member>
 </simplelist>
 
 </para>
@@ -2209,7 +2209,7 @@ any users currently connected to the deleted share.
 </refsect3>
 
 <refsect3>
-<title>USERSHARE INFO <replaceable>[-l|--long]</replaceable> <replaceable>[wildcard sharename]</replaceable></title>
+<title>USERSHARE INFO <replaceable>[--long]</replaceable> <replaceable>[wildcard sharename]</replaceable></title>
 
 <para>
 Get info on user defined shares owned by the current user matching the given pattern, or all users.
@@ -2219,7 +2219,7 @@ Get info on user defined shares owned by the current user matching the given pat
 net usershare info on its own dumps out info on the user defined shares that were
 created by the current user, or restricts them to share names that match the given
 wildcard pattern ('*' matches one or more characters, '?' matches only one character).
-If the '-l' or '--long' option is also given, it prints out info on user defined
+If the '--long' option is also given, it prints out info on user defined
 shares created by other users.
 </para>
 
@@ -2239,7 +2239,7 @@ modified by the "net usershare add" command.
 </refsect3>
 
 <refsect3>
-<title>USERSHARE LIST <replaceable>[-l|--long]</replaceable> <replaceable>wildcard sharename</replaceable></title>
+<title>USERSHARE LIST <replaceable>[--long]</replaceable> <replaceable>wildcard sharename</replaceable></title>
 
 <para>
 List all the user defined shares owned by the current user matching the given pattern, or all users.
@@ -2249,7 +2249,7 @@ List all the user defined shares owned by the current user matching the given pa
 net usershare list on its own list out the names of the user defined shares that were
 created by the current user, or restricts the list to share names that match the given
 wildcard pattern ('*' matches one or more characters, '?' matches only one character).
-If the '-l' or '--long' option is also given, it includes the names of user defined
+If the '--long' option is also given, it includes the names of user defined
 shares created by other users.
 </para>
 
diff --git a/lib/util/fault.h b/lib/util/fault.h
index f3b1666a172..6aceaf6dabc 100644
--- a/lib/util/fault.h
+++ b/lib/util/fault.h
@@ -33,7 +33,7 @@
 #ifdef _SAMBA_DEBUG_H
 #define SMB_ASSERT(b) \
 do { \
-	if (!(b)) { \
+	if (unlikely(!(b))) { \
 		DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
 			 __FILE__, __LINE__, #b)); \
 		smb_panic("assert failed: " #b); \
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index d2f55966c3a..c5d13bd5837 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -4469,7 +4469,11 @@ static void smbXcli_negprot_smb1_done(struct tevent_req *subreq)
 				  NULL, /* pinbuf */
 				  expected, ARRAY_SIZE(expected));
 	TALLOC_FREE(subreq);
-	if (inhdr == NULL || tevent_req_nterror(req, status)) {
+	if (tevent_req_nterror(req, status)) {
+		return;
+	}
+	if (inhdr == NULL) {
+		tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
 		return;
 	}
 
@@ -5009,7 +5013,11 @@ static void smbXcli_negprot_smb2_done(struct tevent_req *subreq)
 
 	status = smb2cli_req_recv(subreq, state, &iov,
 				  expected, ARRAY_SIZE(expected));
-	if (tevent_req_nterror(req, status) || iov == NULL) {
+	if (tevent_req_nterror(req, status)) {
+		return;
+	}
+	if (iov == NULL) {
+		tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
 		return;
 	}
 
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index b12011a71fa..a5392fbf26c 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2772,6 +2772,7 @@ sub provision($$)
 	panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
 	smbd:suicide mode = yes
 	smbd:FSCTL_SMBTORTURE = yes
+	smbd:validate_oplock_types = yes
 
 	client min protocol = SMB2_02
 	server min protocol = SMB2_02
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 1762ae4ae79..e5ae57cb7fc 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -778,6 +778,7 @@ sub provision_raw_step1($$)
 	panic action = $RealBin/gdb_backtrace \%d
 	smbd:suicide mode = yes
 	smbd:FSCTL_SMBTORTURE = yes
+	smbd:validate_oplock_types = yes
 	wins support = yes
 	server role = $ctx->{server_role}
 	server services = +echo $services
diff --git a/source3/include/g_lock.h b/source3/include/g_lock.h
index 3a94879d209..749cb57ed45 100644
--- a/source3/include/g_lock.h
+++ b/source3/include/g_lock.h
@@ -71,7 +71,7 @@ struct tevent_req *g_lock_dump_send(
 	TDB_DATA key,
 	void (*fn)(struct server_id exclusive,
 		   size_t num_shared,
-		   struct server_id *shared,
+		   const struct server_id *shared,
 		   const uint8_t *data,
 		   size_t datalen,
 		   void *private_data),
@@ -81,7 +81,7 @@ NTSTATUS g_lock_dump(struct g_lock_ctx *ctx,
 		     TDB_DATA key,
 		     void (*fn)(struct server_id exclusive,
 				size_t num_shared,
-				struct server_id *shared,
+				const struct server_id *shared,
 				const uint8_t *data,
 				size_t datalen,
 				void *private_data),
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index d683c4ddee6..8a07949b3d9 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -1210,7 +1210,7 @@ struct g_lock_dump_state {
 	TDB_DATA key;
 	void (*fn)(struct server_id exclusive,
 		   size_t num_shared,
-		   struct server_id *shared,
+		   const struct server_id *shared,
 		   const uint8_t *data,
 		   size_t datalen,
 		   void *private_data);
@@ -1238,12 +1238,14 @@ static void g_lock_dump_fn(TDB_DATA key, TDB_DATA data,
 		return;
 	}
 
-	shared = talloc_array(
-		state->mem_ctx, struct server_id, lck.num_shared);
-	if (shared == NULL) {
-		DBG_DEBUG("talloc failed\n");
-		state->status = NT_STATUS_NO_MEMORY;
-		return;
+	if (lck.num_shared > 0) {
+		shared = talloc_array(
+			state->mem_ctx, struct server_id, lck.num_shared);
+		if (shared == NULL) {
+			DBG_DEBUG("talloc failed\n");
+			state->status = NT_STATUS_NO_MEMORY;
+			return;
+		}
 	}
 
 	for (i=0; i<lck.num_shared; i++) {
@@ -1265,7 +1267,7 @@ static void g_lock_dump_fn(TDB_DATA key, TDB_DATA data,
 NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, TDB_DATA key,
 		     void (*fn)(struct server_id exclusive,
 				size_t num_shared,
-				struct server_id *shared,
+				const struct server_id *shared,
 				const uint8_t *data,
 				size_t datalen,
 				void *private_data),
@@ -1300,7 +1302,7 @@ struct tevent_req *g_lock_dump_send(
 	TDB_DATA key,
 	void (*fn)(struct server_id exclusive,
 		   size_t num_shared,
-		   struct server_id *shared,
+		   const struct server_id *shared,
 		   const uint8_t *data,
 		   size_t datalen,
 		   void *private_data),
diff --git a/source3/locking/leases_util.c b/source3/locking/leases_util.c
index cb62bffbd7d..9ae4081cd7b 100644
--- a/source3/locking/leases_util.c
+++ b/source3/locking/leases_util.c
@@ -71,23 +71,6 @@ uint32_t fsp_lease_type(struct files_struct *fsp)
 	return fsp->lease_type;
 }
 
-static uint32_t lease_type_is_exclusive(uint32_t lease_type)
-{
-	if ((lease_type & (SMB2_LEASE_READ | SMB2_LEASE_WRITE)) ==
-	    (SMB2_LEASE_READ | SMB2_LEASE_WRITE)) {
-		return true;
-	}
-
-	return false;
-}
-
-bool fsp_lease_type_is_exclusive(struct files_struct *fsp)
-{
-	uint32_t lease_type = fsp_lease_type(fsp);
-
-	return lease_type_is_exclusive(lease_type);
-}
-
 const struct GUID *fsp_client_guid(const files_struct *fsp)
 {
 	return &fsp->conn->sconn->client->global->client_guid;
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index b002e80fee4..befdc10f369 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -468,17 +468,6 @@ char *share_mode_str(TALLOC_CTX *ctx, int num,
 		 (unsigned int)e->name_hash);
 }
 
-/*******************************************************************
- Fetch a share mode where we know one MUST exist. This call reference
- counts it internally to allow for nested lock fetches.
-********************************************************************/
-
-struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
-						     const struct file_id id)
-{
-	return get_share_mode_lock(mem_ctx, id, NULL, NULL, NULL);
-}
-
 struct rename_share_filename_state {
 	struct share_mode_lock *lck;
 	struct messaging_context *msg_ctx;
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index d6e7a54a766..7fc177d7aa6 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -128,8 +128,6 @@ void locking_close_file(files_struct *fsp,
 char *share_mode_str(TALLOC_CTX *ctx, int num,
 		     const struct file_id *id,
 		     const struct share_mode_entry *e);
-struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
-						     struct file_id id);
 
 bool rename_share_filename(struct messaging_context *msg_ctx,
 			struct share_mode_lock *lck,
@@ -212,7 +210,6 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
 /* The following definitions come from locking/leases_util.c */
 uint32_t map_oplock_to_lease_type(uint16_t op_type);
 uint32_t fsp_lease_type(struct files_struct *fsp);
-bool fsp_lease_type_is_exclusive(struct files_struct *fsp);
 const struct GUID *fsp_client_guid(const files_struct *fsp);
 
 #endif /* _LOCKING_PROTO_H_ */
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index dd19c53024b..75912ec5dc8 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -468,7 +468,7 @@ struct locking_tdb_data_fetch_state {
 static void locking_tdb_data_fetch_fn(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data)
@@ -768,7 +768,7 @@ struct get_static_share_mode_data_state {
 static void get_static_share_mode_data_fn(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data)
@@ -1005,6 +1005,17 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
 	return 0;
 }
 
+/*******************************************************************
+ Fetch a share mode where we know one MUST exist. This call reference
+ counts it internally to allow for nested lock fetches.
+********************************************************************/
+
+struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
+						     const struct file_id id)
+{
+	return get_share_mode_lock(mem_ctx, id, NULL, NULL, NULL);
+}
+
 struct share_mode_do_locked_state {
 	TDB_DATA key;
 	void (*fn)(const uint8_t *buf,
@@ -1017,7 +1028,7 @@ struct share_mode_do_locked_state {
 static void share_mode_do_locked_fn(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data)
@@ -1324,7 +1335,7 @@ struct fetch_share_mode_unlocked_state {
 static void fetch_share_mode_unlocked_parser(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data)
@@ -1395,7 +1406,7 @@ struct fetch_share_mode_state {
 static void fetch_share_mode_fn(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data);
@@ -1460,7 +1471,7 @@ struct tevent_req *fetch_share_mode_send(TALLOC_CTX *mem_ctx,
 static void fetch_share_mode_fn(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data)
@@ -1564,7 +1575,7 @@ struct share_mode_forall_state {
 static void share_mode_forall_dump_fn(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data)
@@ -1782,6 +1793,7 @@ bool set_share_mode(struct share_mode_lock *lck,
 		    uid_t uid,
 		    uint64_t mid,
 		    uint16_t op_type,
+		    const struct smb2_lease_key *lease_key,
 		    uint32_t share_access,
 		    uint32_t access_mask)
 {
@@ -1839,7 +1851,7 @@ bool set_share_mode(struct share_mode_lock *lck,
 	if (op_type == LEASE_OPLOCK) {
 		const struct GUID *client_guid = fsp_client_guid(fsp);
 		e.client_guid = *client_guid;
-		e.lease_key = fsp->lease->lease.lease_key;
+		e.lease_key = *lease_key;
 	}
 
 	ok = share_mode_entry_put(&e, &e_buf);
@@ -2108,7 +2120,7 @@ struct share_mode_count_entries_state {
 static void share_mode_count_entries_fn(
 	struct server_id exclusive,
 	size_t num_shared,
-	struct server_id *shared,
+	const struct server_id *shared,
 	const uint8_t *data,
 	size_t datalen,
 	void *private_data)
diff --git a/source3/locking/share_mode_lock.h b/source3/locking/share_mode_lock.h
index bd4e98ccecd..4f47b6fbcbe 100644
--- a/source3/locking/share_mode_lock.h
+++ b/source3/locking/share_mode_lock.h
@@ -26,6 +26,7 @@ struct share_mode_lock;
 struct share_mode_entry;
 struct smb_filename;
 struct files_struct;
+struct smb2_lease_key;
 
 bool locking_init(void);
 bool locking_init_readonly(void);
@@ -37,6 +38,8 @@ struct share_mode_lock *get_share_mode_lock(
 	const char *servicepath,
 	const struct smb_filename *smb_fname,
 	const struct timespec *old_write_time);
+struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
+						     struct file_id id);
 
 bool del_share_mode(struct share_mode_lock *lck,
 		    struct files_struct *fsp);
@@ -52,6 +55,7 @@ bool set_share_mode(
 	uid_t uid,
 	uint64_t mid,
 	uint16_t op_type,
+	const struct smb2_lease_key *lease_key,
 	uint32_t share_access,
 	uint32_t access_mask);
 bool reset_share_mode_entry(
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index 044242d5697..776d7af4c12 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -24,6 +24,25 @@
 #include "smbd/globals.h"
 #include "lib/util/bitmap.h"
 
+static void conn_free_internal(connection_struct *conn);
+
+/****************************************************************************
+ * Remove a conn struct from conn->sconn->connections
+ * if not already done.
+****************************************************************************/
+
+static int conn_struct_destructor(connection_struct *conn)
+{
+        if (conn->sconn != NULL) {
+		DLIST_REMOVE(conn->sconn->connections, conn);
+		SMB_ASSERT(conn->sconn->num_connections > 0);
+		conn->sconn->num_connections--;
+		conn->sconn = NULL;
+	}
+	conn_free_internal(conn);
+	return 0;
+}
+
 /****************************************************************************
  Return the number of open connections.
 ****************************************************************************/
@@ -115,6 +134,11 @@ connection_struct *conn_new(struct smbd_server_connection *sconn)
 	DLIST_ADD(sconn->connections, conn);
 	sconn->num_connections++;
 
+	/*
+	 * Catches the case where someone forgets to call
+	 * conn_free().
+	 */
+	talloc_set_destructor(conn, conn_struct_destructor);
 	return conn;
 }
 
@@ -212,7 +236,6 @@ static void conn_free_internal(connection_struct *conn)
 	free_namearray(conn->aio_write_behind_list);
 
 	ZERO_STRUCTP(conn);
-	talloc_destroy(conn);
 }
 
 /****************************************************************************
@@ -221,16 +244,7 @@ static void conn_free_internal(connection_struct *conn)
 
 void conn_free(connection_struct *conn)
 {
-	if (conn->sconn == NULL) {
-		conn_free_internal(conn);
-		return;
-	}
-
-	DLIST_REMOVE(conn->sconn->connections, conn);
-	SMB_ASSERT(conn->sconn->num_connections > 0);
-	conn->sconn->num_connections--;
-
-	conn_free_internal(conn);
+	TALLOC_FREE(conn);
 }
 
 /*
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index a6c41f2b928..b494a8b789a 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -1258,7 +1258,8 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx,
 	return NT_STATUS_OK;
 }
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list