Skip to contentSkip to conversation

rxrpc: uninitialized variable in rxrpc_send_ack_packet()

PATCH Applied Dan Carpenter 3 participants 7 messages Nov 17, 2022 – Nov 18, 2022

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

PATCH 1/1 rxrpc: uninitialized variable in rxrpc_send_ack_packet()

The "pkt" was supposed to have been deleted in a previous patch. It leads to an uninitialized variable bug.

Fixes 72f0c6fb0579 ("rxrpc: Allocate ACK records at proposal and queue for transmission")

---
Applies to net-next.

 net/rxrpc/output.c | 2 --
 1 file changed, 2 deletions(-)
net/rxrpc/output.c +0 -2
index 46432e70a16b..04f945e042ab 100644
@@ -202,7 +202,6 @@ static void rxrpc_cancel_rtt_probe(struct rxrpc_call *call,
 static int rxrpc_send_ack_packet(struct rxrpc_local *local, struct rxrpc_txbuf *txb)
 {
 	struct rxrpc_connection *conn;
-	struct rxrpc_ack_buffer *pkt;
 	struct rxrpc_call *call = txb->call;
 	struct msghdr msg;
 	struct kvec iov[1];
@@ -270,7 +269,6 @@ static int rxrpc_send_ack_packet(struct rxrpc_local *local, struct rxrpc_txbuf *
 		rxrpc_set_keepalive(call);
 	}
 
-	kfree(pkt);
 	return ret;
 }
 
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 2 lines · Dan Carpenter

The "pkt" was supposed to have been deleted in a previous patch. It leads to an uninitialized variable bug.

Weird. I don't get a compiler warning and the kernel doesn't crash, despite transmitting millions of acks.

If I disassemble the built code, I see:

   0xffffffff81b09e89 <+723>:   xor    %edi,%edi
   0xffffffff81b09e8b <+725>:   call   0xffffffff811c0bc1 <kfree>

I'm not sure why it's sticking 0 in EDI, though.

David

#2 lore raw
Quoted 8 lines · David Howells
Quoted 2 lines · Dan Carpenter

The "pkt" was supposed to have been deleted in a previous patch. It leads to an uninitialized variable bug.

Weird. I don't get a compiler warning and the kernel doesn't crash, despite transmitting millions of acks.

Quoted 6 lines

If I disassemble the built code, I see:

   0xffffffff81b09e89 <+723>:   xor    %edi,%edi
   0xffffffff81b09e8b <+725>:   call   0xffffffff811c0bc1 <kfree>

I'm not sure why it's sticking 0 in EDI, though.

We disabled GCC's check for uninitialized variables. It could be that you have the .config to automatically zero out stack variables.

CONFIG_CC_HAS_AUTO_VAR_INIT_PATTERN=y
CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_BARE=y
CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO=y

regards,
dan carpenter

maintainer
#3 lore raw
Quoted 6 lines · Dan Carpenter

We disabled GCC's check for uninitialized variables. It could be that you have the .config to automatically zero out stack variables.

CONFIG_CC_HAS_AUTO_VAR_INIT_PATTERN=y
CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_BARE=y
CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO=y

Ah. Is there a way to reenable that?

David

#4 lore raw
In reply to David Howells
Quoted 10 lines · David Howells
Quoted 6 lines · Dan Carpenter

We disabled GCC's check for uninitialized variables. It could be that you have the .config to automatically zero out stack variables.

CONFIG_CC_HAS_AUTO_VAR_INIT_PATTERN=y
CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_BARE=y
CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO=y

Ah. Is there a way to reenable that?

make W=2 will do it, but W=2 sucks...

regards,
dan carpenter

#6 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 9 lines · On Thu, 17 Nov 2022 10:44:02 +0300 you wrote:

The "pkt" was supposed to have been deleted in a previous patch. It leads to an uninitialized variable bug.

Fixes 72f0c6fb0579 ("rxrpc: Allocate ACK records at proposal and queue for transmission")

---
Applies to net-next.

[...]

Here is the summary with links:
- [net-next] rxrpc: uninitialized variable in rxrpc_send_ack_packet()

    https://git.kernel.org/netdev/net-next/c/38461894838b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html