public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow.
       [not found] ` <512055D0.7050100@asianux.com>
@ 2013-03-25  4:30   ` Chen Gang
  2013-04-24  7:45     ` Chen Gang
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Gang @ 2013-03-25  4:30 UTC (permalink / raw)
  To: benh, paulus, Michael Neuling, sfr@canb.auug.org.au
  Cc: linuxppc-dev, linux-kernel@vger.kernel.org

Hello Maintainers:

  could you help check this patch whether is ok ?

  thanks.


On 2013年02月17日 12:00, Chen Gang wrote:
> Hello relative members:
> 
>   please give a glance to this patch, when you have time.
> 
>   thanks.
> 
>   :-)
> 
> gchen.
> 
> 
> 于 2013年01月24日 12:14, Chen Gang 写道:
>>
>>   for tmp_part->header.name:
>>     it is "Terminating null required only for names < 12 chars".
>>     so need to limit the %.12s for it in printk
>>
>>   additional info:
>>
>>     %12s  limit the width, not for the original string output length
>>           if name length is more than 12, it still can be fully displayed.
>>           if name length is less than 12, the ' ' will be filled before name.
>>
>>     %.12s truly limit the original string output length (precision)
>>
>>
>> Signed-off-by: Chen Gang <gang.chen@asianux.com>
>> ---
>>  arch/powerpc/kernel/nvram_64.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
>> index bec1e93..57bf6d2 100644
>> --- a/arch/powerpc/kernel/nvram_64.c
>> +++ b/arch/powerpc/kernel/nvram_64.c
>> @@ -202,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
>>  	printk(KERN_WARNING "--------%s---------\n", label);
>>  	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
>>  	list_for_each_entry(tmp_part, &nvram_partitions, partition) {
>> -		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12s\n",
>> +		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12.12s\n",
>>  		       tmp_part->index, tmp_part->header.signature,
>>  		       tmp_part->header.checksum, tmp_part->header.length,
>>  		       tmp_part->header.name);
>>
> 
> 


-- 
Chen Gang

Asianux Corporation

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

* Re: [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow.
  2013-03-25  4:30   ` [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow Chen Gang
@ 2013-04-24  7:45     ` Chen Gang
  2013-04-24  8:15       ` Vasant Hegde
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Gang @ 2013-04-24  7:45 UTC (permalink / raw)
  To: Vasant Hegde
  Cc: benh, paulus, Michael Neuling, sfr@canb.auug.org.au, linuxppc-dev,
	linux-kernel@vger.kernel.org

Hello Vasant Hegde:

How about this patch, is it OK ?

Thanks.


On 2013年03月25日 12:30, Chen Gang wrote:
> Hello Maintainers:
> 
>   could you help check this patch whether is ok ?
> 
>   thanks.
> 
> 
> On 2013年02月17日 12:00, Chen Gang wrote:
>> Hello relative members:
>>
>>   please give a glance to this patch, when you have time.
>>
>>   thanks.
>>
>>   :-)
>>
>> gchen.
>>
>>
>> 于 2013年01月24日 12:14, Chen Gang 写道:
>>>
>>>   for tmp_part->header.name:
>>>     it is "Terminating null required only for names < 12 chars".
>>>     so need to limit the %.12s for it in printk
>>>
>>>   additional info:
>>>
>>>     %12s  limit the width, not for the original string output length
>>>           if name length is more than 12, it still can be fully displayed.
>>>           if name length is less than 12, the ' ' will be filled before name.
>>>
>>>     %.12s truly limit the original string output length (precision)
>>>
>>>
>>> Signed-off-by: Chen Gang <gang.chen@asianux.com>
>>> ---
>>>  arch/powerpc/kernel/nvram_64.c |    2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
>>> index bec1e93..57bf6d2 100644
>>> --- a/arch/powerpc/kernel/nvram_64.c
>>> +++ b/arch/powerpc/kernel/nvram_64.c
>>> @@ -202,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
>>>  	printk(KERN_WARNING "--------%s---------\n", label);
>>>  	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
>>>  	list_for_each_entry(tmp_part, &nvram_partitions, partition) {
>>> -		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12s\n",
>>> +		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12.12s\n",
>>>  		       tmp_part->index, tmp_part->header.signature,
>>>  		       tmp_part->header.checksum, tmp_part->header.length,
>>>  		       tmp_part->header.name);
>>>
>>
>>
> 
> 


-- 
Chen Gang

Asianux Corporation

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

* Re: [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow.
  2013-04-24  7:45     ` Chen Gang
@ 2013-04-24  8:15       ` Vasant Hegde
  2013-04-24  8:19         ` Vasant Hegde
  0 siblings, 1 reply; 5+ messages in thread
From: Vasant Hegde @ 2013-04-24  8:15 UTC (permalink / raw)
  To: Chen Gang
  Cc: sfr@canb.auug.org.au, Michael Neuling,
	linux-kernel@vger.kernel.org, paulus, linuxppc-dev

On 04/24/2013 01:15 PM, Chen Gang wrote:
> Hello Vasant Hegde:
> 
> How about this patch, is it OK ?
> 
> Thanks.
> 
> 
> On 2013年03月25日 12:30, Chen Gang wrote:
>> Hello Maintainers:
>>
>>    could you help check this patch whether is ok ?
>>
>>    thanks.
>>
>>
>> On 2013年02月17日 12:00, Chen Gang wrote:
>>> Hello relative members:
>>>
>>>    please give a glance to this patch, when you have time.
>>>
>>>    thanks.
>>>
>>>    :-)
>>>
>>> gchen.
>>>
>>>
>>> 于 2013年01月24日 12:14, Chen Gang 写道:
>>>>
>>>>    for tmp_part->header.name:
>>>>      it is "Terminating null required only for names<  12 chars".
>>>>      so need to limit the %.12s for it in printk
>>>>
>>>>    additional info:
>>>>
>>>>      %12s  limit the width, not for the original string output length
>>>>            if name length is more than 12, it still can be fully displayed.
>>>>            if name length is less than 12, the ' ' will be filled before name.
>>>>
>>>>      %.12s truly limit the original string output length (precision)
>>>>
>>>>
>>>> Signed-off-by: Chen Gang<gang.chen@asianux.com>
>>>> ---
>>>>   arch/powerpc/kernel/nvram_64.c |    2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
>>>> index bec1e93..57bf6d2 100644
>>>> --- a/arch/powerpc/kernel/nvram_64.c
>>>> +++ b/arch/powerpc/kernel/nvram_64.c
>>>> @@ -202,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
>>>>   	printk(KERN_WARNING "--------%s---------\n", label);
>>>>   	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
>>>>   	list_for_each_entry(tmp_part,&nvram_partitions, partition) {
>>>> -		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12s\n",
>>>> +		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12.12s\n",

First, this code in inside NVRAM_DEBUG which is used only for debug purpose and
AFAIK, all partition names are less than 20 character. So I don't think we need
this patch.

-Vasant

>>>>   		       tmp_part->index, tmp_part->header.signature,
>>>>   		       tmp_part->header.checksum, tmp_part->header.length,
>>>>   		       tmp_part->header.name);
>>>>
>>>
>>>
>>
>>
> 
> 


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

* Re: [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow.
  2013-04-24  8:15       ` Vasant Hegde
@ 2013-04-24  8:19         ` Vasant Hegde
  2013-04-24  8:31           ` Chen Gang
  0 siblings, 1 reply; 5+ messages in thread
From: Vasant Hegde @ 2013-04-24  8:19 UTC (permalink / raw)
  To: Chen Gang
  Cc: sfr@canb.auug.org.au, Michael Neuling, linuxppc-dev, paulus,
	linux-kernel@vger.kernel.org

On 04/24/2013 01:45 PM, Vasant Hegde wrote:
> On 04/24/2013 01:15 PM, Chen Gang wrote:
>> Hello Vasant Hegde:
>>
>> How about this patch, is it OK ?
>>
>> Thanks.
>>
>>
>> On 2013年03月25日 12:30, Chen Gang wrote:
>>> Hello Maintainers:
>>>
>>>     could you help check this patch whether is ok ?
>>>
>>>     thanks.
>>>
>>>
>>> On 2013年02月17日 12:00, Chen Gang wrote:
>>>> Hello relative members:
>>>>
>>>>     please give a glance to this patch, when you have time.
>>>>
>>>>     thanks.
>>>>
>>>>     :-)
>>>>
>>>> gchen.
>>>>
>>>>
>>>> 于 2013年01月24日 12:14, Chen Gang 写道:
>>>>>
>>>>>     for tmp_part->header.name:
>>>>>       it is "Terminating null required only for names<   12 chars".
>>>>>       so need to limit the %.12s for it in printk
>>>>>
>>>>>     additional info:
>>>>>
>>>>>       %12s  limit the width, not for the original string output length
>>>>>             if name length is more than 12, it still can be fully displayed.
>>>>>             if name length is less than 12, the ' ' will be filled before name.
>>>>>
>>>>>       %.12s truly limit the original string output length (precision)
>>>>>
>>>>>
>>>>> Signed-off-by: Chen Gang<gang.chen@asianux.com>
>>>>> ---
>>>>>    arch/powerpc/kernel/nvram_64.c |    2 +-
>>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
>>>>> index bec1e93..57bf6d2 100644
>>>>> --- a/arch/powerpc/kernel/nvram_64.c
>>>>> +++ b/arch/powerpc/kernel/nvram_64.c
>>>>> @@ -202,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
>>>>>    	printk(KERN_WARNING "--------%s---------\n", label);
>>>>>    	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
>>>>>    	list_for_each_entry(tmp_part,&nvram_partitions, partition) {
>>>>> -		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12s\n",
>>>>> +		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12.12s\n",
> 
> First, this code in inside NVRAM_DEBUG which is used only for debug purpose and
> AFAIK, all partition names are less than 20 character. So I don't think we need

Sorry.. I meant 12 character.

-Vasant


> this patch.
> 
> -Vasant
> 
>>>>>    		tmp_part->index, tmp_part->header.signature,
>>>>>    		       tmp_part->header.checksum, tmp_part->header.length,
>>>>>    		       tmp_part->header.name);
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev


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

* Re: [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow.
  2013-04-24  8:19         ` Vasant Hegde
@ 2013-04-24  8:31           ` Chen Gang
  0 siblings, 0 replies; 5+ messages in thread
From: Chen Gang @ 2013-04-24  8:31 UTC (permalink / raw)
  To: Vasant Hegde
  Cc: sfr@canb.auug.org.au, Michael Neuling, linuxppc-dev, paulus,
	linux-kernel@vger.kernel.org

On 2013年04月24日 16:19, Vasant Hegde wrote:
>>>>>>     for tmp_part->header.name:
>>>>>> >>>>>       it is "Terminating null required only for names<   12 chars".
>>>>>> >>>>>       so need to limit the %.12s for it in printk
>>>>>> >>>>>
>>>>>> >>>>>     additional info:
>>>>>> >>>>>
>>>>>> >>>>>       %12s  limit the width, not for the original string output length
>>>>>> >>>>>             if name length is more than 12, it still can be fully displayed.
>>>>>> >>>>>             if name length is less than 12, the ' ' will be filled before name.
>>>>>> >>>>>
>>>>>> >>>>>       %.12s truly limit the original string output length (precision)
>>>>>> >>>>>
>>>>>> >>>>>
>>>>>> >>>>> Signed-off-by: Chen Gang<gang.chen@asianux.com>
>>>>>> >>>>> ---
>>>>>> >>>>>    arch/powerpc/kernel/nvram_64.c |    2 +-
>>>>>> >>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>> >>>>>
>>>>>> >>>>> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
>>>>>> >>>>> index bec1e93..57bf6d2 100644
>>>>>> >>>>> --- a/arch/powerpc/kernel/nvram_64.c
>>>>>> >>>>> +++ b/arch/powerpc/kernel/nvram_64.c
>>>>>> >>>>> @@ -202,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
>>>>>> >>>>>    	printk(KERN_WARNING "--------%s---------\n", label);
>>>>>> >>>>>    	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
>>>>>> >>>>>    	list_for_each_entry(tmp_part,&nvram_partitions, partition) {
>>>>>> >>>>> -		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12s\n",
>>>>>> >>>>> +		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12.12s\n",
>> > 
>> > First, this code in inside NVRAM_DEBUG which is used only for debug purpose and
>> > AFAIK, all partition names are less than 20 character. So I don't think we need
> Sorry.. I meant 12 character.

Please see line 283:
  "strncpy(part->header.name, "wwwwwwwwwwww", 12);"
  (it is not a NUL terminated string, and the length is 12)

And also, can we be sure that all partition names should be less than 12
characters ?

All together, I think we still need %12.12s to protect the memory.

Thanks.

-- 
Chen Gang

Asianux Corporation

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

end of thread, other threads:[~2013-04-24  8:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <5100B53C.3030109@asianux.com>
     [not found] ` <512055D0.7050100@asianux.com>
2013-03-25  4:30   ` [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow Chen Gang
2013-04-24  7:45     ` Chen Gang
2013-04-24  8:15       ` Vasant Hegde
2013-04-24  8:19         ` Vasant Hegde
2013-04-24  8:31           ` Chen Gang

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