]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
rxrpc: Fix handling of an unsupported token type in rxrpc_read()
authorDavid Howells <dhowells@redhat.com>
Tue, 12 Jan 2021 15:23:51 +0000 (15:23 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 19 Feb 2021 15:45:23 +0000 (16:45 +0100)
commite778e16c1f77ffdb698730f152a0ac5182281888
treeb29d9b7e5db1290a85675a165121acd517a32ef3
parentfcf33da52d9614dfc63f145550e8a45fe011550b
rxrpc: Fix handling of an unsupported token type in rxrpc_read()

BugLink: https://bugs.launchpad.net/bugs/1915186
[ Upstream commit d52e419ac8b50c8bef41b398ed13528e75d7ad48 ]

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: 9a059cd5ca7d ("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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: William Breathitt Gray <william.gray@canonical.com>
net/rxrpc/key.c