Commit 08d4d217 authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller

rxrpc: out of bound read in debug code

Smatch complains because we are using an untrusted index into the
rxrpc_acks[] array.  It's just a read and it's only in the debug code,
but it's simple enough to add a check and fix it.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2fa053a0
...@@ -21,10 +21,17 @@ ...@@ -21,10 +21,17 @@
static unsigned int rxrpc_ack_defer = 1; static unsigned int rxrpc_ack_defer = 1;
static const char *const rxrpc_acks[] = { static const char *rxrpc_acks(u8 reason)
"---", "REQ", "DUP", "OOS", "WIN", "MEM", "PNG", "PNR", "DLY", "IDL", {
"-?-" static const char *const str[] = {
}; "---", "REQ", "DUP", "OOS", "WIN", "MEM", "PNG", "PNR", "DLY",
"IDL", "-?-"
};
if (reason >= ARRAY_SIZE(str))
reason = ARRAY_SIZE(str) - 1;
return str[reason];
}
static const s8 rxrpc_ack_priority[] = { static const s8 rxrpc_ack_priority[] = {
[0] = 0, [0] = 0,
...@@ -50,7 +57,7 @@ void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, ...@@ -50,7 +57,7 @@ void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
ASSERTCMP(prior, >, 0); ASSERTCMP(prior, >, 0);
_enter("{%d},%s,%%%x,%u", _enter("{%d},%s,%%%x,%u",
call->debug_id, rxrpc_acks[ack_reason], ntohl(serial), call->debug_id, rxrpc_acks(ack_reason), ntohl(serial),
immediate); immediate);
if (prior < rxrpc_ack_priority[call->ackr_reason]) { if (prior < rxrpc_ack_priority[call->ackr_reason]) {
...@@ -637,7 +644,7 @@ static int rxrpc_process_rx_queue(struct rxrpc_call *call, ...@@ -637,7 +644,7 @@ static int rxrpc_process_rx_queue(struct rxrpc_call *call,
hard, hard,
ntohl(ack.previousPacket), ntohl(ack.previousPacket),
ntohl(ack.serial), ntohl(ack.serial),
rxrpc_acks[ack.reason], rxrpc_acks(ack.reason),
ack.nAcks); ack.nAcks);
rxrpc_extract_ackinfo(call, skb, latest, ack.nAcks); rxrpc_extract_ackinfo(call, skb, latest, ack.nAcks);
...@@ -1180,7 +1187,7 @@ void rxrpc_process_call(struct work_struct *work) ...@@ -1180,7 +1187,7 @@ void rxrpc_process_call(struct work_struct *work)
ntohl(ack.firstPacket), ntohl(ack.firstPacket),
ntohl(ack.previousPacket), ntohl(ack.previousPacket),
ntohl(ack.serial), ntohl(ack.serial),
rxrpc_acks[ack.reason], rxrpc_acks(ack.reason),
ack.nAcks); ack.nAcks);
del_timer_sync(&call->ack_timer); del_timer_sync(&call->ack_timer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment