Fix: conversion from KB to bytes overflow on arm32
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 27 Jan 2022 19:22:22 +0000 (14:22 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 28 Feb 2022 22:11:54 +0000 (17:11 -0500)
commitf9f927bc85812b09e5cb60f598d91b86db8d19c8
treed62e783cdf2a55faf3ad90ce7e659b0e3f1a690e
parent37c7ffca3e35bdddae5aaafe979f1554f6e1b2b9
Fix: conversion from KB to bytes overflow on arm32

Observed issue
==============

On enable channel the memory available check fails on arm32 when
available memory, in bytes, is larger than 2^32.

Cause
=====

`read_proc_meminfo_field` converts the read value (in KB) to bytes and
stores it into a size_t variable.

On the system running the reproducer the value of the `value_kb` variable
is 4839692, yielding an overflow when multiplied with 1024 since
`size_t` is 32 bit long. `size_t` can be larger in certain situation
(i.e LARGEFILE) but this is irrelevant to the problem at hand.

Solution
========

Convert all the checks to use uint64_t.

Known drawbacks
=========

None.

References
==========

The multiplication overflow check scheme is borrowed from
`src/common/time.c`

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I76fe7e57da149c1b4c230a411e0346ba6f9ef7b1
src/common/utils.c
src/common/utils.h
src/lib/lttng-ctl/lttng-ctl.c
This page took 0.025501 seconds and 4 git commands to generate.