linux-stable/net/rxrpc
David Howells 3aec0767b3 rxrpc: Fix handling of an unsupported token type in rxrpc_read()
[ Upstream commit d52e419ac8 ]

Clang static analysis reports the following:

net/rxrpc/key.c:657:11: warning: Assigned value is garbage or undefined
                toksize = toksizes[tok++];
                        ^ ~~~~~~~~~~~~~~~

rxrpc_read() contains two consecutive loops.  The first loop calculates the
token sizes and stores the results in toksizes[] and the second one uses
the array.  When there is an error in identifying the token in the first
loop, the token is skipped, no change is made to the toksizes[] array.
When the same error happens in the second loop, the token is not skipped.
This will cause the toksizes[] array to be out of step and will overrun
past the calculated sizes.

Fix this by making both loops log a message and return an error in this
case.  This should only happen if a new token type is incompletely
implemented, so it should normally be impossible to trigger this.

Fixes: 9a059cd5ca ("rxrpc: Downgrade the BUG() for unsupported token type in rxrpc_read()")
Reported-by: Tom Rix <trix@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/161046503122.2445787.16714129930607546635.stgit@warthog.procyon.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-23 15:48:47 +01:00
..
af_rxrpc.c rxrpc: Fix send on a connected, but unbound socket 2019-07-31 07:28:45 +02:00
ar-internal.h rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect 2020-02-14 16:32:07 -05:00
call_accept.c rxrpc: Fix notification call on completion of discarded calls 2020-06-30 15:37:59 -04:00
call_event.c
call_object.c rxrpc: Fix race between recvmsg and sendmsg on immediate call failure 2020-08-21 09:48:02 +02:00
conn_client.c rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect 2020-02-14 16:32:07 -05:00
conn_event.c rxrpc: Fix some missing _bh annotations on locking conn->state_lock 2020-10-14 09:51:14 +02:00
conn_object.c rxrpc: Fix race between recvmsg and sendmsg on immediate call failure 2020-08-21 09:48:02 +02:00
conn_service.c rxrpc: Make service connection lookup always check for retry 2017-09-05 14:39:17 -07:00
input.c rxrpc: Fix handling of rwind from an ACK packet 2020-06-30 15:38:04 -04:00
insecure.c
Kconfig
key.c rxrpc: Fix handling of an unsupported token type in rxrpc_read() 2021-01-23 15:48:47 +01:00
local_event.c rxrpc: Fix IPv6 support 2017-08-29 10:55:20 +01:00
local_object.c rxrpc: Fix transport sockopts to get IPv4 errors on an IPv6 socket 2020-06-03 08:18:11 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
misc.c
net_ns.c rxrpc: Fix service endpoint expiry 2018-02-03 17:39:01 +01:00
output.c rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect 2020-02-14 16:32:07 -05:00
peer_event.c rxrpc: Fix possible NULL pointer access in ICMP handling 2020-01-09 10:17:59 +01:00
peer_object.c
proc.c
protocol.h rxrpc: Move the packet.h include file into net/rxrpc/ 2017-07-21 11:00:20 +01:00
recvmsg.c rxrpc: Fix race between recvmsg and sendmsg on immediate call failure 2020-08-21 09:48:02 +02:00
rxkad.c rxrpc: Fix a memory leak in rxkad_verify_response() 2020-05-27 16:43:12 +02:00
security.c
sendmsg.c rxrpc: Fix race between recvmsg and sendmsg on immediate call failure 2020-08-21 09:48:02 +02:00
skbuff.c
sysctl.c
utils.c rxrpc: Fix IPv6 support 2017-08-29 10:55:20 +01:00