]> git.baikalelectronics.ru Git - kernel.git/commit
packet: clarify timestamp overflow
authorArnd Bergmann <arnd@arndb.de>
Mon, 27 Nov 2017 09:09:24 +0000 (10:09 +0100)
committerArnd Bergmann <arnd@arndb.de>
Wed, 18 Dec 2019 17:07:31 +0000 (18:07 +0100)
commit0ec150b20538c4aa8fda6cbdca0872642b1bc4a2
treec0e56431fd46884e674206f970b8a63b6ce1e2d4
parentb0535ecbd3ae250602b23ce24ff7657fd94b6f29
packet: clarify timestamp overflow

The memory mapped packet socket data structure in version 1 through 3
all contain 32-bit second values for the packet time stamps, which makes
them suffer from the overflow of time_t in y2038 or y2106 (depending
on whether user space interprets the value as signed or unsigned).

The implementation uses the deprecated getnstimeofday() function.

In order to get rid of that, this changes the code to use
ktime_get_real_ts64() as a replacement, documenting the nature of the
overflow. As long as the user applications treat the timestamps as
unsigned, or only use the difference between timestamps, they are
fine, and changing the timestamps to 64-bit wouldn't require a more
invasive user space API change.

Note: a lot of other APIs suffer from incompatible structures when
time_t gets redefined to 64-bit in 32-bit user space, but this one
does not.

Acked-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/lkml/CAF=yD-Jomr-gWSR-EBNKnSpFL46UeG564FLfqTCMNEm-prEaXA@mail.gmail.com/T/#u
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
net/packet/af_packet.c