Skip to content

fix(ovn): add use-after-free fix for en-sync-sb to null check patch#6326

Merged
oilbeater merged 1 commit intomasterfrom
fix-ovn-null-pointer-patches
Feb 24, 2026
Merged

fix(ovn): add use-after-free fix for en-sync-sb to null check patch#6326
oilbeater merged 1 commit intomasterfrom
fix-ovn-null-pointer-patches

Conversation

@oilbeater
Copy link
Copy Markdown
Collaborator

Summary

  • Add missing continue in sync_changed_lbs() (northd/en-sync-sb.c) to prevent use-after-free after hmap_remove and free(sb_lb), avoiding subsequent access to the freed entry.
  • Existing null pointer checks for sbrec_port_binding_delete, sbrec_bfd_delete, and sbrec_encap_delete are preserved.

Test plan

  • Verify the patch applies cleanly to the OVN source during image build
  • Run e2e tests to ensure no regression

🤖 Generated with Claude Code

Add a missing `continue` statement in sync_changed_lbs() to prevent
use-after-free access after hmap_remove and free of sb_lb entry.

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 24, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @oilbeater, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical use-after-free vulnerability in the OVN 'northd' component. By introducing a 'continue' statement after deallocating memory, it ensures that freed resources are not subsequently accessed, thereby enhancing the stability and security of the system. The change specifically targets the 'sync_changed_lbs()' function to prevent potential crashes or undefined behavior.

Highlights

  • Use-after-free prevention: Added a 'continue' statement in 'sync_changed_lbs()' within 'northd/en-sync-sb.c' to prevent a use-after-free vulnerability after 'hmap_remove' and 'free(sb_lb)'.
  • Existing null checks preserved: Ensured that existing null pointer checks for 'sbrec_port_binding_delete', 'sbrec_bfd_delete', and 'sbrec_encap_delete' remain preserved.
Changelog
  • dist/images/patches/sbrec-delete-null-check.patch
    • Updated to include a new patch for 'northd/en-sync-sb.c' that adds a 'continue' statement to prevent a use-after-free bug.
Activity
  • The pull request was generated using Claude Code.
  • A test plan has been outlined, including verification of patch application and running e2e tests, which are currently pending.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the bug Something isn't working label Feb 24, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request addresses a potential use-after-free vulnerability by adding a continue statement after freeing an sb_lb object. It also introduces null pointer checks before deleting sbrec_port_binding, sbrec_bfd, and sbrec_encap records, enhancing the robustness of the code. The changes appear to correctly resolve the identified issues.


hmap_remove(&sb_lbs->entries, &sb_lb->key_node);
free(sb_lb);
+ continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

Adding continue here is crucial to prevent use-after-free. After sb_lb is freed, any subsequent access to sb_lb within the loop iteration would lead to undefined behavior. This change correctly ensures that the loop proceeds to the next iteration immediately after freeing the resource.

            continue;

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 22334427923

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 23.057%

Totals Coverage Status
Change from base Build 22313794790: 0.0%
Covered Lines: 12533
Relevant Lines: 54357

💛 - Coveralls

@oilbeater oilbeater merged commit 0cad95f into master Feb 24, 2026
77 checks passed
@oilbeater oilbeater deleted the fix-ovn-null-pointer-patches branch February 24, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants