From patchwork Sat Dec 31 00:35:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Nieder X-Patchwork-Id: 133705 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-iy0-f184.google.com (mail-iy0-f184.google.com [209.85.210.184]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 3EF2AB6FC5 for ; Sat, 31 Dec 2011 11:36:04 +1100 (EST) Received: by iaeo4 with SMTP id o4sf50178417iae.11 for ; Fri, 30 Dec 2011 16:36:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:date:from:to:cc:subject:message-id :references:mime-version:in-reply-to:user-agent:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type:content-disposition; bh=7bIq4PQgmgYwcNZrHlQ1IVxUb6x7BABPLjQ/K9WXn6Y=; b=DeDyq8tGTFM7DAf4uRg1a6W5OzabLwv8E59ZPV03WBkPdkaEpTvc8OhUrhqbv41sTm UFQw49Hr8zDgk5cnAKjri37aTcfqF8rNxi6gvvoATq1TF7UU/IHoJu5OSD1xSXBS5WDG kB+Ls+G069oK0LfD5WrZfAtHHUwWrFPsQTufs= Received: by 10.50.135.102 with SMTP id pr6mr12365890igb.1.1325291760225; Fri, 30 Dec 2011 16:36:00 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.178.42 with SMTP id cv10ls11306845igc.2.gmail; Fri, 30 Dec 2011 16:35:59 -0800 (PST) Received: by 10.42.144.198 with SMTP id c6mr26982766icv.1.1325291759824; Fri, 30 Dec 2011 16:35:59 -0800 (PST) Received: by 10.42.144.198 with SMTP id c6mr26982765icv.1.1325291759813; Fri, 30 Dec 2011 16:35:59 -0800 (PST) Received: from mail-iy0-f175.google.com (mail-iy0-f175.google.com [209.85.210.175]) by gmr-mx.google.com with ESMTPS id wm10si18681765igc.1.2011.12.30.16.35.59 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Dec 2011 16:35:59 -0800 (PST) Received-SPF: pass (google.com: domain of jrnieder@gmail.com designates 209.85.210.175 as permitted sender) client-ip=209.85.210.175; Received: by iakh37 with SMTP id h37so22370028iak.6 for ; Fri, 30 Dec 2011 16:35:59 -0800 (PST) Received: by 10.50.180.167 with SMTP id dp7mr48287640igc.26.1325291759662; Fri, 30 Dec 2011 16:35:59 -0800 (PST) Received: from elie.Belkin (c-67-180-61-129.hsd1.ca.comcast.net. [67.180.61.129]) by mx.google.com with ESMTPS id z22sm133274765ibg.5.2011.12.30.16.35.58 (version=SSLv3 cipher=OTHER); Fri, 30 Dec 2011 16:35:59 -0800 (PST) Date: Fri, 30 Dec 2011 18:35:52 -0600 From: Jonathan Nieder To: "P." Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, Alessandro Zummo , John Stultz , Ben Hutchings Subject: [rtc-linux] [PATCH resend] rtc: Fix alarm rollover when day or month is out-of-range Message-ID: <20111231003552.GB22266@elie.Belkin> References: <1325289236.85273.YahooMailClassic@web27003.mail.ukl.yahoo.com> MIME-Version: 1.0 In-Reply-To: <1325289236.85273.YahooMailClassic@web27003.mail.ukl.yahoo.com> User-Agent: Mutt/1.5.21+51 (9e756d1adb76) (2011-07-01) X-Original-Sender: jrnieder@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jrnieder@gmail.com designates 209.85.210.175 as permitted sender) smtp.mail=jrnieder@gmail.com; dkim=pass (test mode) header.i=@gmail.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Disposition: inline From: Ben Hutchings Date: Thu, 29 Dec 2011 16:41:56 +0100 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 , Reported-by: leo weppelman Reported-by: "P. van Gaans" Cc: stable@vger.kernel.org Signed-off-by: Ben Hutchings Signed-off-by: Jonathan Nieder --- P. wrote: > Following the advice from Jonathan Nieder I am sending this mail. Old advice. :) Here's a patch that was sent to the rtc-linux list, but I can't seem to find it with search.gmane.org. drivers/rtc/interface.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 3bcc7cfcaba7..67b68c4543d0 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -232,11 +232,11 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) 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;