Commit 4685ee17 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] RTC leaks.

From: Russell King, Tom Rini, Dave Jones

As plugged in 2.4 recently.

Fix some leakage of uninitialised memory to userspace via rtc reads.
parent 1fbe06d4
......@@ -342,6 +342,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
{
struct rtc_time rtc_tm;
memset(&rtc_tm, 0, sizeof (struct rtc_time));
get_rtc_time(&rtc_tm);
if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
return -EFAULT;
......
......@@ -219,6 +219,7 @@ pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned
unsigned long flags;
struct rtc_time tm;
memset(&tm, 0, sizeof (struct rtc_time));
if (!capable(CAP_SYS_TIME))
return -EPERM;
......
......@@ -53,6 +53,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
/* Ensure clock and real-time-mode-register are accessible */
msr = rtc->msr & 0xc0;
rtc->msr = 0x40;
memset(&wtime, 0, sizeof(struct rtc_time));
do {
wtime.tm_sec = BCD2BIN(rtc->bcd_sec);
wtime.tm_min = BCD2BIN(rtc->bcd_min);
......
......@@ -51,6 +51,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
local_irq_save(flags);
/* Ensure clock and real-time-mode-register are accessible */
rtc->ctrl = RTC_READ;
memset(&wtime, 0, sizeof(struct rtc_time));
wtime.tm_sec = BCD2BIN(rtc->bcd_sec);
wtime.tm_min = BCD2BIN(rtc->bcd_min);
wtime.tm_hour = BCD2BIN(rtc->bcd_hr);
......
......@@ -99,6 +99,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
switch (cmd) {
case RTC_RD_TIME: /* Read the time/date from RTC */
{
memset(&wtime, 0, sizeof(struct rtc_time));
ppc_md.get_rtc_time(&wtime);
break;
}
......
......@@ -167,6 +167,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file,
break;
case RTC_RD_TIME:
memset(&rtctm, 0, sizeof(struct rtc_time));
get_rtc_time(&rtc_raw, &year);
rtctm.tm_sec = rtc_raw.secs;
rtctm.tm_min = rtc_raw.mins;
......
......@@ -118,6 +118,7 @@ convert_to_efi_time(struct rtc_time *wtime, efi_time_t *eft)
static void
convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime)
{
memset(wtime, 0, sizeof(*wtime));
wtime->tm_sec = eft->second;
wtime->tm_min = eft->minute;
wtime->tm_hour = eft->hour;
......
......@@ -431,7 +431,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
* means "don't care" or "match all". Only the tm_hour,
* tm_min, and tm_sec values are filled in.
*/
memset(&wtime, 0, sizeof(struct rtc_time));
get_rtc_alm_time(&wtime);
break;
}
......@@ -481,6 +481,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
}
case RTC_RD_TIME: /* Read the time/date from RTC */
{
memset(&wtime, 0, sizeof(struct rtc_time));
rtc_get_rtc_time(&wtime);
break;
}
......
......@@ -89,6 +89,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
switch (cmd)
{
case RTCGET:
memset(&rtc_tm, 0, sizeof(struct rtc_time));
get_rtc_time(&rtc_tm);
if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment