lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 29 May 2013 15:53:11 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Sergey Yanovich <ynvich@...il.com>
Cc:	rtc-linux@...glegroups.com, linux-kernel@...r.kernel.org,
	Marc Zyngier <maz@...terjones.org>,
	Alessandro Zummo <a.zummo@...ertech.it>,
	Sachin Kamat <sachin.kamat@...aro.org>,
	Jingoo Han <jg1.han@...sung.com>
Subject: Re: [PATCH] rtc-ds1302: handle write protection

On Tue, 21 May 2013 03:21:30 +0400 Sergey Yanovich <ynvich@...il.com> wrote:

> This chip has a control register and can prevent altering saved clock.
> Without this patch we could have:
> ----8<----
> (arm)root@...14:~# date
> Tue May 21 03:08:27 MSK 2013
> (arm)root@...14:~# /etc/init.d/hwclock.sh show
> Tue May 21 11:13:58 2013  -0.067322 seconds
> (arm)root@...14:~# /etc/init.d/hwclock.sh stop
> [info] Saving the system clock.
> [info] Hardware Clock updated to Tue May 21 03:09:01 MSK 2013.
> (arm)root@...14:~# /etc/init.d/hwclock.sh show
> Tue May 21 11:14:15 2013  -0.624272 seconds
> ----8<----
>
> ...
>
> --- a/drivers/rtc/rtc-ds1302.c
> +++ b/drivers/rtc/rtc-ds1302.c
> @@ -23,8 +23,12 @@
>  #define	RTC_CMD_READ	0x81		/* Read command */
>  #define	RTC_CMD_WRITE	0x80		/* Write command */
>  
> +#define	RTC_CMD_WRITE_ENABLE	0x00		/* Write enable */
> +#define	RTC_CMD_WRITE_DISABLE	0x80		/* Write disable */
> +
>  #define RTC_ADDR_RAM0	0x20		/* Address of RAM0 */
>  #define RTC_ADDR_TCR	0x08		/* Address of trickle charge register */
> +#define	RTC_ADDR_CTRL	0x07		/* Address of control register */
>  #define	RTC_ADDR_YEAR	0x06		/* Address of year register */
>  #define	RTC_ADDR_DAY	0x05		/* Address of day of week register */
>  #define	RTC_ADDR_MON	0x04		/* Address of month register */
> @@ -313,6 +317,7 @@ static int __init ds1302_rtc_probe(struct platform_device *pdev)
>  		return PTR_ERR(rtc);
>  
>  	platform_set_drvdata(pdev, rtc);
> +	ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_ENABLE);
>  
>  	return 0;
>  }
> @@ -321,6 +326,7 @@ static int ds1302_rtc_remove(struct platform_device *pdev)
>  {
>  	struct rtc_device *rtc = platform_get_drvdata(pdev);
>  
> +	ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_DISABLE);
>  	rtc_device_unregister(rtc);
>  	platform_set_drvdata(pdev, NULL);

ds1302_rtc_remove() no longer exists in my tree - it got whittled away
to nothing by
http://ozlabs.org/~akpm/mmots/broken-out/rtc-rtc-ds1302-remove-unnecessary-platform_set_drvdata.patch
and
http://ozlabs.org/~akpm/mmots/broken-out/drivers-rtc-rtc-ds1302c-remove-empty-function.patch

Perhaps it should be re-added for this?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ