From patchwork Fri Aug 12 21:04:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Waychison X-Patchwork-Id: 109898 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wy0-f184.google.com (mail-wy0-f184.google.com [74.125.82.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 030D1B70B7 for ; Sat, 13 Aug 2011 07:04:51 +1000 (EST) Received: by wyh15 with SMTP id 15sf1281796wyh.11 for ; Fri, 12 Aug 2011 14:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer: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; bh=FuT5LFVbrJ7E8TNQjb04ThwK/b3Mk02A6AxS1im29eY=; b=42UE8ykPVmpCZn28SXYEeAMBU1AVdRs/witK+McEm7vG3D1kRS4XwQrG2C7dFugcBr GbklnPlTCdmegpe+bxPPN/9y2enSGlyzuWY+nk75NUSmt/eGJSsrWwX9zdg2nPocm/sr zOsv5vzxj5yGBCDrr+LWxBUL9c44yCh67JfL4= Received: by 10.216.192.168 with SMTP id i40mr461168wen.17.1313183085882; Fri, 12 Aug 2011 14:04:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.14.24.77 with SMTP id w53ls4195eew.3.canary; Fri, 12 Aug 2011 14:04:44 -0700 (PDT) Received: by 10.14.148.10 with SMTP id u10mr45061eej.2.1313183084856; Fri, 12 Aug 2011 14:04:44 -0700 (PDT) Received: by 10.14.148.10 with SMTP id u10mr45059eej.2.1313183084839; Fri, 12 Aug 2011 14:04:44 -0700 (PDT) Received: from smtp-out.google.com (hpaq8.eem.corp.google.com [172.25.149.8]) by gmr-mx.google.com with ESMTPS id p1si4951254eeh.1.2011.08.12.14.04.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Aug 2011 14:04:44 -0700 (PDT) Received-SPF: pass (google.com: domain of mikew@google.com designates 172.25.149.8 as permitted sender) Received: from hpaq7.eem.corp.google.com (hpaq7.eem.corp.google.com [172.25.149.7]) by smtp-out.google.com with ESMTP id p7CL4ii4026978; Fri, 12 Aug 2011 14:04:44 -0700 Received: from mike2.sea.corp.google.com (mike2.sea.corp.google.com [172.31.71.68]) by hpaq7.eem.corp.google.com with ESMTP id p7CL4brC032392; Fri, 12 Aug 2011 14:04:38 -0700 Received: by mike2.sea.corp.google.com (Postfix, from userid 11438) id 217FD20A43; Fri, 12 Aug 2011 14:04:37 -0700 (PDT) From: Mike Waychison To: Alessandro Zummo Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, Mike Waychison Subject: [rtc-linux] [PATCH] rtc: Initialized rtc_time->tm_isdst Date: Fri, 12 Aug 2011 14:04:30 -0700 Message-Id: <1313183070-16724-1-git-send-email-mikew@google.com> X-Mailer: git-send-email 1.7.3.1 X-Original-Sender: mikew@google.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of mikew@google.com designates 172.25.149.8 as permitted sender) smtp.mail=mikew@google.com; dkim=pass (test mode) header.i=@google.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: , Even though the Linux kernel does not use the tm_isdst field, it is exposed as part of the ABI. This field can accidentally be left initialized, which is why we currently memset buffers returned to userland in rtc_read_time. There is a case however where the field can return garbage from the stack though when using the RTC_ALM_READ ioctl on the rtc device. This ioctl invokes rtc_read_alarm, which is careful to memset the rtc_wkalrm buffer that is copied to userland, but it then uses a struct copy to assign to alarm->time given the return value from rtc_ktime_to_tm(). rtc_ktime_to_tm() is implemented by calling rtc_time_to_tm using a derivative seconds counds from ktime, but rtc_time_to_tm does not assign a value to ->tm_isdst. This results in garbage from rtc_ktime_to_tm()'s frame ending up being copied out to userland as part of the returned rtc_wkalrm. Fix this by initializing rtc_time->tm_isdst to 0 in rtc_time_to_tm. Signed-off-by: Mike Waychison --- drivers/rtc/rtc-lib.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 075f170..c4cf057 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c @@ -85,6 +85,8 @@ void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) time -= tm->tm_hour * 3600; tm->tm_min = time / 60; tm->tm_sec = time - tm->tm_min * 60; + + tm->tm_isdst = 0; } EXPORT_SYMBOL(rtc_time_to_tm);