mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fs: Fix link_path_walk to return -ENOENT on empty path
@ 2021-04-17 23:34 Jules Maselbas
  2021-05-03 12:45 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Jules Maselbas @ 2021-04-17 23:34 UTC (permalink / raw)
  To: barebox; +Cc: Neeraj Pal, Jules Maselbas

link_path_walk was returning 0 when passed with an empty path,
this lead calling code to assume that the struct nameidata nd
is valid and thus has a `last` field populated, which is not.
In the end causing a runtime crash.

This issue can easily be reproduced by running the command:
cat ""

Reported-by: Neeraj Pal <neerajpal09@gmail.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 fs/fs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index a02332491..6de5a3b59 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1928,6 +1928,8 @@ static int link_path_walk(const char *name, struct nameidata *nd)
 	int err;
 	char separator = '/';
 
+	if (!*name)
+		return -ENOENT;
 	while (*name=='/')
 		name++;
 	if (!*name)
-- 
2.17.1



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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs: Fix link_path_walk to return -ENOENT on empty path
  2021-04-17 23:34 [PATCH] fs: Fix link_path_walk to return -ENOENT on empty path Jules Maselbas
@ 2021-05-03 12:45 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2021-05-03 12:45 UTC (permalink / raw)
  To: Jules Maselbas; +Cc: barebox, Neeraj Pal

On Sun, Apr 18, 2021 at 01:34:09AM +0200, Jules Maselbas wrote:
> link_path_walk was returning 0 when passed with an empty path,
> this lead calling code to assume that the struct nameidata nd
> is valid and thus has a `last` field populated, which is not.
> In the end causing a runtime crash.
> 
> This issue can easily be reproduced by running the command:
> cat ""
> 
> Reported-by: Neeraj Pal <neerajpal09@gmail.com>
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
>  fs/fs.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/fs/fs.c b/fs/fs.c
> index a02332491..6de5a3b59 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -1928,6 +1928,8 @@ static int link_path_walk(const char *name, struct nameidata *nd)
>  	int err;
>  	char separator = '/';
>  
> +	if (!*name)
> +		return -ENOENT;
>  	while (*name=='/')
>  		name++;
>  	if (!*name)
> -- 
> 2.17.1
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 2+ messages in thread

end of thread, other threads:[~2021-05-03 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-17 23:34 [PATCH] fs: Fix link_path_walk to return -ENOENT on empty path Jules Maselbas
2021-05-03 12:45 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox