* [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line
@ 2013-04-08 9:23 Wang YanQing
2013-04-08 9:29 ` Zhang Yanfei
0 siblings, 1 reply; 6+ messages in thread
From: Wang YanQing @ 2013-04-08 9:23 UTC (permalink / raw)
To: kexec; +Cc: tjd21, horms, zhangyanfei, ebiederm, hari, zhangyanfei.yes
This patch 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.
Signed-off-by: Wang YanQing <udknight@gmail.com>
---
Hi Zhang Yanfei, could you give your signed-off-by to
this patch?
kexec/arch/i386/kexec-bzImage.c | 3 +++
kexec/arch/i386/kexec-elf-x86.c | 3 +++
kexec/arch/x86_64/kexec-bzImage64.c | 6 +++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index 99fd790..29f280d 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -435,6 +435,9 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
command_line_len = 0;
if (command_line) {
command_line_len = strlen(command_line) +1;
+ } else {
+ command_line = strdup("\0");
+ command_line_len = 1;
}
ramdisk_buf = 0;
if (ramdisk) {
diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
index e62ebcb..788a209 100644
--- a/kexec/arch/i386/kexec-elf-x86.c
+++ b/kexec/arch/i386/kexec-elf-x86.c
@@ -161,6 +161,9 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
command_line_len = 0;
if (command_line) {
command_line_len = strlen(command_line) +1;
+ } else {
+ command_line = strdup("\0");
+ command_line_len = 1;
}
/* Need to append some command line parameters internally in case of
diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c
index 86e6d13..ec614a4 100644
--- a/kexec/arch/x86_64/kexec-bzImage64.c
+++ b/kexec/arch/x86_64/kexec-bzImage64.c
@@ -284,8 +284,12 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len,
}
command_line = concat_cmdline(command_line, append);
command_line_len = 0;
- if (command_line)
+ if (command_line) {
command_line_len = strlen(command_line) + 1;
+ } else {
+ command_line = strdup("\0");
+ command_line_len = 1;
+ }
ramdisk_buf = 0;
if (ramdisk)
ramdisk_buf = slurp_file(ramdisk, &ramdisk_length);
--
1.7.12.4.dirty
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line
2013-04-08 9:23 [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line Wang YanQing
@ 2013-04-08 9:29 ` Zhang Yanfei
2013-04-09 6:14 ` Zhang Yanfei
2013-04-16 14:09 ` Zhang Yanfei
0 siblings, 2 replies; 6+ messages in thread
From: Zhang Yanfei @ 2013-04-08 9:29 UTC (permalink / raw)
To: Wang YanQing, horms; +Cc: tjd21, kexec, ebiederm, zhangyanfei.yes, hari
于 2013年04月08日 17:23, Wang YanQing 写道:
> This patch 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.
>
> Signed-off-by: Wang YanQing <udknight@gmail.com>
> ---
> Hi Zhang Yanfei, could you give your signed-off-by to
> this patch?
Yeah.
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Hi Simon, could you please take a look at this to see if the change is reasonable?
After all, if no commadline, we make the commandline_len to 1. I don't know if
this behaviour could be accepted by you.
Thanks
Zhang
>
> kexec/arch/i386/kexec-bzImage.c | 3 +++
> kexec/arch/i386/kexec-elf-x86.c | 3 +++
> kexec/arch/x86_64/kexec-bzImage64.c | 6 +++++-
> 3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
> index 99fd790..29f280d 100644
> --- a/kexec/arch/i386/kexec-bzImage.c
> +++ b/kexec/arch/i386/kexec-bzImage.c
> @@ -435,6 +435,9 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
> command_line_len = 0;
> if (command_line) {
> command_line_len = strlen(command_line) +1;
> + } else {
> + command_line = strdup("\0");
> + command_line_len = 1;
> }
> ramdisk_buf = 0;
> if (ramdisk) {
> diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
> index e62ebcb..788a209 100644
> --- a/kexec/arch/i386/kexec-elf-x86.c
> +++ b/kexec/arch/i386/kexec-elf-x86.c
> @@ -161,6 +161,9 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
> command_line_len = 0;
> if (command_line) {
> command_line_len = strlen(command_line) +1;
> + } else {
> + command_line = strdup("\0");
> + command_line_len = 1;
> }
>
> /* Need to append some command line parameters internally in case of
> diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c
> index 86e6d13..ec614a4 100644
> --- a/kexec/arch/x86_64/kexec-bzImage64.c
> +++ b/kexec/arch/x86_64/kexec-bzImage64.c
> @@ -284,8 +284,12 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len,
> }
> command_line = concat_cmdline(command_line, append);
> command_line_len = 0;
> - if (command_line)
> + if (command_line) {
> command_line_len = strlen(command_line) + 1;
> + } else {
> + command_line = strdup("\0");
> + command_line_len = 1;
> + }
> ramdisk_buf = 0;
> if (ramdisk)
> ramdisk_buf = slurp_file(ramdisk, &ramdisk_length);
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line
2013-04-08 9:29 ` Zhang Yanfei
@ 2013-04-09 6:14 ` Zhang Yanfei
2013-04-16 14:09 ` Zhang Yanfei
1 sibling, 0 replies; 6+ messages in thread
From: Zhang Yanfei @ 2013-04-09 6:14 UTC (permalink / raw)
To: Wang YanQing, horms; +Cc: hari, tjd21, kexec, ebiederm, zhangyanfei.yes
于 2013年04月08日 17:29, Zhang Yanfei 写道:
> 于 2013年04月08日 17:23, Wang YanQing 写道:
>> This patch 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.
>>
>> Signed-off-by: Wang YanQing <udknight@gmail.com>
>> ---
>> Hi Zhang Yanfei, could you give your signed-off-by to
>> this patch?
>
> Yeah.
>
> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>
> Hi Simon, could you please take a look at this to see if the change is reasonable?
> After all, if no commadline, we make the commandline_len to 1. I don't know if
> this behaviour could be accepted by you.
I am now thinking that whether this way is reasonable or not...
>
> Thanks
> Zhang
>
>>
>> kexec/arch/i386/kexec-bzImage.c | 3 +++
>> kexec/arch/i386/kexec-elf-x86.c | 3 +++
>> kexec/arch/x86_64/kexec-bzImage64.c | 6 +++++-
>> 3 files changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
>> index 99fd790..29f280d 100644
>> --- a/kexec/arch/i386/kexec-bzImage.c
>> +++ b/kexec/arch/i386/kexec-bzImage.c
>> @@ -435,6 +435,9 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
>> command_line_len = 0;
>> if (command_line) {
>> command_line_len = strlen(command_line) +1;
>> + } else {
>> + command_line = strdup("\0");
>> + command_line_len = 1;
>> }
>> ramdisk_buf = 0;
>> if (ramdisk) {
>> diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
>> index e62ebcb..788a209 100644
>> --- a/kexec/arch/i386/kexec-elf-x86.c
>> +++ b/kexec/arch/i386/kexec-elf-x86.c
>> @@ -161,6 +161,9 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
>> command_line_len = 0;
>> if (command_line) {
>> command_line_len = strlen(command_line) +1;
>> + } else {
>> + command_line = strdup("\0");
>> + command_line_len = 1;
>> }
>>
>> /* Need to append some command line parameters internally in case of
>> diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c
>> index 86e6d13..ec614a4 100644
>> --- a/kexec/arch/x86_64/kexec-bzImage64.c
>> +++ b/kexec/arch/x86_64/kexec-bzImage64.c
>> @@ -284,8 +284,12 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len,
>> }
>> command_line = concat_cmdline(command_line, append);
>> command_line_len = 0;
>> - if (command_line)
>> + if (command_line) {
>> command_line_len = strlen(command_line) + 1;
>> + } else {
>> + command_line = strdup("\0");
>> + command_line_len = 1;
>> + }
>> ramdisk_buf = 0;
>> if (ramdisk)
>> ramdisk_buf = slurp_file(ramdisk, &ramdisk_length);
>
>
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line
2013-04-08 9:29 ` Zhang Yanfei
2013-04-09 6:14 ` Zhang Yanfei
@ 2013-04-16 14:09 ` Zhang Yanfei
2013-04-17 0:13 ` Simon Horman
1 sibling, 1 reply; 6+ messages in thread
From: Zhang Yanfei @ 2013-04-16 14:09 UTC (permalink / raw)
To: Zhang Yanfei; +Cc: tjd21, kexec, Wang YanQing, horms, ebiederm, hari
于 2013年04月08日 17:29, Zhang Yanfei 写道:
> 于 2013年04月08日 17:23, Wang YanQing 写道:
>> This patch 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.
>>
>> Signed-off-by: Wang YanQing <udknight@gmail.com>
>> ---
>> Hi Zhang Yanfei, could you give your signed-off-by to
>> this patch?
>
> Yeah.
>
> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>
> Hi Simon, could you please take a look at this to see if the change is reasonable?
> After all, if no commadline, we make the commandline_len to 1. I don't know if
> this behaviour could be accepted by you.
>
Hi Simon
What is your opinion about this patch?
>>
>> kexec/arch/i386/kexec-bzImage.c | 3 +++
>> kexec/arch/i386/kexec-elf-x86.c | 3 +++
>> kexec/arch/x86_64/kexec-bzImage64.c | 6 +++++-
>> 3 files changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
>> index 99fd790..29f280d 100644
>> --- a/kexec/arch/i386/kexec-bzImage.c
>> +++ b/kexec/arch/i386/kexec-bzImage.c
>> @@ -435,6 +435,9 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
>> command_line_len = 0;
>> if (command_line) {
>> command_line_len = strlen(command_line) +1;
>> + } else {
>> + command_line = strdup("\0");
>> + command_line_len = 1;
>> }
>> ramdisk_buf = 0;
>> if (ramdisk) {
>> diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
>> index e62ebcb..788a209 100644
>> --- a/kexec/arch/i386/kexec-elf-x86.c
>> +++ b/kexec/arch/i386/kexec-elf-x86.c
>> @@ -161,6 +161,9 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
>> command_line_len = 0;
>> if (command_line) {
>> command_line_len = strlen(command_line) +1;
>> + } else {
>> + command_line = strdup("\0");
>> + command_line_len = 1;
>> }
>>
>> /* Need to append some command line parameters internally in case of
>> diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c
>> index 86e6d13..ec614a4 100644
>> --- a/kexec/arch/x86_64/kexec-bzImage64.c
>> +++ b/kexec/arch/x86_64/kexec-bzImage64.c
>> @@ -284,8 +284,12 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len,
>> }
>> command_line = concat_cmdline(command_line, append);
>> command_line_len = 0;
>> - if (command_line)
>> + if (command_line) {
>> command_line_len = strlen(command_line) + 1;
>> + } else {
>> + command_line = strdup("\0");
>> + command_line_len = 1;
>> + }
>> ramdisk_buf = 0;
>> if (ramdisk)
>> ramdisk_buf = slurp_file(ramdisk, &ramdisk_length);
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line
2013-04-16 14:09 ` Zhang Yanfei
@ 2013-04-17 0:13 ` Simon Horman
2013-04-17 1:27 ` Zhang Yanfei
0 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2013-04-17 0:13 UTC (permalink / raw)
To: Zhang Yanfei; +Cc: tjd21, kexec, Wang YanQing, Zhang Yanfei, ebiederm, hari
On Tue, Apr 16, 2013 at 10:09:18PM +0800, Zhang Yanfei wrote:
> 于 2013年04月08日 17:29, Zhang Yanfei 写道:
> > 于 2013年04月08日 17:23, Wang YanQing 写道:
> >> This patch 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.
> >>
> >> Signed-off-by: Wang YanQing <udknight@gmail.com>
> >> ---
> >> Hi Zhang Yanfei, could you give your signed-off-by to
> >> this patch?
> >
> > Yeah.
> >
> > Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> >
> > Hi Simon, could you please take a look at this to see if the change is reasonable?
> > After all, if no commadline, we make the commandline_len to 1. I don't know if
> > this behaviour could be accepted by you.
> >
>
> Hi Simon
>
> What is your opinion about this patch?
It seems reasonable to me, I have applied it.
I have added your Signed-off-by. However, for reference: unless you are the
maintainer or were involved in writing the patch I think an Acked-by or
Tested-by would be more appropriate.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line
2013-04-17 0:13 ` Simon Horman
@ 2013-04-17 1:27 ` Zhang Yanfei
0 siblings, 0 replies; 6+ messages in thread
From: Zhang Yanfei @ 2013-04-17 1:27 UTC (permalink / raw)
To: Simon Horman; +Cc: tjd21, kexec, Wang YanQing, ebiederm, hari, Zhang Yanfei
于 2013年04月17日 08:13, Simon Horman 写道:
> On Tue, Apr 16, 2013 at 10:09:18PM +0800, Zhang Yanfei wrote:
>> 于 2013年04月08日 17:29, Zhang Yanfei 写道:
>>> 于 2013年04月08日 17:23, Wang YanQing 写道:
>>>> This patch 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.
>>>>
>>>> Signed-off-by: Wang YanQing <udknight@gmail.com>
>>>> ---
>>>> Hi Zhang Yanfei, could you give your signed-off-by to
>>>> this patch?
>>>
>>> Yeah.
>>>
>>> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>>>
>>> Hi Simon, could you please take a look at this to see if the change is reasonable?
>>> After all, if no commadline, we make the commandline_len to 1. I don't know if
>>> this behaviour could be accepted by you.
>>>
>>
>> Hi Simon
>>
>> What is your opinion about this patch?
>
> It seems reasonable to me, I have applied it.
>
> I have added your Signed-off-by. However, for reference: unless you are the
> maintainer or were involved in writing the patch I think an Acked-by or
> Tested-by would be more appropriate.
>
I added some codes in the mail when we discussed this patch, so I
add my Signed-off-by.
Anyway, thanks for your reminding:-)
Thanks
Zhang
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-17 1:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-08 9:23 [PATCH RESEND]kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as command line instead of empty command line Wang YanQing
2013-04-08 9:29 ` Zhang Yanfei
2013-04-09 6:14 ` Zhang Yanfei
2013-04-16 14:09 ` Zhang Yanfei
2013-04-17 0:13 ` Simon Horman
2013-04-17 1:27 ` Zhang Yanfei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox