Skip to content

Fix overflow in ldv-consumption task

The global variable jiffies is extern volatile. In the kernel elapsed time is measured in jiffies, so this variable will continuously increase. (Here this is overapproximated by a variable that could have any content everytime it is read, there is no guarantee that it will actually increase, but this is not of concern for the overflow).

In real-world scenarios there is no way to reach LONG_MAX on a 64 bit system, so overflows here are practically irrelevant.

The arithmetic operation in the changed line casts the values to long, so there is a trivial overflow whenever this line can be reached. dev->last_rx saves the value of jiffies for the last received package. We can fix this by writing a < b instead of a -b < 0. This preserves the logic of the task. It is unclear whether the insufficient modelling of jiffies will cause the task to be unsafe with regards to unreach_call, but this should not be the concern here. This should be investigated independently.

Merge request reports