mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/cmdline: prevent unintented access to address
       [not found] <CGME20200812025432epcas1p1b810c6b94adf533d5cae3ef6a24ca9a2@epcas1p1.samsung.com>
@ 2020-08-12  2:54 ` Seungil Kang
  2020-08-12  8:51   ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Seungil Kang @ 2020-08-12  2:54 UTC (permalink / raw)
  To: bhe, mingo
  Cc: akpm, gregkh, herbert, andriy.shevchenko, tglx, linux-kernel,
	Seungil Kang

When args = "\"\0", "i" will be 0 and args[i-1] is used (line:238)
Because of "i" is an unsigned int type,
the function will access at args[0xFFFFFFFF]
It can make a crash

Signed-off-by: Seungil Kang <sil.kang@samsung.com>
---
 lib/cmdline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cmdline.c b/lib/cmdline.c
index fbb9981a04a4..2fd29d7723b2 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -200,7 +200,7 @@ bool parse_option_str(const char *str, const char *option)
  */
 char *next_arg(char *args, char **param, char **val)
 {
-	unsigned int i, equals = 0;
+	int i, equals = 0;
 	int in_quote = 0, quoted = 0;
 	char *next;
 
-- 
2.17.1


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

* Re: [PATCH] lib/cmdline: prevent unintented access to address
  2020-08-12  2:54 ` [PATCH] lib/cmdline: prevent unintented access to address Seungil Kang
@ 2020-08-12  8:51   ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2020-08-12  8:51 UTC (permalink / raw)
  To: Seungil Kang; +Cc: bhe, mingo, akpm, gregkh, herbert, tglx, linux-kernel

On Wed, Aug 12, 2020 at 11:54:02AM +0900, Seungil Kang wrote:

Thanks for the patch, my comments below.

> When args = "\"\0", "i" will be 0 and args[i-1] is used (line:238)

Can you be less ambiguous with the args value? (Perhaps provide a hexdump of it
for better understanding)

> Because of "i" is an unsigned int type,
> the function will access at args[0xFFFFFFFF]
> It can make a crash

Please, use proper punctuation, I'm lost where is the sentence and what are the
logical parts of them.

Can you point out to the code that calls this and leads to a crash?

>  lib/cmdline.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Can you provide a KUnit test module which can check the case?

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2020-08-12  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200812025432epcas1p1b810c6b94adf533d5cae3ef6a24ca9a2@epcas1p1.samsung.com>
2020-08-12  2:54 ` [PATCH] lib/cmdline: prevent unintented access to address Seungil Kang
2020-08-12  8:51   ` Andy Shevchenko

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

all inboxes | Powered by JetHome®