Commit 38e8a56e authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] PPC64 rtasd: window when error_log_cnt could get zeroed

This patch is from Jake Moilanen <moilanen@austin.ibm.com>.

There appears to be a hole that if we get an log_error() call, that we could
zero out our error log count in nvram. 

When rtasd() starts up, it turns on the logging via 'no_more_logging = 0'.  If
we get a log_error() call after that is set but before nvram_read_error_log
has actually read nvram to set error_log_cnt, the log_error() call will write
back to nvram a uninitialized error_log_cnt value, and wipe out our sequence
number.

To close the hole, simply move the 'no_more_logging = 0' till after nvram sets
error_log_cnt but before pSeries_log_error is called.

I also changed the 'no_more_logging' variable to be 'no_logging' since it's
not only used when we stop logging now.  I also removed the "volatile" part of
no_more_logging, since it's unneeded.  
Signed-off-by: default avatarJake Moilanen <moilanen@austin.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c96eeb20
......@@ -43,9 +43,9 @@ static struct nvram_partition * nvram_part;
static long nvram_error_log_index = -1;
static long nvram_error_log_size = 0;
volatile int no_more_logging = 1; /* Until we initialize everything,
* make sure we don't try logging
* anything */
int no_logging = 1; /* Until we initialize everything,
* make sure we don't try logging
* anything */
extern volatile int error_log_cnt;
......@@ -640,7 +640,7 @@ int nvram_write_error_log(char * buff, int length, unsigned int err_type)
loff_t tmp_index;
struct err_log_info info;
if (no_more_logging) {
if (no_logging) {
return -EPERM;
}
......
......@@ -48,7 +48,7 @@ static unsigned int rtas_error_log_buffer_max;
static int full_rtas_msgs = 0;
extern volatile int no_more_logging;
extern int no_logging;
volatile int error_log_cnt = 0;
......@@ -213,7 +213,7 @@ void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
}
/* Write error to NVRAM */
if (!no_more_logging && !(err_type & ERR_FLAG_BOOT))
if (!no_logging && !(err_type & ERR_FLAG_BOOT))
nvram_write_error_log(buf, len, err_type);
/*
......@@ -225,8 +225,8 @@ void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
printk_log_rtas(buf, len);
/* Check to see if we need to or have stopped logging */
if (fatal || no_more_logging) {
no_more_logging = 1;
if (fatal || no_logging) {
no_logging = 1;
spin_unlock_irqrestore(&rtasd_log_lock, s);
return;
}
......@@ -299,7 +299,7 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
spin_lock_irqsave(&rtasd_log_lock, s);
/* if it's 0, then we know we got the last one (the one in NVRAM) */
if (rtas_log_size == 0 && !no_more_logging)
if (rtas_log_size == 0 && !no_logging)
nvram_clear_error_log();
spin_unlock_irqrestore(&rtasd_log_lock, s);
......@@ -417,9 +417,6 @@ static int rtasd(void *unused)
goto error;
}
/* We can use rtas_log_buf now */
no_more_logging = 0;
printk(KERN_ERR "RTAS daemon started\n");
DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2);
......@@ -428,6 +425,10 @@ static int rtasd(void *unused)
memset(logdata, 0, rtas_error_log_max);
rc = nvram_read_error_log(logdata, rtas_error_log_max, &err_type);
/* We can use rtas_log_buf now */
no_logging = 0;
if (!rc) {
if (err_type != ERR_FLAG_ALREADY_LOGGED) {
pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
......
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