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

Karolin Seeger kseeger at samba.org
Thu May 14 09:34:07 UTC 2020


The branch, v4-12-test has been updated
       via  f1c602ea9c9 docs-xml: Fix usernames in pam_winbind manpages
       via  8d8549f571d libsmb: Protect cli_oem_change_password() from rprcnt<2
       via  054e7de5b4b libsmb: Protect cli_RNetServerEnum against rprcnt<6
       via  8dc3d1e4fb7 libsmb: Protect cli_RNetShareEnum() against rprcnt<6
       via  848a1ad7c15 libsmb: Fix indentation in cli_RNetShareEnum()
       via  136a83c5a9f s3/locking: prime flags in a fresh sharemode data object
       via  6b650659ef6 smbd: fix for bug 14375
       via  2b1525ca030 smbd: make conflicting_access available to other functions
       via  5c76c6f2d60 s4/torture: reproducer for bug 14375
       via  31f91b59365 selftest: split a knownfail entry
       via  20d61b9c543 s3: RPC: Don't crash on trying to talloc_free(-1) if smb_iconv_open_ex() fails.
       via  43bc61b1c79 vfs_io_uring: retry after a short writes in vfs_io_uring_pwrite_completion()
       via  0baa1036c6f vfs_io_uring: retry after a short read in vfs_io_uring_pread_completion()
       via  8ed9668cefb vfs_io_uring: protect vfs_io_uring_fsync_completion() against invalid results
       via  9b1281a7062 vfs_io_uring: protect vfs_io_uring_pwrite_completion() against invalid results
       via  dadb1698693 vfs_io_uring: protect vfs_io_uring_pread_completion() against invalid results
       via  0c3523d83cf vfs_io_uring: split out a vfs_io_uring_pwrite_submit() function
       via  bd41e956fcd vfs_io_uring: split out a vfs_io_uring_pread_submit() function
       via  adac9ae7017 vfs_io_uring: split out a vfs_io_uring_request_submit() function
       via  2ab5eaebc4c vfs_io_uring: avoid stack recursion of vfs_io_uring_queue_run()
       via  efdcf63d939 vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pwrite_send()
       via  49847bada15 vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pread_send()
       via  2588cf0d711 vfs_io_uring: move error handling out of vfs_io_uring_fsync_recv()
       via  d9e2acf9445 vfs_io_uring: move error handling out of vfs_io_uring_pwrite_recv()
       via  3dc60c54090 vfs_io_uring: move error handling out of vfs_io_uring_pread_recv()
       via  a15861f6dd3 vfs_io_uring: introduce vfs_io_uring_request->completion_fn()
       via  5acc7ee7681 vfs_io_uring: replace vfs_io_uring_request->state with _tevent_req_data()
       via  7130e37d8f2 vfs_io_uring: fix the prefix for parametric options from 'vfs_io_uring' to 'io_uring'
       via  6b347a406de s3: VFS: default. Change pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE_SEND() to protect against short writes.
       via  00e0cf4241b s3: VFS: default. Change pread() -> sys_pread_full() in SMB_VFS_PREAD_SEND() to protect against short reads.
       via  838a52fa25e s3: VFS: default. Change sys_pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE() to protect against short writes.
       via  aff82c00a05 s3: VFS: default. Change sys_pread() -> sys_pread_full() in SMB_VFS_PREAD() to protect against short reads.
       via  b60d60bd505 s3: VFS: aio_fork: Change sys_pwrite() -> sys_pwrite_full() to protect against short writes.
       via  f6baeeece8f s3: VFS: aio_fork: Change sys_pread() -> sys_pread_full() to protect against short reads.
       via  0d29e442b15 smbd: add vfs_valid_{pread,pwrite}_range() checks where needed
       via  3197bd27b35 s3:smbd: add vfs_valid_{pread,pwrite}_range() helper functions
       via  9b0aba40e83 s3:smbd: handle 0 length writes as no-op.
       via  f3114c72a3f smb2_server: fix smbd_smb2_request_verify_sizes() for SMB2_OP_WRITE
       via  6c51b56282b lib: util: Add sys_pwrite_full().
       via  442fa5a9782 lib: util: Add sys_pread_full().
       via  b171d8161d2 lib: util: Add sys_valid_io_range()
       via  b50874309d2 s4:torture: add tests to test the SMB2 read/write offset/length boundaries
       via  392863d3d51 vfs_shadow_copy2: implement case canonicalisation in shadow_copy2_get_real_filename()
       via  105ed96add2 s3/lib: add is_gmt_token()
       via  6bf40566d88 smbd: make get_real_filename_full_scan() public
       via  3cedb9c9594 CI: add two tests for shadow_copy2 VFS module
       via  f9f03c0a6f5 ldb: Bump version to 2.1.3
       via  39742f3ffe8 lib ldb: lmdb init var before calling mdb_reader_check
       via  d294eb47296 lib ldb: lmdb clear stale readers on write txn start
       via  2b8faefabb4 ldb tests: Confirm lmdb free list handling
       via  f6468de046e lib:util: Fix smbclient -l basename dir
       via  6bc407b2860 Add a test for smbclient -l basename
      from  21cf1419c54 s3: pass DCE RPC handle type to create_policy_hnd

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


- Log -----------------------------------------------------------------
commit f1c602ea9c9073daa050bf6cb2101c0b7f5e7e12
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Apr 28 17:25:35 2020 +0200

    docs-xml: Fix usernames in pam_winbind manpages
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14358
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Wed Apr 29 09:44:55 UTC 2020 on sn-devel-184
    
    (cherry picked from commit 3abd92d7824e803f1ff53425088ebee30b58894b)
    
    Autobuild-User(v4-12-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-12-test): Thu May 14 09:33:57 UTC 2020 on sn-devel-184

commit 8d8549f571d13a241b9811b90ac451d00cb6ada9
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 2 15:18:07 2020 +0200

    libsmb: Protect cli_oem_change_password() from rprcnt<2
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Tue May  5 17:12:04 UTC 2020 on sn-devel-184
    
    (cherry picked from commit f80c97cb8da64f3cd9904e2e1fd43c29b691166d)

commit 054e7de5b4b090e1d4579184d7137824a56ac598
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 2 15:10:14 2020 +0200

    libsmb: Protect cli_RNetServerEnum against rprcnt<6
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit ce8b70df7bd63e96723b8e8dc864f1690f5fad7b)

commit 8dc3d1e4fb7f25d3be238dba2652201281b4cfc6
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 2 14:59:07 2020 +0200

    libsmb: Protect cli_RNetShareEnum() against rprcnt<6
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 4a9fe4efefa67d6f24efcbe29722a43fc4859fdc)

commit 848a1ad7c159442d3ad51297fb12dd8c2f2d110e
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 2 14:54:01 2020 +0200

    libsmb: Fix indentation in cli_RNetShareEnum()
    
    Also remove a level of indentation with a "goto done;"
    
    Best review with "git show -b", almost no code change
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit ae91d67a247424d4ddc89230f52365558d6ff402)

commit 136a83c5a9faf9a5d32c4b2f43559aef984fe09d
Author: Ralph Boehme <slow at samba.org>
Date:   Mon May 11 11:35:04 2020 +0200

    s3/locking: prime flags in a fresh sharemode data object
    
    This is needed to prime the logic in share_mode_flags_restrict() for the
    following scenario:
    
    * (First) CREATE on a file with FILE_SHARE_NONE and
      access_mask=FILE_READ_ATTRIBUTES (a stat-open).
    
    * share_mode_flags_restrict() gets called with
    
        share_mode_flags_restrict(flags=0,
                                  access_mask=0x80,
                                  share_mode=0,
                                  lease_type=UINT32_MAX)
    
      and returns a value where none of the FILE_SHARE_* flags is set.
    
    As a result share_mode_data.flags doesn't reflect the share-modes in effect.
    
    This doesn't change any current visible behaviour outside of open_mode_check(),
    but it avoids calling share_mode_forall_entries() in open_mode_check_fn().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14375
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Tue May 12 19:52:48 UTC 2020 on sn-devel-184
    
    (cherry picked from commit bf04ca5658dcf7d7cdf5f718eec0e5e21f9a0d64)

commit 6b650659ef6dc037e446879e19773159d04e9cbe
Author: Ralph Boehme <slow at samba.org>
Date:   Sat May 9 15:13:54 2020 +0200

    smbd: fix for bug 14375
    
    ... with many thanks to an enthusiastic Samba user from Poland for helping to
    track this down.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14375
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 59f55aa083ce2d87ad6f43dc941f725c79c8ec59)

commit 2b1525ca030f44c558aaacbf630a42c0828d4198
Author: Ralph Boehme <slow at samba.org>
Date:   Mon May 11 13:42:39 2020 +0200

    smbd: make conflicting_access available to other functions
    
    The next commit adds more users of conflicting_access.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14375
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 3f37008edaa31c3bc8c9b291dc1af00550ce4f9a)

commit 5c76c6f2d600d1b1bca6189f2925cc5353198c15
Author: Ralph Boehme <slow at samba.org>
Date:   Sat May 9 15:29:15 2020 +0200

    s4/torture: reproducer for bug 14375
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14375
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 2ace545a6378970ca3d8a1a30d4c7da66aaa9721)

commit 31f91b59365f4a61b044b48cad101cbd15a57335
Author: Ralph Boehme <slow at samba.org>
Date:   Mon May 11 15:56:58 2020 +0200

    selftest: split a knownfail entry
    
    Lists the two existing subtests indidivually in preparation of adding a third
    that is going to pass against ad_dc_ntvfs.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14375
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit c83ef1d90573fdc9db3d0acbc1335a5b2325f5c5)

commit 20d61b9c543944c1d292d7829a6ce14a3f31d491
Author: Jeremy Allison <jra at samba.org>
Date:   Wed May 6 12:36:00 2020 -0700

    s3: RPC: Don't crash on trying to talloc_free(-1) if smb_iconv_open_ex() fails.
    
    Assign output from smb_iconv_open_ex() to a temporary
    handle. Only assign to mds_ctx->[handles] if correctly
    opened otherwise we end up trying to call smb_iconv_close(-1).
    
    MacOSX Catalina triggers this.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14372
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Thu May  7 18:03:16 UTC 2020 on sn-devel-184
    
    (cherry picked from commit 14df5d20a8ec00bf8627732284f427f6463177e3)

commit 43bc61b1c799470bb87f99ad4401aa77fb17e901
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 13:30:17 2020 +0200

    vfs_io_uring: retry after a short writes in vfs_io_uring_pwrite_completion()
    
    We need to be prepared for short writes from the kernel depending on
    the state of the page cache.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 0f01b10679c06dbd28da72ca6c6280ddf81672ba)

commit 0baa1036c6f5fbf5ed2334f6f6655c64363eaf41
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 13:30:17 2020 +0200

    vfs_io_uring: retry after a short read in vfs_io_uring_pread_completion()
    
    We need to be prepared for short reads from the kernel depending on
    the state of the page cache. Windows and Mac clients don't
    expect short reads for files, so we need to retry ourself.
    
    For the future we may be able to play with some io_uring flags
    in order to avoid the retries in userspace, but for now we just fix
    the data corruption bug...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 42e77c4cf245d8420641d216d1abefe81f7a3b79)

commit 8ed9668cefbf09ca7d985ce82cfd10bf9d00dfab
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 11:38:56 2020 +0200

    vfs_io_uring: protect vfs_io_uring_fsync_completion() against invalid results
    
    We should never get back a value > 0.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit c57a731c4ce395fd710f0b066cd6f1b72223ae07)

commit 9b1281a7062537f46c0e33ad040965d3c6975353
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 11:38:56 2020 +0200

    vfs_io_uring: protect vfs_io_uring_pwrite_completion() against invalid results
    
    We should never get more acked than we asked for.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 283f96872237517f0b3bc4e63e8d3c482ecd5fa4)

commit dadb169869375221c04478dbf19f95f100096530
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 11:38:56 2020 +0200

    vfs_io_uring: protect vfs_io_uring_pread_completion() against invalid results
    
    We should never get back more than we asked for.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit f085dbf8b2bed2695e0065a5bf4523232cb532c7)

commit 0c3523d83cf9612602a9487686b635c0f394b0cd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 11:17:51 2020 +0200

    vfs_io_uring: split out a vfs_io_uring_pwrite_submit() function
    
    This can be reused when we add handling for short writes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 2f6abb00b0daeb4de9ad0aea1b5c56559391aef9)

commit bd41e956fcd409bf121205084469fe8d2923b9c7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 11:17:51 2020 +0200

    vfs_io_uring: split out a vfs_io_uring_pread_submit() function
    
    This can be reused when we add handling for short reads.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9de4f8be1dc8b4274891016191a5ca1f724e08b3)

commit adac9ae7017e5c31aca91d54139788b8603c867f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 11:17:51 2020 +0200

    vfs_io_uring: split out a vfs_io_uring_request_submit() function
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit ab89b8e75354c5fd571985e924e1ccbec99de990)

commit 2ab5eaebc4c6f7bbffc35aa592f8aa09c8246f2d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 21:29:53 2020 +0200

    vfs_io_uring: avoid stack recursion of vfs_io_uring_queue_run()
    
    Instead we remember if recursion was triggered and jump to
    the start of the function again from the end.
    
    This should make it safe to be called from the completion_fn().
    
    This is hideously complex stuff, so document the hell
    out of it.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit f96f45c9ba8d4c8fa4026c22ac4201d66335e5c4)

commit efdcf63d939c5ab4dd426c97e39c984ec39cb82e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 13:17:05 2020 +0200

    vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pwrite_send()
    
    This makes the follow up commits easier as we don't have to care
    about overflows.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 388bc2e6e44470ea4043ecb22750e241145355d2)

commit 49847bada158a1a530c6055c475b6a7d1a2300a5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 13:17:05 2020 +0200

    vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pread_send()
    
    This makes the follow up commits easier as we don't have to care
    about overflows.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 5005ae3fb24018e370ae60cc23c5e9cfe8357bc9)

commit 2588cf0d711147f256bb485f152b8ff91c632478
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 10:52:52 2020 +0200

    vfs_io_uring: move error handling out of vfs_io_uring_fsync_recv()
    
    We should do that as early as possible and that's in
    vfs_io_uring_fsync_completion().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 40be2232a44a86cb5dfdda330801e615826408ba)

commit d9e2acf94459c1ce66229ed4d6f57d35f662a409
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 10:52:52 2020 +0200

    vfs_io_uring: move error handling out of vfs_io_uring_pwrite_recv()
    
    We should do that as early as possible and that's in
    vfs_io_uring_pwrite_completion().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit a51969b8c7e6e49c0d3b776d897aea4f309f8678)

commit 3dc60c5409096a35ec1742bf42b7f84099181fba
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 10:52:52 2020 +0200

    vfs_io_uring: move error handling out of vfs_io_uring_pread_recv()
    
    We should do that as early as possible and that's in
    vfs_io_uring_pread_completion().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit a1487067a6c9df3136fd5d4d16dda4c0f63cb662)

commit a15861f6dd39400ff08db8479f84caa29a0d979d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 10:42:59 2020 +0200

    vfs_io_uring: introduce vfs_io_uring_request->completion_fn()
    
    We'll need to add more logic than a simple _tevent_req_done()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 456533c9cfc332d3a83ea03a6f969b0d64ccbeb6)

commit 5acc7ee76819c69c0aa0bb83233a43c8ee76ecf5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 10:39:52 2020 +0200

    vfs_io_uring: replace vfs_io_uring_request->state with _tevent_req_data()
    
    We don't need a direct pointer to the state...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit f78e98e0226fe70899b613e0aa5c804d8458bdb0)

commit 7130e37d8f29b1071d5a19361f5fef156a458a6c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed May 6 03:05:47 2020 -0700

    vfs_io_uring: fix the prefix for parametric options from 'vfs_io_uring' to 'io_uring'
    
    This is what the manpage describes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit fadc7043a71b409ad60a1a4076a7f88f379d2056)

commit 6b347a406de873a5703b99f46ae490bf2ae2cec6
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:48:49 2020 -0700

    s3: VFS: default. Change pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE_SEND() to protect against short writes.
    
    Note that as sys_pwrite_full() deals with the EINTR case
    we can remove the do {} while loop here.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 801c06f4c9400343b72cad998086288931f7c6b3)

commit 00e0cf4241be4142316882d70e03a2b20258c224
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:45:10 2020 -0700

    s3: VFS: default. Change pread() -> sys_pread_full() in SMB_VFS_PREAD_SEND() to protect against short reads.
    
    Note that as sys_pread_full() deals with the EINTR case
    we can remove the do {} while loop here.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit bf2e546be38abfc77cf40e0b0fef42937696dcde)

commit 838a52fa25ebf7e399e086eed6be4b5c0f3db743
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:44:26 2020 -0700

    s3: VFS: default. Change sys_pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE() to protect against short writes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit ca8c3619f657dc38db7cb248f1a657f5bfe20757)

commit aff82c00a056c1cf4b6f9fe59807d579e6fac679
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:43:34 2020 -0700

    s3: VFS: default. Change sys_pread() -> sys_pread_full() in SMB_VFS_PREAD() to protect against short reads.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 7daa79908b6a0362db30276b3b6f0db176b6ae3c)

commit b60d60bd5052e2aac1c87eaf94b3b62c37323762
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:42:53 2020 -0700

    s3: VFS: aio_fork: Change sys_pwrite() -> sys_pwrite_full() to protect against short writes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 20ee8b03bbe5bef4ea968170808e3c4c9d22318e)

commit f6baeeece8f2ceec232d32c94e8076979782ca3f
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:42:10 2020 -0700

    s3: VFS: aio_fork: Change sys_pread() -> sys_pread_full() to protect against short reads.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 60f590000d545292760018694deb34a7cc4ded6d)

commit 0d29e442b159ed1123356c8c1ced29b8282903a9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon May 11 18:18:24 2020 +0200

    smbd: add vfs_valid_{pread,pwrite}_range() checks where needed
    
    I checked all callers of SMB_VFS_PWRITE[_SEND](),
    all callers of SMB_VFS_PREAD[_SEND]() and also
    places where we append to the file and allocate
    more space.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6fa753a1a67d563cd22d0cad73ae15ee267512fc)

commit 3197bd27b359746aaa70fa80b1971fc42cc96c13
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon May 11 22:00:37 2020 +0200

    s3:smbd: add vfs_valid_{pread,pwrite}_range() helper functions
    
    These implement the SMB2 visible behavior of the [MS-FSA]
    2.1.5.2 Server Requests a Read and 2.1.5.3 Server Requests a Write
    constraints. Note that offset < 0 is not allowed over SMB.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 70fa4b884d2c22669984c25fe757c2fc528f7331)

commit 9b0aba40e836b7686c609fa6b5ab2e95ebb48e48
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon May 11 18:18:24 2020 +0200

    s3:smbd: handle 0 length writes as no-op.
    
    They should never touch the SMB_VFS layer
    and they never trigger an DISK_FULL error.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit ba68f21286c2c2f1fef8bf8c9cd500a622077887)

commit f3114c72a3fd3c12d8b49d323757134ec34fd971
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon May 11 18:18:24 2020 +0200

    smb2_server: fix smbd_smb2_request_verify_sizes() for SMB2_OP_WRITE
    
    Writes with a length of 0 are allowed.
    
    The readfile related check we had before was not really useful
    as min_dyn_len can only every be 0 or 1 (and for SMB2_OP_WRITE it's
    always 1). So we checked
      if (unread_bytes > 0) {
         if (unread_bytes < 1) {
           return error;
         }
      }
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit a6eee38ba2f89280676f0a32d26745afd95b551c)

commit 6c51b56282bf4b34433dd5718a75d2fa7d85adf1
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:34:32 2020 -0700

    lib: util: Add sys_pwrite_full().
    
    A pwrite wrapper that will deal with EINTR and never return a short
    write unless the file system returns an error. Copes with the
    unspecified edge condition of pwrite returning zero by changing
    the return to -1, errno = ENOSPC.
    
    Thread-safe so may be used as a replacement for pwrite
    inside pwrite_do() thread functions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 3ba7a89cea85d134eacf1e624e011fe6f66146fc)

commit 442fa5a97829c0a8bb293ffe224c7b08c743f8ad
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 7 12:32:48 2020 -0700

    lib: util: Add sys_pread_full().
    
    A pread wrapper that will deal with EINTR and never return a short
    read unless pread returns zero meaning EOF.
    
    Thread-safe so may be used as a replacement for pread
    inside pread_do() thread functions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 36af33bf9fcdf93fce5ef1520fcb7ddbb07b355e)

commit b171d8161d2823f79676fb26baa136bc5bafbe1b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 8 13:06:54 2020 +0200

    lib: util: Add sys_valid_io_range()
    
    This implements the contraints of
    [MS-FSA] 2.1.5.2 Server Requests a Read.
    
    The special handling of [MS-FSA] 2.1.5.3 Server Requests a Write
    with offset < 0, should be handled by higher layers!
    Which means the check can also be used for writes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e02cbd5c3ea6903d2b7b43c3193b8662d029ecdd)

commit b50874309d2d133afc24895adc51aef6a7734c66
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon May 11 12:37:41 2020 +0200

    s4:torture: add tests to test the SMB2 read/write offset/length boundaries
    
    [MS-FSA] 2.1.5.2 Server Requests a Read and
    2.1.5.3 Server Requests a Write define some contraints.
    
    These tests demonstrate that ((int64_t)offset) < 0) is
    not allowed for both reads and writes for SMB.
    Also the special case for writes at offset -2 is not possible
    nor the append mode with offset < 0.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 54de0e4a3e46a53db5262963e64b109c567554a1)

commit 392863d3d510156b8cc63a403b19e688d1a7a464
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Apr 23 16:10:23 2020 +0200

    vfs_shadow_copy2: implement case canonicalisation in shadow_copy2_get_real_filename()
    
    unix_convert() can't do this for us in snapdirseverywhere mode, so we do it
    ourselves.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14350
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    (Similar to commit a3d1ac2a597e2441d6855db566306298ae5db99b)

commit 105ed96add2e0506abcff0d7a480f5942f1e8c72
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Apr 27 14:38:28 2020 +0200

    s3/lib: add is_gmt_token()
    
    This is not present in master as master has been converted to use struct
    smb_filename.twrp instead of @GMT string tokens as part of the path.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>

commit 6bf40566d88957423c31cf17014b45876420aefd
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Apr 23 16:09:16 2020 +0200

    smbd: make get_real_filename_full_scan() public
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14350
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (backported from commit aa5f19ddf1dec1ac4386441929bca94727f30ee6)
    [Conflicts: source3/smbd/proto.h: more functions are missing in 4.12]

commit 3cedb9c9594e3958be378dfbc0ec615905c9440a
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Apr 21 13:06:03 2020 +0200

    CI: add two tests for shadow_copy2 VFS module
    
    Note that the test "fetch a previous version of a regular file via non-canonical
    basepath" doesn't fail by "luck" because it runs into the "creating file"
    optimisation in unix_convert().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14350
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6557777c86d72a185b3fe4061a8b5791fd748924)

commit f9f03c0a6f5c998df9f1f150c19fea4300ce5738
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri May 1 08:57:30 2020 +1200

    ldb: Bump version to 2.1.3
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14330
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>

commit 39742f3ffe89f6227d2d57d159f427a4fa622ea5
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Wed Apr 1 08:22:08 2020 +1300

    lib ldb: lmdb init var before calling mdb_reader_check
    
    Initilalise "stale" to zero before passing a pointer to it to
    mdb_reader_check.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Tue Apr  7 12:29:00 UTC 2020 on sn-devel-184
    
    (cherry picked from commit d1f4002b914efb31aa34a59e7c93d80f3174727c)

commit d294eb472961b2450a0d2737e2bab69a9fae1fb9
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Mon Mar 30 12:08:30 2020 +1300

    lib ldb: lmdb clear stale readers on write txn start
    
    In use process failures and Bind9 shut downs leave stale entries in the
    lmdb reader table.  This can result in lmdb filling it's database file, as
    the free list can not be reclaimed due to the stale reader.
    
    In this fix we call mdb_reader_check at the start of each transaction,
    to free any stale readers.  As the default maximum number of readers is
    127, this should not impact on performance to any great extent.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14330
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Mar 31 01:26:07 UTC 2020 on sn-devel-184
    
    (cherry picked from commit 89041a6d18a1d091ea713e6986cac5ca66c2b481)

commit 2b8faefabb49e6823762fe1d0ae26ff6f54f8319
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Mon Mar 16 15:18:12 2020 +1300

    ldb tests: Confirm lmdb free list handling
    
    Add cmocka tests to confirm lmdb's handling of the free list.
    
    As a result of lmdb's MVCC (Multiversion Concurrency Control) long
    running read transactions or stale readers (read transactions where the
    process exited without ending the transaction) can cause the database to
    run out of space.
    
    Items in the free list are only reused when they would not be visible in
    a read transaction.  So long running read transactions prevent entries
    in the free list being reused, and the database can run out of space.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit fc13304d1575ad6bc6e04cdb3eedf46d3c3678c7)

commit f6468de046e93dc45d4bcc76dc27daef75a0152d
Author: Amit Kumar <amitkuma at redhat.com>
Date:   Wed Apr 22 06:53:42 2020 -0500

    lib:util: Fix smbclient -l basename dir
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14345
    
    Pair-Programmed-With: Andreas Schneider <asn at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: Amit Kumar <amitkuma at redhat.com>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit c83ce5f4f99aef94530411ec82cc03e9935b352d)

commit 6bc407b28600596b3270b4671c12199177dc5f2b
Author: Amit Kumar <amitkuma at redhat.com>
Date:   Wed Apr 22 06:53:33 2020 -0500

    Add a test for smbclient -l basename
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14345
    
    Signed-off-by: Amit Kumar <amitkuma at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit 2a7fc40fb3f3ca994cecad3e2957433d7a411208)

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

Summary of changes:
 docs-xml/manpages/pam_winbind.8.xml                |   4 +-
 docs-xml/manpages/pam_winbind.conf.5.xml           |   4 +-
 lib/ldb/ABI/{ldb-2.0.5.sigs => ldb-2.1.3.sigs}     |   0
 ...pyldb-util-2.1.0.sigs => pyldb-util-2.1.3.sigs} |   0
 lib/ldb/ldb_mdb/ldb_mdb.c                          |  17 +
 lib/ldb/tests/ldb_lmdb_free_list_test.c            | 661 +++++++++++++++++++++
 lib/ldb/wscript                                    |  10 +-
 lib/util/debug.c                                   |   8 +-
 lib/util/sys_rw.c                                  | 121 ++++
 lib/util/sys_rw.h                                  |   3 +
 selftest/knownfail                                 |   3 +-
 selftest/knownfail.d/rw-invalid                    |   1 +
 source3/include/proto.h                            |   1 +
 source3/lib/filename_util.c                        |  19 +
 source3/libsmb/clirap.c                            | 151 +++--
 source3/locking/share_mode_lock.c                  |   3 +
 source3/modules/vfs_aio_fork.c                     |   4 +-
 source3/modules/vfs_default.c                      |  27 +-
 source3/modules/vfs_io_uring.c                     | 377 ++++++++++--
 source3/modules/vfs_shadow_copy2.c                 |  91 ++-
 source3/rpc_server/mdssvc/mdssvc.c                 |  11 +-
 source3/script/tests/test_shadow_copy.sh           |  12 +
 .../script/tests/test_smbclient_log_basename.sh    |  36 ++
 source3/selftest/tests.py                          |   3 +
 source3/smbd/aio.c                                 |  24 +
 source3/smbd/fileio.c                              |  18 +
 source3/smbd/filename.c                            |  10 +-
 source3/smbd/open.c                                |  22 +-
 source3/smbd/proto.h                               |   8 +
 source3/smbd/smb2_server.c                         |  10 +-
 source3/smbd/vfs.c                                 |  66 +-
 source4/torture/smb2/read_write.c                  | 189 ++++++
 source4/torture/smb2/sharemode.c                   | 114 ++++
 33 files changed, 1851 insertions(+), 177 deletions(-)
 copy lib/ldb/ABI/{ldb-2.0.5.sigs => ldb-2.1.3.sigs} (100%)
 copy lib/ldb/ABI/{pyldb-util-2.1.0.sigs => pyldb-util-2.1.3.sigs} (100%)
 create mode 100644 lib/ldb/tests/ldb_lmdb_free_list_test.c
 create mode 100644 selftest/knownfail.d/rw-invalid
 create mode 100755 source3/script/tests/test_smbclient_log_basename.sh


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/pam_winbind.8.xml b/docs-xml/manpages/pam_winbind.8.xml
index 003020d8b7c..622e9e188d9 100644
--- a/docs-xml/manpages/pam_winbind.8.xml
+++ b/docs-xml/manpages/pam_winbind.8.xml
@@ -83,8 +83,8 @@
 		<listitem><para>
 		If this option is set, pam_winbind will only succeed if the user is a member of the given SID or NAME. A SID
 		can be either a group-SID, an alias-SID or even an user-SID. It is also possible to give a NAME instead of the
-		SID. That name must have the form: <parameter>MYDOMAIN\\mygroup</parameter> or
-		<parameter>MYDOMAIN\\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
+		SID. That name must have the form: <parameter>MYDOMAIN\mygroup</parameter> or
+		<parameter>MYDOMAIN\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
 		NAME may not contain any spaces. It is thus recommended to only use SIDs. You can verify the list of SIDs a
 		user is a member of with <command>wbinfo --user-sids=SID</command>.
 		</para>
diff --git a/docs-xml/manpages/pam_winbind.conf.5.xml b/docs-xml/manpages/pam_winbind.conf.5.xml
index 918450c4643..c4a7771fb31 100644
--- a/docs-xml/manpages/pam_winbind.conf.5.xml
+++ b/docs-xml/manpages/pam_winbind.conf.5.xml
@@ -68,8 +68,8 @@
 		<listitem><para>
 		If this option is set, pam_winbind will only succeed if the user is a member of the given SID or NAME. A SID
 		can be either a group-SID, an alias-SID or even an user-SID. It is also possible to give a NAME instead of the
-		SID. That name must have the form: <parameter>MYDOMAIN\\mygroup</parameter> or
-		<parameter>MYDOMAIN\\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
+		SID. That name must have the form: <parameter>MYDOMAIN\mygroup</parameter> or
+		<parameter>MYDOMAIN\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
 		NAME may not contain any spaces. It is thus recommended to only use SIDs. You can verify the list of SIDs a
 		user is a member of with <command>wbinfo --user-sids=SID</command>. This setting is empty by default.
 		</para>
diff --git a/lib/ldb/ABI/ldb-2.0.5.sigs b/lib/ldb/ABI/ldb-2.1.3.sigs
similarity index 100%
copy from lib/ldb/ABI/ldb-2.0.5.sigs
copy to lib/ldb/ABI/ldb-2.1.3.sigs
diff --git a/lib/ldb/ABI/pyldb-util-2.1.0.sigs b/lib/ldb/ABI/pyldb-util-2.1.3.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-2.1.0.sigs
copy to lib/ldb/ABI/pyldb-util-2.1.3.sigs
diff --git a/lib/ldb/ldb_mdb/ldb_mdb.c b/lib/ldb/ldb_mdb/ldb_mdb.c
index 6c679c214b8..f0a418d07ee 100644
--- a/lib/ldb/ldb_mdb/ldb_mdb.c
+++ b/lib/ldb/ldb_mdb/ldb_mdb.c
@@ -641,6 +641,23 @@ static int lmdb_transaction_start(struct ldb_kv_private *ldb_kv)
 		return LDB_ERR_PROTOCOL_ERROR;
 	}
 
+	/*
+	 * Clear out any stale readers
+	 */
+	{
+		int stale = 0;
+		mdb_reader_check(lmdb->env, &stale);
+		if (stale > 0) {
+			ldb_debug(
+				lmdb->ldb,
+				LDB_DEBUG_ERROR,
+				"LMDB Stale readers, deleted (%d)",
+				stale);
+		}
+	}
+
+
+
 	ltx_head = lmdb_private_trans_head(lmdb);
 
 	tx_parent = lmdb_trans_get_tx(ltx_head);
diff --git a/lib/ldb/tests/ldb_lmdb_free_list_test.c b/lib/ldb/tests/ldb_lmdb_free_list_test.c
new file mode 100644
index 00000000000..9b295460730
--- /dev/null
+++ b/lib/ldb/tests/ldb_lmdb_free_list_test.c
@@ -0,0 +1,661 @@
+/*
+ * Copyright (C) Catalyst.Net Ltd 2020
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/*
+ * Tests confirming lmdb's handling of the free space list in the presence
+ * of active and stale readers.  A stale reader is a process that opens a
+ * read lock and then exits without releasing the lock.
+ *
+ * lmdb uses MVCC to maintain databased consistency, new copies of updated
+ * records are written to the database. The old entries are only
+ * reused when they are no longer referenced in a read transaction.
+ *
+ * The tests all update a single record multiple times
+ *
+ * If there is a read transaction or a stale reader lmdb will report
+ * out of space.
+ *
+ * If no read transaction and no stale reader, lmdb reclaims space from the
+ * free list.
+ */
+
+/*
+ * from cmocka.c:
+ * These headers or their equivalents should be included prior to
+ * including
+ * this header file.
+ *
+ * #include <stdarg.h>
+ * #include <stddef.h>
+ * #include <setjmp.h>
+ *
+ * This allows test applications to use custom definitions of C standard
+ * library functions and types.
+ *
+ */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <errno.h>
+#include <unistd.h>
+#include <talloc.h>
+#include <tevent.h>
+#include <ldb.h>
+#include <ldb_module.h>
+#include <ldb_private.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <sys/wait.h>
+
+#include "ldb_tdb/ldb_tdb.h"
+#include "ldb_key_value/ldb_kv.h"
+
+#define DEFAULT_BE "mdb"
+
+#ifndef TEST_BE
+#define TEST_BE DEFAULT_BE
+#endif /* TEST_BE */
+
+const int RECORD_SIZE = 6144;
+const int ITERATIONS = 3;
+
+struct test_ctx {
+	struct tevent_context *ev;
+	struct ldb_context *ldb;
+
+	const char *dbfile;
+	const char *lockfile; /* lockfile is separate */
+
+	const char *dbpath;
+};
+
+static void unlink_old_db(struct test_ctx *test_ctx)
+{
+	int ret;
+
+	errno = 0;
+	ret = unlink(test_ctx->lockfile);
+	if (ret == -1 && errno != ENOENT) {
+		fail();
+	}
+
+	errno = 0;
+	ret = unlink(test_ctx->dbfile);
+	if (ret == -1 && errno != ENOENT) {
+		fail();
+	}
+}
+
+static int noconn_setup(void **state)
+{
+	struct test_ctx *test_ctx;
+
+	test_ctx = talloc_zero(NULL, struct test_ctx);
+	assert_non_null(test_ctx);
+
+	test_ctx->ev = tevent_context_init(test_ctx);
+	assert_non_null(test_ctx->ev);
+
+	test_ctx->ldb = ldb_init(test_ctx, test_ctx->ev);
+	assert_non_null(test_ctx->ldb);
+
+	test_ctx->dbfile = talloc_strdup(test_ctx, "lmdb_free_list_test.ldb");
+	assert_non_null(test_ctx->dbfile);
+
+	test_ctx->lockfile =
+	    talloc_asprintf(test_ctx, "%s-lock", test_ctx->dbfile);
+	assert_non_null(test_ctx->lockfile);
+
+	test_ctx->dbpath =
+	    talloc_asprintf(test_ctx, TEST_BE "://%s", test_ctx->dbfile);
+	assert_non_null(test_ctx->dbpath);
+
+	unlink_old_db(test_ctx);
+	*state = test_ctx;
+	return 0;
+}
+
+static int noconn_teardown(void **state)
+{
+	struct test_ctx *test_ctx =
+	    talloc_get_type_abort(*state, struct test_ctx);
+
+	unlink_old_db(test_ctx);
+	talloc_free(test_ctx);
+	return 0;
+}
+
+static int setup(void **state)
+{
+	struct test_ctx *test_ctx;
+	int ret;
+	struct ldb_ldif *ldif;
+	const char *index_ldif = "dn: @INDEXLIST\n"
+				 "@IDXGUID: objectUUID\n"
+				 "@IDX_DN_GUID: GUID\n"
+				 "\n";
+	/*
+	 * Use a 64KiB DB for this test
+	 */
+	const char *options[] = {"lmdb_env_size:65536", NULL};
+
+	noconn_setup((void **)&test_ctx);
+
+	ret = ldb_connect(test_ctx->ldb, test_ctx->dbpath, 0, options);
+	assert_int_equal(ret, 0);
+
+	while ((ldif = ldb_ldif_read_string(test_ctx->ldb, &index_ldif))) {
+		ret = ldb_add(test_ctx->ldb, ldif->msg);
+		assert_int_equal(ret, LDB_SUCCESS);
+	}
+	*state = test_ctx;
+	return 0;
+}
+
+static int teardown(void **state)
+{
+	struct test_ctx *test_ctx =
+	    talloc_get_type_abort(*state, struct test_ctx);
+	noconn_teardown((void **)&test_ctx);
+	return 0;
+}
+
+static struct ldb_kv_private *get_ldb_kv(struct ldb_context *ldb)
+{
+	void *data = NULL;
+	struct ldb_kv_private *ldb_kv = NULL;
+
+	data = ldb_module_get_private(ldb->modules);
+	assert_non_null(data);
+
+	ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+	assert_non_null(ldb_kv);
+
+	return ldb_kv;
+}
+
+static int parse(struct ldb_val key, struct ldb_val data, void *private_data)
+{
+	struct ldb_val *read = private_data;
+
+	/* Yes, we leak this.  That is OK */
+	read->data = talloc_size(NULL, data.length);
+	assert_non_null(read->data);
+
+	memcpy(read->data, data.data, data.length);
+	read->length = data.length;
+	return LDB_SUCCESS;
+}
+
+/*
+ * This test has the same structure as the test_free_list_read_lock
+ * except the parent process does not keep the read lock open while the
+ * child process is performing an update.
+ */
+static void test_free_list_no_read_lock(void **state)
+{
+	int ret;
+	struct test_ctx *test_ctx =
+	    talloc_get_type_abort(*state, struct test_ctx);
+	struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb);
+	struct ldb_val key;
+	struct ldb_val val;
+
+	const char *KEY1 = "KEY01";
+
+	/*
+	 * Pipes etc to co-ordinate the processes
+	 */
+	int to_child[2];
+	int to_parent[2];
+	char buf[2];
+	pid_t pid;
+	size_t i;
+
+	TALLOC_CTX *tmp_ctx;
+	tmp_ctx = talloc_new(test_ctx);
+	assert_non_null(tmp_ctx);
+
+	ret = pipe(to_child);
+	assert_int_equal(ret, 0);
+	ret = pipe(to_parent);
+	assert_int_equal(ret, 0);
+	/*
+	 * Now fork a new process
+	 */
+
+	pid = fork();
+	if (pid == 0) {
+		/*
+		 * Child process
+		 */
+
+		struct ldb_context *ldb = NULL;
+		close(to_child[1]);
+		close(to_parent[0]);
+
+		/*
+		 * Wait for the parent to get ready.
+		 */
+		ret = read(to_child[0], buf, 2);
+		assert_int_equal(ret, 2);
+
+		ldb = ldb_init(test_ctx, test_ctx->ev);
+		assert_non_null(ldb);
+
+		ret = ldb_connect(ldb, test_ctx->dbpath, 0, NULL);
+		assert_int_equal(ret, LDB_SUCCESS);
+
+		ldb_kv = get_ldb_kv(ldb);
+		assert_non_null(ldb_kv);
+		/*
+		 * Add a record to the database
+		 */
+		key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1);
+		key.length = strlen(KEY1) + 1;
+		val.data = talloc_zero_size(tmp_ctx, RECORD_SIZE);
+		assert_non_null(val.data);
+		memset(val.data, 'x', RECORD_SIZE);
+		val.length = RECORD_SIZE;
+		/*
+		 * Do more iterations than when a read lock, stale reader
+		 * active to confirm that the space is being re-used.
+		 */
+		for (i = 0; i < ITERATIONS * 10; i++) {
+			ret = ldb_kv->kv_ops->begin_write(ldb_kv);
+			assert_int_equal(ret, LDB_SUCCESS);
+
+			ret = ldb_kv->kv_ops->store(ldb_kv, key, val, 0);
+			assert_int_equal(ret, LDB_SUCCESS);
+
+			ret = ldb_kv->kv_ops->finish_write(ldb_kv);
+			assert_int_equal(ret, LDB_SUCCESS);
+		}
+
+		/*
+		 * Signal the parent that we've done the updates
+		 */
+		ret = write(to_parent[1], "GO", 2);
+		assert_int_equal(ret, 2);
+		exit(0);
+	}
+
+	close(to_child[0]);
+	close(to_parent[1]);
+
+	/*
+	 * Begin a read transaction
+	 */
+	ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules);
+	assert_int_equal(ret, LDB_SUCCESS);
+
+	/*
+	 * Now close it
+	 */
+	ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules);
+	assert_int_equal(ret, LDB_SUCCESS);
+
+	/*
+	 * Signal the child process
+	 */
+	ret = write(to_child[1], "GO", 2);
+	assert_int_equal(2, ret);
+
+	/*
+	 * Wait for the child process to update the record
+	 */
+	ret = read(to_parent[0], buf, 2);
+	assert_int_equal(2, ret);
+
+	/*
+	 * Begin a read transaction
+	 */
+	ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules);
+	assert_int_equal(ret, LDB_SUCCESS);
+	/*
+	 * read the record
+	 * and close the transaction
+	 */
+	key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1);
+	key.length = strlen(KEY1) + 1;
+
+	ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val);
+	assert_int_equal(ret, LDB_SUCCESS);
+
+	ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules);
+	assert_int_equal(ret, LDB_SUCCESS);
+
+	close(to_child[1]);
+	close(to_parent[0]);
+	TALLOC_FREE(tmp_ctx);
+}
+
+/*
+ * This test has the same structure as the test_free_list_read_lock
+ * except the parent process keeps the read lock open while the
+ * child process is performing an update.
+ */
+static void test_free_list_read_lock(void **state)
+{
+	int ret;
+	struct test_ctx *test_ctx =
+	    talloc_get_type_abort(*state, struct test_ctx);
+	struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb);
+	struct ldb_val key;
+	struct ldb_val val;
+
+	const char *KEY1 = "KEY01";
+
+	/*
+	 * Pipes etc to co-ordinate the processes
+	 */
+	int to_child[2];
+	int to_parent[2];
+	char buf[2];
+	pid_t pid;
+	size_t i;
+
+	TALLOC_CTX *tmp_ctx;
+	tmp_ctx = talloc_new(test_ctx);
+	assert_non_null(tmp_ctx);
+
+	ret = pipe(to_child);
+	assert_int_equal(ret, 0);
+	ret = pipe(to_parent);
+	assert_int_equal(ret, 0);
+	/*
+	 * Now fork a new process
+	 */
+
+	pid = fork();
+	if (pid == 0) {
+		/*
+		 * Child process
+		 */
+
+		struct ldb_context *ldb = NULL;
+		close(to_child[1]);
+		close(to_parent[0]);
+
+		/*
+		 * Wait for the transaction to start
+		 */
+		ret = read(to_child[0], buf, 2);
+		assert_int_equal(ret, 2);
+
+		ldb = ldb_init(test_ctx, test_ctx->ev);
+		assert_non_null(ldb);
+
+		ret = ldb_connect(ldb, test_ctx->dbpath, 0, NULL);
+		assert_int_equal(ret, LDB_SUCCESS);
+
+		ldb_kv = get_ldb_kv(ldb);
+		assert_non_null(ldb_kv);
+		/*
+		 * Add a record to the database
+		 */
+		key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1);
+		key.length = strlen(KEY1) + 1;
+		val.data = talloc_zero_size(tmp_ctx, RECORD_SIZE);
+		assert_non_null(val.data);
+		memset(val.data, 'x', RECORD_SIZE);
+		val.length = RECORD_SIZE;
+		for (i = 0; i < ITERATIONS; i++) {
+			ret = ldb_kv->kv_ops->begin_write(ldb_kv);
+			assert_int_equal(ret, 0);
+			ret = ldb_kv->kv_ops->store(ldb_kv, key, val, 0);
+			if (ret == LDB_ERR_BUSY && i > 0) {
+				int rc = ldb_kv->kv_ops->abort_write(ldb_kv);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list