Commit 5413b4c6c07b659e52c84a4e40d897b32b89834f
Committed by
Paul Gortmaker
1 parent
3f8dd9446e
Exists in
master
and in
39 other branches
tipc: Improve handling of invalid link tolerance values
Enhances TIPC link code to ignore an invalid link tolerance value contained in an incoming LINK_PROTOCOL message, rather than processing the value and potentially causing a divide-by-zero error. Also add a compile-time check that catches attempts to redefine TIPC's minimum link tolerance value in a manner that might result in the same divide-by-zero error at run-time. Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Showing 2 changed files with 7 additions and 0 deletions Side-by-side Diff
include/linux/tipc_config.h
... | ... | @@ -193,6 +193,10 @@ |
193 | 193 | #define TIPC_DEF_LINK_TOL 1500 |
194 | 194 | #define TIPC_MAX_LINK_TOL 30000 |
195 | 195 | |
196 | +#if (TIPC_MIN_LINK_TOL < 16) | |
197 | +#error "TIPC_MIN_LINK_TOL is too small (abort limit may be NaN)" | |
198 | +#endif | |
199 | + | |
196 | 200 | /* |
197 | 201 | * Link window limits (min, default, max), in packets |
198 | 202 | */ |
net/tipc/link.c
... | ... | @@ -2617,6 +2617,9 @@ |
2617 | 2617 | |
2618 | 2618 | static void link_set_supervision_props(struct link *l_ptr, u32 tolerance) |
2619 | 2619 | { |
2620 | + if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) | |
2621 | + return; | |
2622 | + | |
2620 | 2623 | l_ptr->tolerance = tolerance; |
2621 | 2624 | l_ptr->continuity_interval = |
2622 | 2625 | ((tolerance / 4) > 500) ? 500 : tolerance / 4; |