Skip to contentSkip to conversation

net: Initialize return value in gro_cells_receive

PATCH Gregory Rose 2 participants 5 messages Oct 6, 2020 – Oct 7, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The 'res' return value is uninitalized and may be returned with some random value. Initialize to NET_RX_DROP as the default return value.

net/core/gro_cells.c +1 -1
index e095fb871d91..4e835960db07 100644
@@ -13,7 +13,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
 {
        struct net_device *dev = skb->dev;
        struct gro_cell *cell;
-       int res;
+       int res = NET_RX_DROP;
 
        rcu_read_lock();
        if (unlikely(!(dev->flags & IFF_UP)))
#1 lore raw
Quoted 11 lines · Gregory Rose

The 'res' return value is uninitalized and may be returned with some random value.  Initialize to NET_RX_DROP as the default return value.

net/core/gro_cells.c +0 -0
index e095fb871d91..4e835960db07 100644

net/core/gro_cells.c int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb) · line 19

Quoted 8 lines
net/core/gro_cells.c +1 -1
@@ -13,7 +13,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
  {
         struct net_device *dev = skb->dev;
         struct gro_cell *cell;
-       int res;
+       int res = NET_RX_DROP;
 
         rcu_read_lock();
         if (unlikely(!(dev->flags & IFF_UP)))

I do not think this is needed.

Also, when/if sending a patch fixing a bug, we require a Fixes: tag.

Thanks.

#2 lore raw
Quoted 20 lines · Eric Dumazet
Quoted 17 lines · Gregory Rose

The 'res' return value is uninitalized and may be returned with some random value.  Initialize to NET_RX_DROP as the default return value.

net/core/gro_cells.c +1 -1
index e095fb871d91..4e835960db07 100644
@@ -13,7 +13,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
  {
         struct net_device *dev = skb->dev;
         struct gro_cell *cell;
-       int res;
+       int res = NET_RX_DROP;
 
Quoted 9 lines

net/core/gro_cells.c int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb) · line 19

Quoted 2 lines
net/core/gro_cells.c +0 -0
         rcu_read_lock();
         if (unlikely(!(dev->flags & IFF_UP)))

I do not think this is needed.

Also, when/if sending a patch fixing a bug, we require a Fixes: tag.

Thanks.

If it's not needed then feel free to ignore it. It just looked like the unlikely case returns without setting the return value.

Thanks

- Greg

Thanks,

#3 lore raw
Quoted 28 lines · Gregory Rose
Quoted 25 lines · Eric Dumazet
Quoted 11 lines · Gregory Rose

The 'res' return value is uninitalized and may be returned with some random value.  Initialize to NET_RX_DROP as the default return value.

net/core/gro_cells.c +0 -0
index e095fb871d91..4e835960db07 100644

net/core/gro_cells.c int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb) · line 19

Quoted 8 lines
net/core/gro_cells.c +1 -1
@@ -13,7 +13,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
   {
          struct net_device *dev = skb->dev;
          struct gro_cell *cell;
-       int res;
+       int res = NET_RX_DROP;
 
          rcu_read_lock();
          if (unlikely(!(dev->flags & IFF_UP)))

I do not think this is needed.

Quoted 6 lines
Quoted 4 lines

Also, when/if sending a patch fixing a bug, we require a Fixes: tag.

Thanks.

If it's not needed then feel free to ignore it.  It just looked like the unlikely case returns without setting the return value.

Can you elaborate ? I do not see this problem in current upstream code.

If a compiler gave you a warning, please give its version, thanks.

#4 lore raw
Quoted 33 lines · Eric Dumazet
Quoted 30 lines · Gregory Rose
Quoted 27 lines · Eric Dumazet
Quoted 11 lines · Gregory Rose

The 'res' return value is uninitalized and may be returned with some random value.  Initialize to NET_RX_DROP as the default return value.

net/core/gro_cells.c +0 -0
index e095fb871d91..4e835960db07 100644

net/core/gro_cells.c int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb) · line 19

Quoted 8 lines
net/core/gro_cells.c +1 -1
@@ -13,7 +13,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
   {
          struct net_device *dev = skb->dev;
          struct gro_cell *cell;
-       int res;
+       int res = NET_RX_DROP;
 
          rcu_read_lock();
          if (unlikely(!(dev->flags & IFF_UP)))

I do not think this is needed.

Also, when/if sending a patch fixing a bug, we require a Fixes: tag.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Thanks.

If it's not needed then feel free to ignore it.  It just looked like the unlikely case returns without setting the return value.

Can you elaborate ? I do not see this problem in current upstream code.

If a compiler gave you a warning, please give its version, thanks.

No, it's my misreading of the code - it jumps to the drop that is in the middle of an if statement, sets res to NET_RX_DROP there and then jumps to the unlock label.

My apologies.

- Greg