Skip to content
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

The lock of lruhash table should unlocked after markdel entry #399

Merged
merged 1 commit into from
Jan 13, 2021

Conversation

rma-shuyu
Copy link
Contributor

…hen lru_remove the entry , then unlock the table, and then markdel entry , but in function rrset_cache_touch , the entry will be touched to lru again before markdelling entry in function lruhash_remove. This is a bug!

…hen lru_remove the entry , then unlock the table, and then markdel entry , but in function rrset_cache_touch , the entry will be touched to lru again before markdelling entry in function lruhash_remove. This is a bug!
Copy link
Member

@wcawijngaards wcawijngaards left a comment

Choose a reason for hiding this comment

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

Changes look good.

@wcawijngaards
Copy link
Member

Previous title was, from xiangbao227: I found that in function "lruhash_remove", table was locked at first ,then lru_remove the entry , then unlock the table, and then markdel entry , but in function "rrset_cache_touch" , the entry will be touched to lru again before markdelling entry in function "lruhash_remove". This may lead to core!
Changed the title to a shorter one.

@wcawijngaards wcawijngaards changed the title I found that in function "lruhash_remove", table was locked at first ,then lru_remove the entry , then unlock the table, and then markdel entry , but in function "rrset_cache_touch" , the entry will be touched to lru again before markdelling entry in function "lruhash_remove". This may lead to core! The function rrset_cache_touch can touch an entry to the lru while markdelling the entry in lruhash_remove Jan 13, 2021
@wcawijngaards wcawijngaards merged commit 7e46204 into NLnetLabs:master Jan 13, 2021
wcawijngaards added a commit that referenced this pull request Jan 13, 2021
- Merge #399 from xiangbao227: The function rrset_cache_touch can
  touch an entry to the lru while markdelling the entry in
  lruhash_remove.
@rma-shuyu rma-shuyu changed the title The function rrset_cache_touch can touch an entry to the lru while markdelling the entry in lruhash_remove The lock of lruhash table should unlocked after markdel entry Jan 13, 2021
@wcawijngaards
Copy link
Member

Thank you for the bug fix! That was hard to find, I think. I have committed the fix to the code repository.

The other calls of the markdel function have the table lock held, so they should not have this race condition.

wcawijngaards added a commit that referenced this pull request Jan 13, 2021
- Merge #399 from xiangbao227: The lock of lruhash table should
  unlocked after markdel entry.
jedisct1 added a commit to jedisct1/unbound that referenced this pull request Jan 20, 2021
* nlnet/master: (33 commits)
  rpl tests for nsid
  example.conf.in entry for nsid
  - Fix declaration before statement and signed comparison warning in   dns64.
  - Fix NLnetLabs#404: DNS query with small edns bufsize fail.
  Changelog entry for NLnetLabs#402. - Merge NLnetLabs#402 from fobser: Implement IPv4-Embedded addresses according   to RFC6052.
  Implement IPv4-Embedded addresses according to RFC6052.
  - Fix for NLnetLabs#93: dynlibmodule import library is named libunbound.dll.a.
  - Fix for NLnetLabs#93: dynlibmodule link fix for Windows.
  Nicer changelog note for NLnetLabs#399 - Merge NLnetLabs#399 from xiangbao227: The lock of lruhash table should   unlocked after markdel entry.
  Changelog note for NLnetLabs#399 - Merge NLnetLabs#399 from xiangbao227: The function rrset_cache_touch can   touch an entry to the lru while markdelling the entry in   lruhash_remove.
  I found that in function lruhash_remove, table was locked at first ,then lru_remove the entry , then unlock the table, and then markdel entry , but in function rrset_cache_touch , the entry will be touched to lru again before markdelling entry in function lruhash_remove. This is a bug!
  And man page documentation for them.
  - Fix so local zone types always_nodata and always_deny can be used   from the config file.
  - Fix NLnetLabs#397: [Feature request] add new type always_null to local-zone   similar to always_nxdomain.
  - Fix clang analysis warning.
  - Add comment documentation.
  - For NLnetLabs#391: more double casts in python start time calculation.
  - For NLnetLabs#391: fix indentation.
  - For NLnetLabs#391: use struct timeval* start_time for callback information.
  Changelog note for NLnetLabs#391 - Merge PR NLnetLabs#391 from fhriley: Add start_time to reply callbacks so   modules can compute the response time.
  ...
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.

2 participants