* [PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing
@ 2018-03-18 22:22 Gaël PORTAY
2018-03-19 8:36 ` Sascha Hauer
2018-03-27 7:17 ` Antony Pavlov
0 siblings, 2 replies; 4+ messages in thread
From: Gaël PORTAY @ 2018-03-18 22:22 UTC (permalink / raw)
To: barebox; +Cc: Gaël PORTAY
In __canonicalize_path() we dereference the pointer returned by
get_fsdevice_by_path() without checking if the pointer is NULL or not.
When the pointer is NULL it leads to an Ooops.
Ooops, address error on load or ifetch!
$ 0 : 00000000 00000001 a0000026 a0811c10
$ 4 : a0402e60 a0402e48 a0811c00 a0402e58
$ 8 : 00000001 00000000 0000005a 00000023
$12 : 00000000 00000002 00601021 00000000
$16 : a0402e60 a0402e50 a0402e39 a0810000
$20 : a0402e38 a0811420 a0811424 00000000
$24 : 00000000 a080de10
$28 : 87f87d40 a03ffa68 a0810000 a080ce30
Hi : 00000002
Lo : 00000000
epc : a080ce34
ra : a080ce30
Status: 00000006
Cause : 40008010
Config: 80040483
### ERROR ### Please RESET the board ###
Fixes: d79a81736 fs: Don't bother filesystems without link support with additional stat() calls
Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
---
fs/fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/fs.c b/fs/fs.c
index 88f0b1478..5135112c8 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -191,7 +191,7 @@ static char *__canonicalize_path(const char *_pathname, int level)
* with an additional stat() call.
*/
fsdev = get_fsdevice_by_path(outpath);
- if (!fsdev->driver->readlink)
+ if (!fsdev || !fsdev->driver->readlink)
continue;
ret = __lstat(outpath, &s);
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing
2018-03-18 22:22 [PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing Gaël PORTAY
@ 2018-03-19 8:36 ` Sascha Hauer
2018-03-19 9:06 ` Gaël PORTAY
2018-03-27 7:17 ` Antony Pavlov
1 sibling, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2018-03-19 8:36 UTC (permalink / raw)
To: Gaël PORTAY; +Cc: barebox
Hi Gaël,
On Sun, Mar 18, 2018 at 06:22:36PM -0400, Gaël PORTAY wrote:
> In __canonicalize_path() we dereference the pointer returned by
> get_fsdevice_by_path() without checking if the pointer is NULL or not.
> When the pointer is NULL it leads to an Ooops.
>
> Ooops, address error on load or ifetch!
>
> $ 0 : 00000000 00000001 a0000026 a0811c10
> $ 4 : a0402e60 a0402e48 a0811c00 a0402e58
> $ 8 : 00000001 00000000 0000005a 00000023
> $12 : 00000000 00000002 00601021 00000000
> $16 : a0402e60 a0402e50 a0402e39 a0810000
> $20 : a0402e38 a0811420 a0811424 00000000
> $24 : 00000000 a080de10
> $28 : 87f87d40 a03ffa68 a0810000 a080ce30
> Hi : 00000002
> Lo : 00000000
> epc : a080ce34
> ra : a080ce30
> Status: 00000006
> Cause : 40008010
> Config: 80040483
>
> ### ERROR ### Please RESET the board ###
>
> Fixes: d79a81736 fs: Don't bother filesystems without link support with additional stat() calls
>
> Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
> ---
> fs/fs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
I wonder though what calls into the filesystem layer before / is
mounted in your case.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing
2018-03-19 8:36 ` Sascha Hauer
@ 2018-03-19 9:06 ` Gaël PORTAY
0 siblings, 0 replies; 4+ messages in thread
From: Gaël PORTAY @ 2018-03-19 9:06 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hi Sascha,
On Mon, Mar 19, 2018 at 09:36:29AM +0100, Sascha Hauer wrote:
> ...
> I wonder though what calls into the filesystem layer before / is
> mounted in your case.
>
The issue is trigger by function stat() in start_barebox(), right before
I expect to have a shell.
Here.
if (IS_ENABLED(CONFIG_COMMAND_SUPPORT)) {
pr_info("running /env/bin/init...\n");
if (!stat("/env/bin/init", &s))
run_command("source /env/bin/init");
else
pr_err("/env/bin/init not found\n");
}
My configuration is very minimal for now. I do not have (yet) any FS
selected (excepted devfs) and I do not have any root device mounted
either in this configuration.
I guess this is why fs_dev_root is NULL and why get_fsdevice_by_path()
returns fs_dev_root (because there is nothing to iterate in list
fs_device_list).
Gael
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing
2018-03-18 22:22 [PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing Gaël PORTAY
2018-03-19 8:36 ` Sascha Hauer
@ 2018-03-27 7:17 ` Antony Pavlov
1 sibling, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2018-03-27 7:17 UTC (permalink / raw)
To: Gaël PORTAY; +Cc: barebox
On Sun, 18 Mar 2018 18:22:36 -0400
Gaël PORTAY <gael.portay@savoirfairelinux.com> wrote:
> In __canonicalize_path() we dereference the pointer returned by
> get_fsdevice_by_path() without checking if the pointer is NULL or not.
> When the pointer is NULL it leads to an Ooops.
>
> Ooops, address error on load or ifetch!
>
> $ 0 : 00000000 00000001 a0000026 a0811c10
> $ 4 : a0402e60 a0402e48 a0811c00 a0402e58
> $ 8 : 00000001 00000000 0000005a 00000023
> $12 : 00000000 00000002 00601021 00000000
> $16 : a0402e60 a0402e50 a0402e39 a0810000
> $20 : a0402e38 a0811420 a0811424 00000000
> $24 : 00000000 a080de10
> $28 : 87f87d40 a03ffa68 a0810000 a080ce30
> Hi : 00000002
> Lo : 00000000
> epc : a080ce34
Salut Gaël!
It looks like you use MIPS board.
Your epc == 0xa080ce34 is inside KSEG1 region (uncached memory).
May be there is no cache support in current barebox for your CPU.
Which CPU core you use?
Très cordialement,
Antony Pavlov
> ra : a080ce30
> Status: 00000006
> Cause : 40008010
> Config: 80040483
>
> ### ERROR ### Please RESET the board ###
>
> Fixes: d79a81736 fs: Don't bother filesystems without link support with additional stat() calls
>
> Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
> ---
> fs/fs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/fs.c b/fs/fs.c
> index 88f0b1478..5135112c8 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -191,7 +191,7 @@ static char *__canonicalize_path(const char *_pathname, int level)
> * with an additional stat() call.
> */
> fsdev = get_fsdevice_by_path(outpath);
> - if (!fsdev->driver->readlink)
> + if (!fsdev || !fsdev->driver->readlink)
> continue;
>
> ret = __lstat(outpath, &s);
> --
> 2.16.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-27 7:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-18 22:22 [PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing Gaël PORTAY
2018-03-19 8:36 ` Sascha Hauer
2018-03-19 9:06 ` Gaël PORTAY
2018-03-27 7:17 ` Antony Pavlov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox