summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2021-06-14 15:24:05 -0700
committerSasha Levin <sashal@kernel.org>2021-06-30 08:48:19 -0400
commitcee0a9c1826bebd7c2578ad0dcff06eb68868069 (patch)
tree4a36ee138eabcba3a25a03496bd63b8c1788cddc /include/linux
parentb5200624e643bb4cf65eb3b6d9bf36fc11982669 (diff)
downloadlinux-stable-cee0a9c1826bebd7c2578ad0dcff06eb68868069.tar.gz
linux-stable-cee0a9c1826bebd7c2578ad0dcff06eb68868069.tar.bz2
linux-stable-cee0a9c1826bebd7c2578ad0dcff06eb68868069.zip
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: d39a743511cd ("ptp: validate the requested frequency adjustment.") Fixes: d94ba80ebbea ("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>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/ptp_clock_kernel.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index 40ea83fcfdd5..99c3f4ee938e 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -210,7 +210,7 @@ extern int ptp_clock_index(struct ptp_clock *ptp);
* @ppm: Parts per million, but with a 16 bit binary fractional field
*/
-extern s32 scaled_ppm_to_ppb(long ppm);
+extern long scaled_ppm_to_ppb(long ppm);
/**
* ptp_find_pin() - obtain the pin index of a given auxiliary function