All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
To: Wang YanQing <udknight@gmail.com>
Cc: jbarnes@sgi.com, tjd21@cl.cam.ac.uk, khalid.aziz@hp.com,
	kexec@lists.infradead.org, horms@verge.net.au,
	ebiederm@xmission.com, hari@in.ibm.com,
	Zhang Yanfei <zhangyanfei.yes@gmail.com>
Subject: Re: [PATCH] i386:kexec-bzImage: Use "\0" as command line instead of empty command line
Date: Mon, 08 Apr 2013 14:43:48 +0800	[thread overview]
Message-ID: <51626724.7070902@cn.fujitsu.com> (raw)
In-Reply-To: <20130408060729.GA2334@udknight>

于 2013年04月08日 14:07, Wang YanQing 写道:
> On Mon, Apr 08, 2013 at 12:33:40PM +0800, Zhang Yanfei wrote:
>> I think this is ok for we have filled all the real_mode buffer with 0.
> I don't think so, it must be somethings wrong, if we had filled all
> the real_mode buffer with 0, why do we need my patch to set 
> the string termination guard '\0'? 

real_mode = kernel16 buf + commandline + purgatory commandline.

At first, we filled all real_mode buffer with 0, then we assigned values
to kernel16 buf just in the head of real_mode.
And next, we copied the commandline just after the kernel16 buf. Usually,
when we copy a string into a buffer, we will set the string termination
guard '\0' right after the string in the buffer for safety, I think.

As your patch, If we have no commandline, and just assign it to '\0'. It
prevents the problems to happen below:

In setup_linux_bootloader_parameters_high

120         cmdline_ptr = ((char *)real_mode) + cmdline_offset;
121         memcpy(cmdline_ptr, cmdline, cmdline_len);
122         cmdline_ptr[cmdline_len - 1] = '\0';

if cmdline_len == 0, Line 122 will corrupt kernel16 buf just before the commandline.

And in do_bzImage_load, for example,

369         cmdline_end = setup_base + kern16_size_needed + command_line_len - 1;
370         elf_rel_set_symbol(&info->rhdr, "cmdline_end", &cmdline_end,
371                            sizeof(unsigned long));

Line 369 will go wrong, too.

> 
> Does '\0' equal zero, right?

Yeah, if we write '\0', the value store into the char buf is zero, I think.

Correct me if I am wrong, please.

Thanks
Zhang

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

  reply	other threads:[~2013-04-08  6:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03  9:43 [PATCH] i386:kexec-bzImage: Use "\0" as command line instead of empty command line Wang YanQing
2013-04-06  5:52 ` Zhang Yanfei
2013-04-07  1:01   ` Wang YanQing
2013-04-07  5:54     ` Zhang Yanfei
2013-04-07  9:35       ` Wang YanQing
2013-04-08  1:08         ` Wang YanQing
2013-04-08  3:35           ` Zhang Yanfei
2013-04-08  3:53             ` Wang YanQing
2013-04-08  4:33               ` Zhang Yanfei
2013-04-08  6:07                 ` Wang YanQing
2013-04-08  6:43                   ` Zhang Yanfei [this message]
2013-04-08  4:18             ` Wang YanQing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51626724.7070902@cn.fujitsu.com \
    --to=zhangyanfei@cn.fujitsu.com \
    --cc=ebiederm@xmission.com \
    --cc=hari@in.ibm.com \
    --cc=horms@verge.net.au \
    --cc=jbarnes@sgi.com \
    --cc=kexec@lists.infradead.org \
    --cc=khalid.aziz@hp.com \
    --cc=tjd21@cl.cam.ac.uk \
    --cc=udknight@gmail.com \
    --cc=zhangyanfei.yes@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.