Skip to content

Comments

[BUG][issue-2797] Block module unload when ACL references module subcommands#3160

Merged
madolson merged 12 commits intovalkey-io:unstablefrom
sachinvmurthy:bug/fixes_issue_2797
Feb 17, 2026
Merged

[BUG][issue-2797] Block module unload when ACL references module subcommands#3160
madolson merged 12 commits intovalkey-io:unstablefrom
sachinvmurthy:bug/fixes_issue_2797

Conversation

@sachinvmurthy
Copy link
Contributor

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

@sachinvmurthy sachinvmurthy force-pushed the bug/fixes_issue_2797 branch 2 times, most recently from 133aff1 to 5e229fd Compare February 3, 2026 21:44
@sachinvmurthy
Copy link
Contributor Author

cc: @roshkhatri @zuiderkwast Please review. Have made the changes as per the discussion. Thank you :D

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Copy link
Member

@madolson madolson left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (5d7d542) to head (bfe06fa).
⚠️ Report is 36 commits behind head on unstable.

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     

see 129 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sachinvmurthy sachinvmurthy force-pushed the bug/fixes_issue_2797 branch 2 times, most recently from da6df73 to 9adf03f Compare February 5, 2026 21:45
@zuiderkwast
Copy link
Contributor

Copy link
Member

@roshkhatri roshkhatri left a comment

Choose a reason for hiding this comment

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

Overall the function ACLModuleHasCommandRules implementation looks good, just few suggestions about the tests.

@roshkhatri
Copy link
Member

roshkhatri commented Feb 9, 2026

We should probably add this to release-notes

@roshkhatri roshkhatri added the release-notes This issue should get a line item in the release notes label Feb 12, 2026
@roshkhatri
Copy link
Member

Please don't resolve the comments that are not responded to, or any updates are done.
Couldn't keep track of the comments if addressed for example: #3160 (comment)

@roshkhatri
Copy link
Member

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

@zuiderkwast zuiderkwast moved this to In Progress in Valkey 9.0 Feb 17, 2026
Copy link
Member

@roshkhatri roshkhatri left a comment

Choose a reason for hiding this comment

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

LGTM, we can merge this @zuiderkwast can you please look at this?

Copy link
Member

@madolson madolson left a comment

Choose a reason for hiding this comment

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

Cool, thanks!

@madolson madolson moved this to To be backported in Valkey 8.1 Feb 17, 2026
@madolson madolson moved this to To be backported in Valkey 8.0 Feb 17, 2026
@madolson madolson moved this to To be backported in Valkey 7.2 Feb 17, 2026
@madolson madolson merged commit 385895a into valkey-io:unstable Feb 17, 2026
56 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to To be backported in Valkey 9.0 Feb 17, 2026
@roshkhatri roshkhatri moved this from To be backported to 9.0.3 in Valkey 9.0 Feb 17, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 17, 2026
…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>
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 18, 2026
…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>
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 18, 2026
…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>
@roshkhatri roshkhatri moved this from To be backported to 8.0.7 (WIP) in Valkey 8.0 Feb 18, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 18, 2026
…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>
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 18, 2026
…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>
roshkhatri added a commit to roshkhatri/valkey that referenced this pull request Feb 18, 2026
…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>
@roshkhatri roshkhatri moved this from To be backported to 7.2.12 in Valkey 7.2 Feb 18, 2026
@roshkhatri roshkhatri moved this from To be backported to 8.1.6 WIP in Valkey 8.1 Feb 18, 2026
roshkhatri added a commit to roshkhatri/valkey that referenced this pull request Feb 19, 2026
…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>
harrylin98 pushed a commit to harrylin98/valkey_forked that referenced this pull request Feb 19, 2026
…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>
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 20, 2026
…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>
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 20, 2026
…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>
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 20, 2026
…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>
roshkhatri added a commit to roshkhatri/valkey that referenced this pull request Feb 23, 2026
…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>
hpatro pushed a commit that referenced this pull request Feb 24, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes This issue should get a line item in the release notes

Projects

Status: 7.2.12 WIP
Status: 8.0.7 (WIP)
Status: 8.1.6 WIP
Status: 9.0.3 (WIP)

Development

Successfully merging this pull request may close these issues.

[CRASH] Valkey7/8/9 crashes when unloading a module if a command from that module was added to an ACL user.

4 participants