Skip to content

Fix Integer Overflow and Thread Safety in Record Counting

Vishal Chourasia ltp 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 4 repliesIn review

Changes in v2 from the cover letter

- Replaced mutex synchronization for global records_read updates with inherent serialization offered by pthread_join.
- Link to v1: https://lore.kernel.org/all/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Enhance Thread Safety in Record Countingutils/benchmark/ebizzy-0.3/ebizzy.c+13 -81 reply
2/2ebizzy: prevent integer overflow in 64-bit systemsutils/benchmark/ebizzy-0.3/ebizzy.c+3 -46 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchSrikar DronamrajuShrikanth HegdeCyril Hrubis
1/2R-b R-b R-b
2/2R-b R-b R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [LTP] [PATCH v2 0/2] Fix Integer Overflow and Thread Safety in Record Counting

I am writing to present a patch set that addresses a significant issue we've observed in our 64-bit systems. We noticed an integer overflow bug affecting our results, which has prompted this set of changes.

Key Changes:

- Type Selection for Record Counting: We've shifted from using unsigned int to uintptr_t for tracking record counts. This is crucial, especially on 64-bit systems, to avoid potential integer overflows that can jeopardize the accuracy of our results.

- Thread Safety for Record Counting: Previously, the design used a global records_read variable to accumulate counts from different threads. This approach didn't employ locks, posing potential race conditions. In this patch, we've rectified this by introducing a thread-local variable, records_thread, to individually store the record count of each thread. The accumulated total is then fetched safely during thread joining.

Rationale:

These changes stem from our observations on certain 64-bit systems. The integer overflow bug, combined with potential race conditions due to the unguarded global variable, was impacting the integrity of our results. By switching to uintptr_t, we ensure adequate space to hold larger counts typical for 64-bit systems. Additionally, by introducing the thread-local variable and removing the global counter, we've added a level of safety against concurrent access issues.

This patch set ensures the robustness and accuracy of our system, particularly in multi-threaded environments on 64-bit platforms.

Thank you for your time and consideration. I am open to any feedback and will gladly make any necessary modifications.

Changes in v2:
- Replaced mutex synchronization for global records_read updates with inherent serialization offered by pthread_join.
- Link to v1: https://lore.kernel.org/all/[email protected]/

Vishal Chourasia (2):
Enhance Thread Safety in Record Counting
ebizzy: prevent integer overflow in 64-bit systems

 utils/benchmark/ebizzy-0.3/ebizzy.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
Signature · 5 lines
2.39.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp