Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow/manager: fix prealloc unhandled division by 0 (60x backports) - v1 #8637

Merged
merged 3 commits into from Mar 29, 2023

Conversation

jufajardini
Copy link
Contributor

@jufajardini jufajardini commented Mar 28, 2023

#8616
and
#8628
backports

plus clang formatting fixes

Redmine ticket: https://redmine.openinfosecfoundation.org/issues/5946

If flow.prealloc was set to zero in our yaml config, this led to
a floating point exception in the flow manager.

Bug: OISF#5919.
(cherry picked from commit 5baa6c0)
Updated all cases where flow_config.prealloc was used in a division.

*** CID 1524506:  Integer handling issues  (DIVIDE_BY_ZERO)
/src/flow-manager.c: 858 in FlowManager()
852                                "flow_spare_q status: %" PRIu32 "%% flows at the queue",
853                             spare_pool_len, flow_config.prealloc,
854                             spare_pool_len * 100 / flow_config.prealloc);
855
856                     /* only if we have pruned this "emergency_recovery" percentage
857                      * of flows, we will unset the emergency bit */
>>>     CID 1524506:  Integer handling issues  (DIVIDE_BY_ZERO)
>>>     In expression "spare_pool_len * 100U / flow_config.prealloc", division by expression "flow_config.prealloc" which may be zero has undefined behavior.
858                     if (spare_pool_len * 100 / flow_config.prealloc > flow_config.emergency_recovery) {
859                         emerg_over_cnt++;
860                     } else {
861                         emerg_over_cnt = 0;
862                     }

Related to
Bug OISF#5919

(cherry picked from commit 754d280)
@jufajardini jufajardini requested a review from a team as a code owner March 28, 2023 14:11
@suricata-qa
Copy link

Information:

field baseline test %
TREX_GENERIC_stats_chk
.capture.kernel_drops 0 4755 0.00

Pipeline 12866

@victorjulien victorjulien merged commit 7bfe59f into OISF:master-6.0.x Mar 29, 2023
22 checks passed
@jufajardini jufajardini deleted the 60x-backports-prealloc/v1 branch March 29, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants