Skip to content

Commit d2ae4e9

Browse files
committed
rxrpc: Don't leak the service-side session key to userspace
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>
1 parent 12da59f commit d2ae4e9

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎include/keys/rxrpc-type.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct rxkad_key {
3636
*/
3737
struct rxrpc_key_token {
3838
u16 security_index; /* RxRPC header security index */
39+
bool no_leak_key; /* Don't copy the key to userspace */
3940
struct rxrpc_key_token *next; /* the next token in the list */
4041
union {
4142
struct rxkad_key *kad;

‎net/rxrpc/key.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ static long rxrpc_read(const struct key *key,
579579
case RXRPC_SECURITY_RXKAD:
580580
toksize += 8 * 4; /* viceid, kvno, key*2, begin,
581581
* end, primary, tktlen */
582-
toksize += RND(token->kad->ticket_len);
582+
if (!token->no_leak_key)
583+
toksize += RND(token->kad->ticket_len);
583584
break;
584585

585586
default: /* we have a ticket we can't encode */
@@ -654,7 +655,10 @@ static long rxrpc_read(const struct key *key,
654655
ENCODE(token->kad->start);
655656
ENCODE(token->kad->expiry);
656657
ENCODE(token->kad->primary_flag);
657-
ENCODE_DATA(token->kad->ticket_len, token->kad->ticket);
658+
if (token->no_leak_key)
659+
ENCODE(0);
660+
else
661+
ENCODE_DATA(token->kad->ticket_len, token->kad->ticket);
658662
break;
659663

660664
default:

0 commit comments

Comments
 (0)