diff options
author | Marc Dionne <marc.dionne@auristor.com> | 2020-09-04 14:01:24 -0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-14 09:48:16 +0200 |
commit | 922888326eb52239f3a76bbb7aa3f1fb952c0076 (patch) | |
tree | a4a940bbb55ad6551c2aa572cfb8ab5eef7b2821 /net | |
parent | 22bc408f5d8c3087cbaf357e06d01341eda79fd0 (diff) | |
download | linux-stable-922888326eb52239f3a76bbb7aa3f1fb952c0076.tar.gz linux-stable-922888326eb52239f3a76bbb7aa3f1fb952c0076.tar.bz2 linux-stable-922888326eb52239f3a76bbb7aa3f1fb952c0076.zip |
rxrpc: Fix rxkad token xdr encoding
[ Upstream commit 56305118e05b2db8d0395bba640ac9a3aee92624 ]
The session key should be encoded with just the 8 data bytes and
no length; ENCODE_DATA precedes it with a 4 byte length, which
confuses some existing tools that try to parse this format.
Add an ENCODE_BYTES macro that does not include a length, and use
it for the key. Also adjust the expected length.
Note that commit 774521f353e1d ("rxrpc: Fix an assertion in
rxrpc_read()") had fixed a BUG by changing the length rather than
fixing the encoding. The original length was correct.
Fixes: 99455153d067 ("RxRPC: Parse security index 5 keys (Kerberos 5)")
Signed-off-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/rxrpc/key.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 7fc340726d03..fd9260620824 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -1139,6 +1139,14 @@ static long rxrpc_read(const struct key *key, goto fault; \ xdr += (_l + 3) >> 2; \ } while(0) +#define ENCODE_BYTES(l, s) \ + do { \ + u32 _l = (l); \ + memcpy(xdr, (s), _l); \ + if (_l & 3) \ + memcpy((u8 *)xdr + _l, &zero, 4 - (_l & 3)); \ + xdr += (_l + 3) >> 2; \ + } while(0) #define ENCODE64(x) \ do { \ __be64 y = cpu_to_be64(x); \ @@ -1167,7 +1175,7 @@ static long rxrpc_read(const struct key *key, case RXRPC_SECURITY_RXKAD: ENCODE(token->kad->vice_id); ENCODE(token->kad->kvno); - ENCODE_DATA(8, token->kad->session_key); + ENCODE_BYTES(8, token->kad->session_key); ENCODE(token->kad->start); ENCODE(token->kad->expiry); ENCODE(token->kad->primary_flag); |