[BUG][issue-2797] Block module unload when ACL references module subcommands#3160
Conversation
133aff1 to
5e229fd
Compare
|
cc: @roshkhatri @zuiderkwast Please review. Have made the changes as per the discussion. Thank you :D |
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash (issue #2797) that occurs when unloading a module that has commands referenced in ACL rules. When a module is unloaded, Valkey attempts to recompute ACL command bits, which fails if ACL rules reference commands that no longer exist.
Changes:
- Adds pre-unload validation to check if any ACL users reference commands from the module being unloaded
- Blocks module unload with a descriptive error message when ACL references are found
- Adds test coverage for ACL subcommand rules blocking module unload
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/server.h | Declares new ACLModuleHasCommandRules function for checking ACL references to module commands |
| src/acl.c | Implements ACLModuleHasCommandRules to scan all ACL users and detect references to module commands or subcommands |
| src/module.c | Integrates ACL check into moduleUnloadInternal to block unload when ACL references exist |
| tests/unit/moduleapi/subcommands.tcl | Adds test verifying module unload is blocked when ACL rules reference module subcommands |
madolson
left a comment
There was a problem hiding this comment.
I think this makes more sense to prevent the crash instead of altering the user ACLs, also seems a bit simpler. Just some suggested improvements and added test coverage.
5f079c1 to
891e8b4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3160 +/- ##
============================================
- Coverage 74.72% 0 -74.73%
============================================
Files 129 0 -129
Lines 71309 0 -71309
============================================
- Hits 53284 0 -53284
+ Misses 18025 0 -18025 🚀 New features to boost your workflow:
|
da6df73 to
9adf03f
Compare
roshkhatri
left a comment
There was a problem hiding this comment.
Overall the function ACLModuleHasCommandRules implementation looks good, just few suggestions about the tests.
|
We should probably add this to |
783ffed to
0fa9e46
Compare
70c3cb4 to
ca49ee3
Compare
c2b95c7 to
eaef2ff
Compare
|
Please don't resolve the comments that are not responded to, or any updates are done. |
80a4520 to
46f3b97
Compare
|
Hey @sachinvmurthy , I am sorry. I was wrong about the file where the tests should be. Tests should be going in https://github.com/sachinvmurthy/valkey/blob/unstable/tests/unit/moduleapi/aclcheck.tcl |
c658327 to
bfe06fa
Compare
roshkhatri
left a comment
There was a problem hiding this comment.
LGTM, we can merge this @zuiderkwast can you please look at this?
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Fixes valkey-io#2797 (cherry picked from commit 385895a) Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Fixes valkey-io#2797 (cherry picked from commit 385895a) Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Summary: Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Tests: make test Fixes valkey-io#2797 --------- Signed-off-by: sachinvmurthy <sachin.murthy97@gmail.com> Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (valkey-io#3160) Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Fixes valkey-io#2797 (cherry picked from commit 385895a) Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
…ommands (#3160) Prevent MODULE UNLOAD when ACL rules reference a module subcommand. Avoids crash during ACL recompute after module removal. Adds coverage for subcommand ACL rules. Fixes #2797 (cherry picked from commit 385895a) Signed-off-by: Sachin Venkatesha Murthy <sachin.murthy97@gmail.com> Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
Summary:
Prevent MODULE UNLOAD when ACL rules reference a module subcommand.
Avoids crash during ACL recompute after module removal.
Adds coverage for subcommand ACL rules.
Tests:
make test
Fixes #2797