[05/48] drivers/rtc/interface.c: fix alarm rollover when day or month is out-of-range
From: Greg KH <gregkh@suse.de>
Date: 2012-01-16 18:48:25
Also in:
lkml
3.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <redacted>
commit e74a8f2edb92cb690b467cea0ab652c509e9f624 upstream.
Commit f44f7f96a20a ("RTC: Initialize kernel state from RTC") introduced a
potential infinite loop. If an alarm time contains a wildcard month and
an invalid day (> 31), or a wildcard year and an invalid month (>= 12),
the loop searching for the next matching date will never terminate. Treat
the invalid values as wildcards.
Fixes <http://bugs.debian.org/646429>, <http://bugs.debian.org/653331>
Reported-by: leo weppelman <redacted>
Reported-by: "P. van Gaans" <redacted>
Signed-off-by: Ben Hutchings <redacted>
Signed-off-by: Jonathan Nieder <redacted>
Cc: Mark Brown <redacted>
Cc: Marcelo Roberto Jimenez <redacted>
Cc: Thomas Gleixner <redacted>
Cc: John Stultz <redacted>
Acked-by: Alessandro Zummo <redacted>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/rtc/interface.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c@@ -227,11 +227,11 @@ int __rtc_read_alarm(struct rtc_device * alarm->time.tm_hour = now.tm_hour; /* For simplicity, only support date rollover for now */ - if (alarm->time.tm_mday == -1) { + if (alarm->time.tm_mday < 1 || alarm->time.tm_mday > 31) { alarm->time.tm_mday = now.tm_mday; missing = day; } - if (alarm->time.tm_mon == -1) { + if ((unsigned)alarm->time.tm_mon >= 12) { alarm->time.tm_mon = now.tm_mon; if (missing == none) missing = month;