Skip to content

Issue 6494 - Various errors when using extended matching rule on vlv sort filter #6495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

progier389
Copy link
Contributor

@progier389 progier389 commented Jan 10, 2025

Various issues when configuring and using extended matching rule within a vlv sort filter:

  1. Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
  2. Crash while indexing if vlv are misconfigured because NULL key is not checked.
  3. Read after block because of data type mismatch between SlapiValue and berval
  4. Memory leaks

Solution:

  1. Serialize the vlv index key generation if vlv filter has an extended matching rule.
  2. Check null keys
  3. Always provides SlapiValue even ifg we want to get keys as bervals
  4. Free properly the resources

Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

/*
* Determine if vlv require extended matching rule evaluation
*/
static int
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoul use C11 bool

dblayer_destroy_txn_stack(void)
{
/* Cleanup for the main thread to avoid false/positive leaks from libasan */
void *txn_stack = PR_GetThreadPrivate(thread_private_txn_stack);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable, but why "get" it if you just "set" it to NULL on the next line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, something looks broken.
either the slapi_ch_free(&txn_stack); line is missing, or the PR_GetThreadPrivate should be deleted. (depending whether PR_SetThreadPrivate calls the cleanup callback or not) I will double check
|

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly the dblayer_cleanup_txn_stack is called when using PR_SetThreadPrivate ==> No need to get the data to release it

    #1 0x7f00d94601eb in slapi_ch_free /home/progier/sb/r67020/tst/source/389-ds-base/ldap/servers/slapd/ch_malloc.c:286
    #2 0x7f00d22a6876 in dblayer_cleanup_txn_stack /home/progier/sb/r67020/tst/source/389-ds-base/ldap/servers/slapd/back-ldbm/dblayer.c:1373
    #3 0x7f00d8b04920 in PR_SetThreadPrivate (/lib64/libnspr4.so+0x13920) (BuildId: e6dfe24882ade9ec65f7f1591a3e9e249e5a5780)
    #4 0x7f00d22aac9f in dblayer_destroy_txn_stack /home/progier/sb/r67020/tst/source/389-ds-base/ldap/servers/slapd/back-ldbm/dblayer.c:1429
    #5 0x7f00d22aad5d in dblayer_close /home/progier/sb/r67020/tst/source/389-ds-base/ldap/servers/slapd/back-ldbm/dblayer.c:500

Copy link
Contributor

@mreynolds389 mreynolds389 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a covscan run as well, and didn't see any regressions. Ack!

@mreynolds389
Copy link
Contributor

Thanks for fixing those issues - re-ack!

@progier389 progier389 linked an issue Jan 13, 2025 that may be closed by this pull request
@progier389 progier389 merged commit 4bd27ec into 389ds:main Jan 13, 2025
199 checks passed
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
(cherry picked from commit 223a202)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
(cherry picked from commit 223a202)
(cherry picked from commit 2800437)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
(cherry picked from commit 223a202)
(cherry picked from commit 2800437)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
(cherry picked from commit 223a202)
(cherry picked from commit 2800437)
progier389 added a commit that referenced this pull request Jan 13, 2025
…sort filter (#6495)

* Issue 6494 - Various errors when using extended matching rule on vlv sort filter

Various issues when configuring and using extended matching rule within a vlv sort filter:

Race condition about the keys storage while indexing leading to various heap and data corruption. (lmdb only)
Crash while indexing if vlv are misconfigured because NULL key is not checked.
Read after block because of data type mismatch between SlapiValue and berval
Memory leaks
Solution:

Serialize the vlv index key generation if vlv filter has an extended matching rule.
Check null keys
Always provides SlapiValue even ifg we want to get keys as bervals
Free properly the resources
Issue: #6494

Reviewed by: @mreynolds389 (Thanks!)

(cherry picked from commit 4bd27ec)
(cherry picked from commit 223a202)
(cherry picked from commit 2800437)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Various errors when using extended matching rule on vlv sort filter
2 participants