Re: [PATCH] MIPS: BCM63XX: properly handle mac address octet overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18 September 2012 13:51, Sergei Shtylyov <sshtylyov@xxxxxxxxxx> wrote:
> Hello.
>
>
> On 18-09-2012 13:32, Jonas Gorski wrote:
>
>> While calculating the mac address the pointer for the current octet was
>> never reset back to the least significant one after being decremented
>> because of an octet overflow. This resulted in the code continuing to
>> increment at the current octet, potentially generating duplicate or
>> invalid mac addresses.
>
>
>> As a second issue the pointer was allowed to advance up to the most
>> significant octet, modifying the OUI, and potentially changing the type
>> of mac address.
>
>
>> Rewrite the code so it resets the pointer to the least significant
>> in each outer loop step, and bails out when the least significant octet
>> of the OUI is reached.
>
>
>> Signed-off-by: Jonas Gorski <jonas.gorski@xxxxxxxxx>
>> ---
>>   arch/mips/bcm63xx/boards/board_bcm963xx.c |   16 +++++++++-------
>>   1 file changed, 9 insertions(+), 7 deletions(-)
>
>
>> diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c
>> b/arch/mips/bcm63xx/boards/board_bcm963xx.c
>> index ea4ea77..f0fcec6 100644
>> --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
>> +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
>> @@ -720,7 +720,7 @@ const char *board_get_name(void)
>>    */
>>   static int board_get_mac_address(u8 *mac)
>>   {
>> -       u8 *p;
>> +       u8 *oui;
>>         int count;
>>
>>         if (mac_addr_used >= nvram.mac_addr_count) {
>> @@ -729,21 +729,23 @@ static int board_get_mac_address(u8 *mac)
>>         }
>>
>>         memcpy(mac, nvram.mac_addr_base, ETH_ALEN);
>> -       p = mac + ETH_ALEN - 1;
>> +       oui = mac + ETH_ALEN/2 - 1;
>>         count = mac_addr_used;
>>
>>         while (count--) {
>> +               p = mac + ETH_ALEN - 1;
>
>
>    But didn't you remove 'p' above? Did you compile this?

Argh. Yes, but the wrong version (my "user space" one to test it). Let
me try that again ... . Thanks for catching it.

Jonas



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux