linux/drivers/ptp
Jakub Kicinski 3daa97817a ptp: improve max_adj check against unreasonable values
[ Upstream commit 475b92f932168a78da8109acd10bfb7578b8f2bb ]

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-23 14:41:26 +02:00
..
Kconfig ptp: fix typo of "mechanism" in Kconfig help text 2019-10-07 14:55:46 -04:00
Makefile ptp: add debugfs support for ptp_qoriq 2019-01-22 20:21:57 -08:00
ptp_chardev.c ptp: Introduce strict checking of external time stamp options. 2019-11-15 12:48:32 -08:00
ptp_clock.c ptp: improve max_adj check against unreasonable values 2021-06-23 14:41:26 +02:00
ptp_dte.c ptp: ptp_dte: remove redundant dev_err message 2019-07-25 11:37:40 -07:00
ptp_ixp46x.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
ptp_kvm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
ptp_pch.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 167 2019-05-30 11:26:39 -07:00
ptp_private.h ptp: fix the race between the release of ptp_clock and cdev 2020-01-04 19:18:48 +01:00
ptp_qoriq.c ptp_qoriq: Initialize the registers' spinlock before calling ptp_qoriq_settime 2019-10-02 12:20:38 -04:00
ptp_qoriq_debugfs.c ptp_qoriq: add little enadian support 2019-02-12 12:58:48 -05:00
ptp_sysfs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00