linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: hctosys: Add missing range error reporting
@ 2018-11-05  3:48 Maciej W. Rozycki
  2018-11-07 16:23 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej W. Rozycki @ 2018-11-05  3:48 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel, stable

Fix an issue with the 32-bit range error path in `rtc_hctosys' where no 
error code is set and consequently the successful preceding call result 
from `rtc_read_time' is propagated to `rtc_hctosys_ret'.  This in turn 
makes any subsequent call to `hctosys_show' incorrectly report in sysfs 
that the system time has been set from this RTC while it has not.

Set the error to ERANGE then if we can't express the result due to an 
overflow.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t")
Cc: stable@vger.kernel.org # 4.17+
---
 drivers/rtc/hctosys.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

linux-rtc-hctosys-range.diff
Index: linux-20181008-swarm64-eb/drivers/rtc/hctosys.c
===================================================================
--- linux-20181008-swarm64-eb.orig/drivers/rtc/hctosys.c
+++ linux-20181008-swarm64-eb/drivers/rtc/hctosys.c
@@ -50,8 +50,10 @@ static int __init rtc_hctosys(void)
 	tv64.tv_sec = rtc_tm_to_time64(&tm);
 
 #if BITS_PER_LONG == 32
-	if (tv64.tv_sec > INT_MAX)
+	if (tv64.tv_sec > INT_MAX) {
+		err = -ERANGE;
 		goto err_read;
+	}
 #endif
 
 	err = do_settimeofday64(&tv64);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: hctosys: Add missing range error reporting
  2018-11-05  3:48 [PATCH] rtc: hctosys: Add missing range error reporting Maciej W. Rozycki
@ 2018-11-07 16:23 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2018-11-07 16:23 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Alessandro Zummo, linux-rtc, linux-kernel, stable

On 05/11/2018 03:48:25+0000, Maciej W. Rozycki wrote:
> Fix an issue with the 32-bit range error path in `rtc_hctosys' where no 
> error code is set and consequently the successful preceding call result 
> from `rtc_read_time' is propagated to `rtc_hctosys_ret'.  This in turn 
> makes any subsequent call to `hctosys_show' incorrectly report in sysfs 
> that the system time has been set from this RTC while it has not.
> 
> Set the error to ERANGE then if we can't express the result due to an 
> overflow.
> 
> Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
> Fixes: b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t")
> Cc: stable@vger.kernel.org # 4.17+
> ---
>  drivers/rtc/hctosys.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-07 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-05  3:48 [PATCH] rtc: hctosys: Add missing range error reporting Maciej W. Rozycki
2018-11-07 16:23 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).