All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: loop boundary condition fix
@ 2018-06-23 20:49 Alexander Ploumistos
  2018-06-24  9:03 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Ploumistos @ 2018-06-23 20:49 UTC (permalink / raw)
  To: yamada.masahiro; +Cc: linux-kbuild, labbott, Jerry James, Alexander Ploumistos

From: Jerry James <loganjerry@gmail.com>

If buf[-1] just happens to hold the byte 0x0A, then nread can wrap around
to (size_t)-1, leading to invalid memory accesses.

This has caused segmentation faults when trying to build the latest
kernel snapshots for i686 in Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=1592374

Signed-off-by: Jerry James <loganjerry@gmail.com>
[alexpl@fedoraproject.org: reformatted patch for submission]
Signed-off-by: Alexander Ploumistos <alexpl@fedoraproject.org>
---
 scripts/kconfig/preprocess.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index 65da87fce907..5ca2df790d3c 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -156,7 +156,7 @@ static char *do_shell(int argc, char *argv[])
 		nread--;
 
 	/* remove trailing new lines */
-	while (buf[nread - 1] == '\n')
+	while (nread > 0 && buf[nread - 1] == '\n')
 		nread--;
 
 	buf[nread] = 0;
-- 
2.17.1


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

* Re: [PATCH] kconfig: loop boundary condition fix
  2018-06-23 20:49 [PATCH] kconfig: loop boundary condition fix Alexander Ploumistos
@ 2018-06-24  9:03 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2018-06-24  9:03 UTC (permalink / raw)
  To: Alexander Ploumistos; +Cc: Linux Kbuild mailing list, Laura Abbott, Jerry James

2018-06-24 5:49 GMT+09:00 Alexander Ploumistos <alexpl@fedoraproject.org>:
> From: Jerry James <loganjerry@gmail.com>
>
> If buf[-1] just happens to hold the byte 0x0A, then nread can wrap around
> to (size_t)-1, leading to invalid memory accesses.
>
> This has caused segmentation faults when trying to build the latest
> kernel snapshots for i686 in Fedora:
> https://bugzilla.redhat.com/show_bug.cgi?id=1592374
>
> Signed-off-by: Jerry James <loganjerry@gmail.com>
> [alexpl@fedoraproject.org: reformatted patch for submission]
> Signed-off-by: Alexander Ploumistos <alexpl@fedoraproject.org>
> ---

Applied to linux-kbuild/fixes.  Thanks!


>  scripts/kconfig/preprocess.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
> index 65da87fce907..5ca2df790d3c 100644
> --- a/scripts/kconfig/preprocess.c
> +++ b/scripts/kconfig/preprocess.c
> @@ -156,7 +156,7 @@ static char *do_shell(int argc, char *argv[])
>                 nread--;
>
>         /* remove trailing new lines */
> -       while (buf[nread - 1] == '\n')
> +       while (nread > 0 && buf[nread - 1] == '\n')
>                 nread--;
>
>         buf[nread] = 0;
> --
> 2.17.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2018-06-24  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-23 20:49 [PATCH] kconfig: loop boundary condition fix Alexander Ploumistos
2018-06-24  9:03 ` Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.