linux_dsm_epyc7002/include
Lukas Hannen d545fd4f97 time: Handle negative seconds correctly in timespec64_to_ns()
commit 39ff83f2f6cc5cc1458dfcea9697f96338210beb upstream.

timespec64_ns() prevents multiplication overflows by comparing the seconds
value of the timespec to KTIME_SEC_MAX. If the value is greater or equal it
returns KTIME_MAX.

But that check casts the signed seconds value to unsigned which makes the
comparision true for all negative values and therefore return wrongly
KTIME_MAX.

Negative second values are perfectly valid and required in some places,
e.g. ptp_clock_adjtime().

Remove the cast and add a check for the negative boundary which is required
to prevent undefined behaviour due to multiplication underflow.

Fixes: cb47755725 ("time: Prevent undefined behaviour in timespec64_to_ns()")'
Signed-off-by: Lukas Hannen <lukas.hannen@opensource.tttech-industrial.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/AM6PR01MB541637BD6F336B8FFB72AF80EEC69@AM6PR01MB5416.eurprd01.prod.exchangelabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-05 19:13:39 +02:00
..
acpi
asm-generic vmlinux.lds.h: Handle clang's module.{c,d}tor sections 2024-07-05 18:55:16 +02:00
clocksource
crypto
drm drm: Return -ENOTTY for non-drm ioctls 2021-07-28 14:35:47 +02:00
dt-bindings
keys
kunit
kvm
linux time: Handle negative seconds correctly in timespec64_to_ns() 2024-07-05 19:13:39 +02:00
math-emu
media
memory
misc
net Revert "flow_offload: action should not be NULL when it is referenced" 2024-07-05 18:55:48 +02:00
pcmcia
ras
rdma
scsi
soc firmware: raspberrypi: Keep count of all consumers 2024-07-05 19:12:05 +02:00
sound ALSA: hda: intel-nhlt: verify config type 2021-03-09 11:11:14 +01:00
target
trace
uapi bpf: Fix a typo of reuseport map in bpf.h. 2024-07-05 19:10:44 +02:00
vdso
video
xen