From: Geoff Levand <geoffrey.levand@am.sony.com>
To: Paul Mackerras <paulus@samba.org>
Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>,
"linuxppc-dev@ozlabs.org" <linuxppc-dev@ozlabs.org>
Subject: [patch v2] PS3: Fix printing of os-area magic numbers
Date: Thu, 22 Nov 2007 14:08:27 -0800 [thread overview]
Message-ID: <4745FDDB.7090208@am.sony.com> (raw)
In-Reply-To: <473F6A28.5000309@am.sony.com>
Fix a bug in the printing of the os-area magic numbers which assumed that
magic numbers were zero terminated strings. The magic numbers are represented
in memory as integers. If the os-area sections are not initialized correctly
they could contained random data that would be printed to the display.
CC: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
---
v2: handle unprintable chars.
Paul,
This fixes a very minor bug in linus' current tree. Please consider
for 2.6.24.
-Geoff
arch/powerpc/platforms/ps3/os-area.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
--- a/arch/powerpc/platforms/ps3/os-area.c
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -23,6 +23,7 @@
#include <linux/workqueue.h>
#include <linux/fs.h>
#include <linux/syscalls.h>
+#include <linux/ctype.h>
#include <asm/lmb.h>
@@ -269,8 +270,17 @@ static void __init os_area_get_property(
static void _dump_header(const struct os_area_header *h, const char *func,
int line)
{
+ u8 str[sizeof(h->magic_num) + 1];
+ u8 *s, *d;
+
+ for(s = h->magic_num, d = str; s < h->magic_num + sizeof(h->magic_num);
+ s++, d++) {
+ *d = isprint(*s) ? *s : '.';
+ }
+ d[sizeof(h->magic_num)] = 0;
+
pr_debug("%s:%d: h.magic_num: '%s'\n", func, line,
- h->magic_num);
+ str);
pr_debug("%s:%d: h.hdr_version: %u\n", func, line,
h->hdr_version);
pr_debug("%s:%d: h.db_area_offset: %u\n", func, line,
@@ -484,8 +494,17 @@ static int db_get_rtc_diff(const struct
static void _dump_db(const struct os_area_db *db, const char *func,
int line)
{
+ u8 str[sizeof(db->magic_num) + 1];
+ u8 *s, *d;
+
+ for(s = (u8*)&db->magic_num, d = str;
+ s < (u8*)&db->magic_num + sizeof(db->magic_num); s++, d++) {
+ *d = isprint(*s) ? *s : '.';
+ }
+ d[sizeof(db->magic_num)] = 0;
+
pr_debug("%s:%d: db.magic_num: '%s'\n", func, line,
- (const char*)&db->magic_num);
+ str);
pr_debug("%s:%d: db.version: %u\n", func, line,
db->version);
pr_debug("%s:%d: db.index_64: %u\n", func, line,
next prev parent reply other threads:[~2007-11-22 22:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-17 22:24 [patch] PS3: Fix printing of os-area magic numbers Geoff Levand
2007-11-18 9:33 ` Geert Uytterhoeven
2007-11-22 22:08 ` Geoff Levand [this message]
2007-12-21 4:44 ` [patch v2] " Paul Mackerras
2007-12-23 4:54 ` Geoff Levand
2007-12-23 5:09 ` [patch v3] " Geoff Levand
2007-12-23 9:51 ` Geert Uytterhoeven
2007-12-23 17:20 ` Geoff Levand
2007-12-23 17:41 ` [patch v4] " Geoff Levand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4745FDDB.7090208@am.sony.com \
--to=geoffrey.levand@am.sony.com \
--cc=Geert.Uytterhoeven@sonycom.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).