Skip to content

Commit

Permalink
rxrpc: Don't leak the service-side session key to userspace
Browse files Browse the repository at this point in the history
Don't let someone reading a service-side rxrpc-type key get access to the
session key that was exchanged with the client.  The server application
will, at some point, need to be able to read the information in the ticket,
but this probably shouldn't include the key material.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
dhowells committed Nov 23, 2020
1 parent 12da59f commit d2ae4e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/keys/rxrpc-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct rxkad_key {
*/
struct rxrpc_key_token {
u16 security_index; /* RxRPC header security index */
bool no_leak_key; /* Don't copy the key to userspace */
struct rxrpc_key_token *next; /* the next token in the list */
union {
struct rxkad_key *kad;
Expand Down
8 changes: 6 additions & 2 deletions net/rxrpc/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ static long rxrpc_read(const struct key *key,
case RXRPC_SECURITY_RXKAD:
toksize += 8 * 4; /* viceid, kvno, key*2, begin,
* end, primary, tktlen */
toksize += RND(token->kad->ticket_len);
if (!token->no_leak_key)
toksize += RND(token->kad->ticket_len);
break;

default: /* we have a ticket we can't encode */
Expand Down Expand Up @@ -654,7 +655,10 @@ static long rxrpc_read(const struct key *key,
ENCODE(token->kad->start);
ENCODE(token->kad->expiry);
ENCODE(token->kad->primary_flag);
ENCODE_DATA(token->kad->ticket_len, token->kad->ticket);
if (token->no_leak_key)
ENCODE(0);
else
ENCODE_DATA(token->kad->ticket_len, token->kad->ticket);
break;

default:
Expand Down

0 comments on commit d2ae4e9

Please sign in to comment.