The Samba-Bugzilla – Attachment 19235 Details for
Bug 16253
smbstatus byte-range locks broken by Persistent Handle changes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.25 cherry-picked from master
bug16253-425.patch (text/plain), 4.17 KB, created by
Ralph Böhme
on 2026-09-21 14:00:49 UTC
(
hide
)
Description:
Patch for 4.25 cherry-picked from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2026-09-21 14:00:49 UTC
Size:
4.17 KB
patch
obsolete
>From a3e96dbc4c121b1be1d3d812eca2134c20acdf2c Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Sat, 19 Sep 2026 10:01:03 +0000 >Subject: [PATCH] s3:brlock: use brl_parse_data() in in brl_forall() > >brl_traverse_fn() walked the record itself instead of going through >brl_parse_data(), which stopped being correct when the Persistent Handle series >put a four byte version prefix in front of the array. > >brl_traverse_fn() calls brl_parse_data() with a struct byte_range_lock on the >stack, so it grows a mem_ctx argument for the array it allocates. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=16253 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Volker Lendecke <vl@samba.org> > >Autobuild-User(master): Volker Lendecke <vl@samba.org> >Autobuild-Date(master): Mon Sep 21 13:23:18 UTC 2026 on atb-devel-224 > >(cherry picked from commit 8070be375433503407e1bc07bdd2b89e36a9a66f) >--- > source3/locking/brlock.c | 44 ++++++++++++++++++++++++---------------- > 1 file changed, 27 insertions(+), 17 deletions(-) > >diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c >index 043ef177e421..3293f4046ba2 100644 >--- a/source3/locking/brlock.c >+++ b/source3/locking/brlock.c >@@ -1526,15 +1526,19 @@ struct brl_forall_cb { > on each lock. > ****************************************************************************/ > >+static bool brl_parse_data(TALLOC_CTX *mem_ctx, >+ struct byte_range_lock *br_lck, >+ TDB_DATA data); >+ > static int brl_traverse_fn(struct db_record *rec, void *state) > { > struct brl_forall_cb *cb = (struct brl_forall_cb *)state; >- struct lock_struct *locks; >+ struct byte_range_lock br_lck = {}; > struct file_id *key; > unsigned int i; >- unsigned int num_locks = 0; > TDB_DATA dbkey; > TDB_DATA value; >+ bool ok; > > dbkey = dbwrap_record_get_key(rec); > value = dbwrap_record_get_value(rec); >@@ -1542,28 +1546,26 @@ static int brl_traverse_fn(struct db_record *rec, void *state) > /* In a traverse function we must make a copy of > dbuf before modifying it. */ > >- locks = (struct lock_struct *)talloc_memdup( >- talloc_tos(), value.dptr, value.dsize); >- if (!locks) { >+ ok = brl_parse_data(talloc_tos(), &br_lck, value); >+ if (!ok) { > return -1; /* Terminate traversal. */ > } > > key = (struct file_id *)dbkey.dptr; >- num_locks = value.dsize/sizeof(*locks); > > if (cb->fn) { >- for ( i=0; i<num_locks; i++) { >+ for ( i=0; i<br_lck.num_locks; i++) { > cb->fn(*key, >- locks[i].context.pid, >- locks[i].lock_type, >- locks[i].lock_flav, >- locks[i].start, >- locks[i].size, >+ br_lck.lock_data[i].context.pid, >+ br_lck.lock_data[i].lock_type, >+ br_lck.lock_data[i].lock_flav, >+ br_lck.lock_data[i].start, >+ br_lck.lock_data[i].size, > cb->private_data); > } > } > >- TALLOC_FREE(locks); >+ TALLOC_FREE(br_lck.lock_data); > return 0; > } > >@@ -1679,7 +1681,15 @@ static int byte_range_lock_destructor(struct byte_range_lock *br_lck) > return 0; > } > >-static bool brl_parse_data(struct byte_range_lock *br_lck, TDB_DATA data) >+/* >+ * Parse a brlock record into br_lck. >+ * >+ * mem_ctx owns the resulting lock data. It is normally br_lck itself, but >+ * brl_traverse_fn() keeps br_lck on the stack. >+ */ >+static bool brl_parse_data(TALLOC_CTX *mem_ctx, >+ struct byte_range_lock *br_lck, >+ TDB_DATA data) > { > size_t data_len = data.dsize; > uint32_t version; >@@ -1711,7 +1721,7 @@ static bool brl_parse_data(struct byte_range_lock *br_lck, TDB_DATA data) > } > data_len = br_lck->num_locks * sizeof(struct lock_struct); > >- br_lck->lock_data = talloc_memdup(br_lck, >+ br_lck->lock_data = talloc_memdup(mem_ctx, > data.dptr + sizeof(uint32_t), > data_len); > if (br_lck->lock_data == NULL) { >@@ -1751,7 +1761,7 @@ static struct byte_range_lock *brl_get_locks_internal(TALLOC_CTX *mem_ctx, > > data = dbwrap_record_get_value(br_lck->record); > >- if (!brl_parse_data(br_lck, data)) { >+ if (!brl_parse_data(br_lck, br_lck, data)) { > TALLOC_FREE(br_lck); > return NULL; > } >@@ -1811,7 +1821,7 @@ static void brl_get_locks_readonly_parser(TDB_DATA key, TDB_DATA data, > return; > } > *br_lck = (struct byte_range_lock) { 0 }; >- if (!brl_parse_data(br_lck, data)) { >+ if (!brl_parse_data(br_lck, br_lck, data)) { > *state->br_lock = NULL; > return; > } >-- >2.54.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
vl
:
review+
Actions:
View
Attachments on
bug 16253
: 19235