diff mbox series

[ovs-dev,ovn] pinctrl: Fix possible use of uninitialized eth address.

Message ID 20200514105322.54441-1-i.maximets@ovn.org
State Accepted
Headers show
Series [ovs-dev,ovn] pinctrl: Fix possible use of uninitialized eth address. | expand

Commit Message

Ilya Maximets May 14, 2020, 10:53 a.m. UTC
Not sure if this could happen in a real usecase, but below loop
over mac addresses could never reach initialization of 'ea'.

In this case it will be used uninitialized by the later code.
Setting it to zero ethernet address to avoid that condition.

Fixes: e3a398e9146e ("controller: Add ipv6 prefix delegation state machine")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 controller/pinctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dumitru Ceara May 14, 2020, 11:34 a.m. UTC | #1
On 5/14/20 12:53 PM, Ilya Maximets wrote:
> Not sure if this could happen in a real usecase, but below loop
> over mac addresses could never reach initialization of 'ea'.
> 
> In this case it will be used uninitialized by the later code.
> Setting it to zero ethernet address to avoid that condition.
> 
> Fixes: e3a398e9146e ("controller: Add ipv6 prefix delegation state machine")
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>

Looks good to me.

Acked-by: Dumitru Ceara <dceara@redhat.com>

Thanks,
Dumitru

> ---
>  controller/pinctrl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/controller/pinctrl.c b/controller/pinctrl.c
> index 103198282..bea446c89 100644
> --- a/controller/pinctrl.c
> +++ b/controller/pinctrl.c
> @@ -1184,7 +1184,7 @@ prepare_ipv6_prefixd(struct ovsdb_idl_txn *ovnsb_idl_txn,
>              }
>  
>              struct in6_addr ip6_addr;
> -            struct eth_addr ea;
> +            struct eth_addr ea = eth_addr_zero;
>              for (j = 0; j < pb->n_mac; j++) {
>                  struct lport_addresses laddrs;
>  
>
Mark Michelson May 14, 2020, 7:22 p.m. UTC | #2
On 5/14/20 7:34 AM, Dumitru Ceara wrote:
> On 5/14/20 12:53 PM, Ilya Maximets wrote:
>> Not sure if this could happen in a real usecase, but below loop
>> over mac addresses could never reach initialization of 'ea'.
>>
>> In this case it will be used uninitialized by the later code.
>> Setting it to zero ethernet address to avoid that condition.
>>
>> Fixes: e3a398e9146e ("controller: Add ipv6 prefix delegation state machine")
>> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> 
> Looks good to me.
> 
> Acked-by: Dumitru Ceara <dceara@redhat.com>
> 
> Thanks,
> Dumitru

Thanks, I pushed this to master.

> 
>> ---
>>   controller/pinctrl.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/controller/pinctrl.c b/controller/pinctrl.c
>> index 103198282..bea446c89 100644
>> --- a/controller/pinctrl.c
>> +++ b/controller/pinctrl.c
>> @@ -1184,7 +1184,7 @@ prepare_ipv6_prefixd(struct ovsdb_idl_txn *ovnsb_idl_txn,
>>               }
>>   
>>               struct in6_addr ip6_addr;
>> -            struct eth_addr ea;
>> +            struct eth_addr ea = eth_addr_zero;
>>               for (j = 0; j < pb->n_mac; j++) {
>>                   struct lport_addresses laddrs;
>>   
>>
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 103198282..bea446c89 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -1184,7 +1184,7 @@  prepare_ipv6_prefixd(struct ovsdb_idl_txn *ovnsb_idl_txn,
             }
 
             struct in6_addr ip6_addr;
-            struct eth_addr ea;
+            struct eth_addr ea = eth_addr_zero;
             for (j = 0; j < pb->n_mac; j++) {
                 struct lport_addresses laddrs;