mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gen_init_cpio: stop parsing on lines with a missing argument list
@ 2026-10-05  8:57 lzhan011
  2026-10-07  9:26 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: lzhan011 @ 2026-10-05  8:57 UTC (permalink / raw)
  To: nathan, nsc; +Cc: linux-kbuild, linux-kernel

When a line in the cpio list consists of a file type followed only by
whitespace and no newline (e.g. "slink " as the last line of the file),
strtok(NULL, "\n") returns NULL. main() prints an error and sets ec, but
then carries on and passes the NULL args pointer to the type handler,
which hands it to sscanf() and crashes:

  AddressSanitizer: SEGV on unknown address 0x000000000000
    #4 __isoc99_sscanf
    #5 cpio_mkslink_line usr/gen_init_cpio.c:169

Break out of the loop as is already done for the other format error, so
that the error is reported and gen_init_cpio exits with a failure status.

Found by fuzzing gen_init_cpio built with ASan/UBSan.

Reproducer:
  printf 'slink ' > list && usr/gen_init_cpio list

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by: Claude:claude-opus-5-5 ASan UBSan
Signed-off-by: lzhan011 <lzsx618@gmail.com>
---
 usr/gen_init_cpio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index b7296edc6..0f0c61ec2 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -756,6 +756,7 @@ int main (int argc, char *argv[])
 				"ERROR: incorrect format, newline required line %d: '%s'\n",
 				line_nr, line);
 			ec = -1;
+			break;
 		}
 
 		for (type_idx = 0; file_handler_table[type_idx].type; type_idx++) {
-- 
2.34.1


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

* Re: [PATCH] gen_init_cpio: stop parsing on lines with a missing argument list
  2026-10-05  8:57 [PATCH] gen_init_cpio: stop parsing on lines with a missing argument list lzhan011
@ 2026-10-07  9:26 ` Nathan Chancellor
       [not found]   ` <CAGD6qbRTat70Uf7Ax_e+M0pphwJN9s5+iyWM_3ELPQGm3YjdFw@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2026-10-07  9:26 UTC (permalink / raw)
  To: nsc, lzhan011; +Cc: linux-kbuild, linux-kernel

On Mon, 05 Oct 2026 03:57:29 -0500, lzhan011 wrote:
> gen_init_cpio: stop parsing on lines with a missing argument list

Applied to

  https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-next-unstable

Thanks!

[1/1] gen_init_cpio: stop parsing on lines with a missing argument list
      https://git.kernel.org/kbuild/c/4677a58a643f9

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped or
reverted. Patches applied to an "unstable" branch are accepted pending
wider testing in -next and any post-commit review; they will generally
be moved to the main branch in a week if no issues are found.

Best regards,
-- 
Cheers,
Nathan



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

* Re: [PATCH] gen_init_cpio: stop parsing on lines with a missing argument list
       [not found]   ` <CAGD6qbRTat70Uf7Ax_e+M0pphwJN9s5+iyWM_3ELPQGm3YjdFw@mail.gmail.com>
@ 2026-10-07 10:18     ` Nathan Chancellor
  0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2026-10-07 10:18 UTC (permalink / raw)
  To: LZ; +Cc: nsc, linux-kbuild, linux-kernel

On Wed, Oct 07, 2026 at 04:59:05AM -0500, LZ wrote:
> Hi Nathan,
> 
> Thanks for applying the patch. I noticed that I submitted it with my
> username lzhan011 as the author/sign-off name. For proper attribution, my
> name should be Leizhen Zhang <lzsx618@gmail.com>.
> 
> Would you prefer that I resend the patch with the corrected
> author/sign-off, or is it possible to amend it in the tree? Thank you so
> much for your help.

I have updated the patch in the Kbuild tree, as it was at the top.

  https://git.kernel.org/kbuild/c/c8dd1aa0274d8ad3df82ec1b064065f410ce99ed

Please note this is incorrect for all of the other changes you have
sent, so you will need to resend them. You did not include the Kconfig
reviewer Julian Braha on the patches touching scripts/kconfig, so please
include him when you resend.

-- 
Cheers,
Nathan

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

end of thread, other threads:[~2026-10-07 10:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05  8:57 [PATCH] gen_init_cpio: stop parsing on lines with a missing argument list lzhan011
2026-10-07  9:26 ` Nathan Chancellor
     [not found]   ` <CAGD6qbRTat70Uf7Ax_e+M0pphwJN9s5+iyWM_3ELPQGm3YjdFw@mail.gmail.com>
2026-10-07 10:18     ` Nathan Chancellor

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®