mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Jarzmik <robert.jarzmik@free.fr>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: Ramfs and NULL pointer
Date: Tue, 20 Nov 2012 21:43:14 +0100	[thread overview]
Message-ID: <87lidwdmzh.fsf@free.fr> (raw)
In-Reply-To: <20121104225614.GU1641@pengutronix.de> (Sascha Hauer's message of "Sun, 4 Nov 2012 23:56:14 +0100")

[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]

Sascha Hauer <s.hauer@pengutronix.de> writes:

> On Sun, Nov 04, 2012 at 07:48:07PM +0100, Robert Jarzmik wrote:
>> Robert Jarzmik <robert.jarzmik@free.fr> writes:
>> 
>> > Hi there,
>> >
>> > Lately, I see null pointer dereferences in barebox.
>> > I traced the culprit to ramfs ...
>> 
>> Ah and if I take back v2012.09.0, the problem disappears. 
>> I'm not fully in the mood for a bisection of 544 commits ... any idea ?
>
> sha@dude:~/dude/barebox/barebox git lg v2012.09.0..origin/master fs/ramfs.c
> 77322aa Treewide: remove address of the Free Software Foundation
> ad6c28a ramfs: add symlink and readlink support
>
> Both look harmless, so I don't think that the culprit is ramfs itself.
>
> Sorry, no idea. The good news is that due to my compile tests all 544
> commits at least should compile ;)
>
> Do you have some specific command sequence to provoke this?
One part of the problem is a memory corruption from recent commits on
splash/bmp.

Please have a look at the attached patch. I joined Jean-Christophe, as he is the
original author AFAICS, and he might think of another regression along this
patchset which could lighten my debugging sessions.

My board still doesn't boot correctly, so there's probably another regression.

Cheers.

--
Robert


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-splash-fix-splash-breakage.patch --]
[-- Type: text/x-diff, Size: 1004 bytes --]

From bc2f570bf4bd20c7ce2ead6c35d7cd7274ed1594 Mon Sep 17 00:00:00 2001
From: Robert Jarzmik <robert.jarzmik@free.fr>
Date: Tue, 20 Nov 2012 21:33:49 +0100
Subject: [PATCH] splash: fix splash breakage

Commit 3fa8d74a introduced structures screen and surface.
Unfortunately, these structures are allocated on the stack,
and not initialized.

As a consequence, sc->offscreen might contain a random
value, which is used later for memcpy operations, corrupting
memory.

Fix it by initializing the structures.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 commands/splash.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/commands/splash.c b/commands/splash.c
index 65dd530..b0830fb 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -49,6 +49,8 @@ static int do_splash(int argc, char *argv[])
 	}
 	image_file = argv[optind];
 
+	memset(&sc, 0, sizeof(sc));
+	memset(&s, 0, sizeof(s));
 	fd = fb_open(fbdev, &sc, offscreen);
 	if (fd < 0) {
 		perror("fd_open");
-- 
1.7.10.4


[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-11-20 20:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-04 17:53 Robert Jarzmik
2012-11-04 18:48 ` Robert Jarzmik
2012-11-04 22:56   ` Sascha Hauer
2012-11-05  8:23     ` Robert Jarzmik
2012-11-20 20:43     ` Robert Jarzmik [this message]
2012-11-20 20:50       ` Robert Jarzmik

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=87lidwdmzh.fsf@free.fr \
    --to=robert.jarzmik@free.fr \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    --cc=s.hauer@pengutronix.de \
    /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