linux-stable/drivers/ptp
Jakub Kicinski cee0a9c182 ptp: improve max_adj check against unreasonable values
[ Upstream commit 475b92f932 ]

Scaled PPM conversion to PPB may (on 64bit systems) result
in a value larger than s32 can hold (freq/scaled_ppm is a long).
This means the kernel will not correctly reject unreasonably
high ->freq values (e.g. > 4294967295ppb, 281474976645 scaled PPM).

The conversion is equivalent to a division by ~66 (65.536),
so the value of ppb is always smaller than ppm, but not small
enough to assume narrowing the type from long -> s32 is okay.

Note that reasonable user space (e.g. ptp4l) will not use such
high values, anyway, 4289046510ppb ~= 4.3x, so the fix is
somewhat pedantic.

Fixes: d39a743511 ("ptp: validate the requested frequency adjustment.")
Fixes: d94ba80ebb ("ptp: Added a brand new class driver for ptp clocks.")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-06-30 08:48:19 -04:00
..
Kconfig
Makefile
ptp_chardev.c
ptp_clock.c ptp: improve max_adj check against unreasonable values 2021-06-30 08:48:19 -04:00
ptp_dte.c
ptp_ixp46x.c
ptp_kvm.c
ptp_pch.c
ptp_private.h ptp: fix the race between the release of ptp_clock and cdev 2020-01-04 19:13:35 +01:00
ptp_qoriq.c
ptp_sysfs.c