Skip to content

fix: prevent segmentation fault in ipvs_group_sync_entry - #2704

Merged
pqarmitage merged 1 commit into
acassen:masterfrom
kazeburo:fix/segfault-in-ipvs_group_sync_entry
Aug 13, 2026
Merged

fix: prevent segmentation fault in ipvs_group_sync_entry#2704
pqarmitage merged 1 commit into
acassen:masterfrom
kazeburo:fix/segfault-in-ipvs_group_sync_entry

Conversation

@kazeburo

@kazeburo kazeburo commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Problem

When adding a new IP address to a virtual_server_group and reloading keepalived, the checker child segfaults if the virtual server does not have a sorry_server.

Sample configuration that triggers the crash:

global_defs {
        lvs_flush
}
virtual_server_group VG_80 {
        203.0.113.35 80
        203.0.113.32 80
        203.0.113.49 80
        203.0.113.56 80
        203.0.113.33 80
}

Stack trace:

#0  ipvs_group_sync_entry (keepalived + 0x20f6a)
#1  sync_service_vsg_entry (keepalived + 0x1d8d4)
#2  sync_service_vsg (keepalived + 0x1eb06)
#3  start_check (keepalived + 0xf591)
#4  reload_check_thread (keepalived + 0xf8c3)
...

Root Cause

In ipvs_group_sync_entry(), the weight of a real server is computed as:

drule.user.weight = ((rs->inhibit && !rs->alive) || vs->s_svr->alive) ? 0 : real_weight(rs->effective_weight);

If no sorry_server is configured, vs->s_svr is NULL, so accessing vs->s_svr->alive causes a null pointer dereference.

The later block in the same function already checks if (vs->s_svr && ...) before dereferencing it, so this was just a missing check.

Testing

  • Reproduced the crash by adding a new IP to a VSG without sorry_server and reloading.
  • Verified the crash no longer occurs after the fix.

@pqarmitage
pqarmitage merged commit 55d6f49 into acassen:master Aug 13, 2026
12 checks passed
@pqarmitage

Copy link
Copy Markdown
Collaborator

Many thanks for identifying the issue and providing the patch.

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