Skip to content

fix(ovn): add null check before sbrec delete calls#6316

Merged
oilbeater merged 1 commit intomasterfrom
add-sbrec-delete-null-check-patch
Feb 23, 2026
Merged

fix(ovn): add null check before sbrec delete calls#6316
oilbeater merged 1 commit intomasterfrom
add-sbrec-delete-null-check-patch

Conversation

@oilbeater
Copy link
Copy Markdown
Collaborator

@oilbeater oilbeater commented Feb 22, 2026

Summary

  • Add a patch for OVN (branch-25.03) that adds null pointer checks before calling sbrec_port_binding_delete, sbrec_bfd_delete, and sbrec_encap_delete
  • Prevents potential null pointer dereference crashes in northd and ovn-sbctl
  • Applies the patch during the OVN build in Dockerfile.base

Changes

  • dist/images/patches/sbrec-delete-null-check.patch: New patch file with null checks in three locations:
    • northd/northd.c: Check op->sb before sbrec_port_binding_delete
    • northd/northd.c: Check bfd_e->sb_bt before sbrec_bfd_delete
    • utilities/ovn-sbctl.c: Check sbctl_ch->ch_cfg->encaps[i] before sbrec_encap_delete
  • dist/images/Dockerfile.base: Add and apply the new patch

Test plan

  • Verify the OVN base image builds successfully with the new patch applied
  • Confirm no null pointer crashes in northd when deleting port bindings
  • Confirm no null pointer crashes in northd BFD table sync
  • Confirm no null pointer crashes in ovn-sbctl chassis deletion

Fix #6053

🤖 Generated with Claude Code

Add a patch for OVN that adds null pointer checks before calling
sbrec_port_binding_delete, sbrec_bfd_delete, and sbrec_encap_delete
to prevent potential null pointer dereference crashes in northd and
ovn-sbctl.

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:M This PR changes 30-99 lines, ignoring generated files. label Feb 22, 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 significantly improves the robustness of OVN by addressing potential null pointer dereference issues. By strategically adding null checks in critical deletion functions, it prevents crashes in core components like northd and ovn-sbctl, leading to a more stable and reliable network virtualization environment. The changes are integrated into the OVN build process to ensure consistent application.

Highlights

  • Null Pointer Checks: Introduced a new patch to add null pointer checks before calls to sbrec_port_binding_delete, sbrec_bfd_delete, and sbrec_encap_delete within OVN's northd and ovn-sbctl components.
  • Crash Prevention: The added checks prevent potential null pointer dereference crashes, enhancing the stability of northd and ovn-sbctl.
  • Build Process Integration: The new patch is now applied during the OVN build process by updating Dockerfile.base.
Changelog
  • dist/images/Dockerfile.base
    • Added a new patch file sbrec-delete-null-check.patch to the build context.
    • Modified the OVN build script to apply the sbrec-delete-null-check.patch during compilation.
  • dist/images/patches/sbrec-delete-null-check.patch
    • Created a new patch file.
    • Added a null check for op->sb before calling sbrec_port_binding_delete in northd/northd.c.
    • Added a null check for bfd_e->sb_bt before calling sbrec_bfd_delete in northd/northd.c.
    • Added a null check for sbctl_ch->ch_cfg->encaps[i] before calling sbrec_encap_delete in utilities/ovn-sbctl.c.
Activity
  • No human activity has been recorded on this pull request yet.
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 22, 2026
@dosubot
Copy link
Copy Markdown

dosubot bot commented Feb 22, 2026

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

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 introduces a new patch to add null pointer checks before sbrec_port_binding_delete, sbrec_bfd_delete, and sbrec_encap_delete calls in OVN. This is a critical improvement to prevent potential null pointer dereference crashes, enhancing the stability of northd and ovn-sbctl. The changes also correctly integrate this new patch into the Dockerfile.base for the OVN build process. The implementation of the null checks is straightforward and directly addresses the identified vulnerability.

Comment on lines +10 to +12
+ if (op->sb) {
+ sbrec_port_binding_delete(op->sb);
+ }
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 a null check for op->sb before calling sbrec_port_binding_delete is a critical fix. This prevents potential null pointer dereferences, which could lead to crashes in northd.

Comment on lines +21 to +22
+ if (bfd_e->stale && bfd_e->sb_bt) {
sbrec_bfd_delete(bfd_e->sb_bt);
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

The addition of bfd_e->sb_bt null check before sbrec_bfd_delete is a crucial improvement. This addresses a potential crash scenario in the BFD table synchronization within northd.

Comment on lines +34 to +36
+ if (sbctl_ch->ch_cfg->encaps[i]) {
+ sbrec_encap_delete(sbctl_ch->ch_cfg->encaps[i]);
+ }
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

Implementing a null check for sbctl_ch->ch_cfg->encaps[i] before sbrec_encap_delete is vital. This prevents crashes in ovn-sbctl when handling chassis deletion, especially if an encapsulation entry is unexpectedly null.

Comment on lines +135 to +137
git apply $SRC_DIR/52b727b3315463668669ff423ce8bfa129861162.patch && \
# add null check before sbrec delete calls
git apply $SRC_DIR/sbrec-delete-null-check.patch
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.

medium

The patch application for sbrec-delete-null-check.patch is correctly added. This ensures that the critical null checks are applied during the OVN build process, preventing potential crashes.

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 22, 2026

Pull Request Test Coverage Report for Build 22278762748

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 22272109217: 0.0%
Covered Lines: 12533
Relevant Lines: 54357

💛 - Coveralls

@oilbeater oilbeater merged commit 5c6e746 into master Feb 23, 2026
147 of 148 checks passed
@oilbeater oilbeater deleted the add-sbrec-delete-null-check-patch branch February 23, 2026 01:39
oilbeater added a commit that referenced this pull request Feb 23, 2026
…#6316)

Add a patch for OVN that adds null pointer checks before calling
sbrec_port_binding_delete, sbrec_bfd_delete, and sbrec_encap_delete
to prevent potential null pointer dereference crashes in northd and
ovn-sbctl.

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit 5c6e746)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working need backport size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] master ovn northd segmentation err

2 participants