aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2021-01-12 15:23:51 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-01-23 16:04:03 +0100
commit6f3fe96a69565c96d95ea20e72c02bf9761c4b03 (patch)
treecd2ead4b3ea8fc55aaf73452d7e4b9415671d534
parent2bfb953aeebf39d32f159450d69278b4c9c856dd (diff)
downloadkernel_replicant_linux-6f3fe96a69565c96d95ea20e72c02bf9761c4b03.tar.gz
kernel_replicant_linux-6f3fe96a69565c96d95ea20e72c02bf9761c4b03.tar.bz2
kernel_replicant_linux-6f3fe96a69565c96d95ea20e72c02bf9761c4b03.zip
rxrpc: Fix handling of an unsupported token type in rxrpc_read()
[ 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>
-rw-r--r--net/rxrpc/key.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index 2e8bd3b97301..979338a64c0c 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -1109,7 +1109,7 @@ static long rxrpc_read(const struct key *key,
default: /* we have a ticket we can't encode */
pr_err("Unsupported key token type (%u)\n",
token->security_index);
- continue;
+ return -ENOPKG;
}
_debug("token[%u]: toksize=%u", ntoks, toksize);
@@ -1224,7 +1224,9 @@ static long rxrpc_read(const struct key *key,
break;
default:
- break;
+ pr_err("Unsupported key token type (%u)\n",
+ token->security_index);
+ return -ENOPKG;
}
ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, ==,