| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* RxRPC key management |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
|---|
| 4 | 5 | * Written by David Howells (dhowells@redhat.com) |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or |
|---|
| 7 | | - * modify it under the terms of the GNU General Public License |
|---|
| 8 | | - * as published by the Free Software Foundation; either version |
|---|
| 9 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 10 | 6 | * |
|---|
| 11 | 7 | * RxRPC keys should have a description of describing their purpose: |
|---|
| 12 | 8 | * "afs@CAMBRIDGE.REDHAT.COM> |
|---|
| .. | .. |
|---|
| 43 | 39 | */ |
|---|
| 44 | 40 | struct key_type key_type_rxrpc = { |
|---|
| 45 | 41 | .name = "rxrpc", |
|---|
| 42 | + .flags = KEY_TYPE_NET_DOMAIN, |
|---|
| 46 | 43 | .preparse = rxrpc_preparse, |
|---|
| 47 | 44 | .free_preparse = rxrpc_free_preparse, |
|---|
| 48 | 45 | .instantiate = generic_key_instantiate, |
|---|
| .. | .. |
|---|
| 58 | 55 | */ |
|---|
| 59 | 56 | struct key_type key_type_rxrpc_s = { |
|---|
| 60 | 57 | .name = "rxrpc_s", |
|---|
| 58 | + .flags = KEY_TYPE_NET_DOMAIN, |
|---|
| 61 | 59 | .vet_description = rxrpc_vet_description_s, |
|---|
| 62 | 60 | .preparse = rxrpc_preparse_s, |
|---|
| 63 | 61 | .free_preparse = rxrpc_free_preparse_s, |
|---|
| .. | .. |
|---|
| 898 | 896 | /* |
|---|
| 899 | 897 | * grab the security key for a socket |
|---|
| 900 | 898 | */ |
|---|
| 901 | | -int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) |
|---|
| 899 | +int rxrpc_request_key(struct rxrpc_sock *rx, sockptr_t optval, int optlen) |
|---|
| 902 | 900 | { |
|---|
| 903 | 901 | struct key *key; |
|---|
| 904 | 902 | char *description; |
|---|
| .. | .. |
|---|
| 908 | 906 | if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities) |
|---|
| 909 | 907 | return -EINVAL; |
|---|
| 910 | 908 | |
|---|
| 911 | | - description = memdup_user_nul(optval, optlen); |
|---|
| 909 | + description = memdup_sockptr_nul(optval, optlen); |
|---|
| 912 | 910 | if (IS_ERR(description)) |
|---|
| 913 | 911 | return PTR_ERR(description); |
|---|
| 914 | 912 | |
|---|
| 915 | | - key = request_key(&key_type_rxrpc, description, NULL); |
|---|
| 913 | + key = request_key_net(&key_type_rxrpc, description, sock_net(&rx->sk), NULL); |
|---|
| 916 | 914 | if (IS_ERR(key)) { |
|---|
| 917 | 915 | kfree(description); |
|---|
| 918 | 916 | _leave(" = %ld", PTR_ERR(key)); |
|---|
| .. | .. |
|---|
| 928 | 926 | /* |
|---|
| 929 | 927 | * grab the security keyring for a server socket |
|---|
| 930 | 928 | */ |
|---|
| 931 | | -int rxrpc_server_keyring(struct rxrpc_sock *rx, char __user *optval, |
|---|
| 932 | | - int optlen) |
|---|
| 929 | +int rxrpc_server_keyring(struct rxrpc_sock *rx, sockptr_t optval, int optlen) |
|---|
| 933 | 930 | { |
|---|
| 934 | 931 | struct key *key; |
|---|
| 935 | 932 | char *description; |
|---|
| .. | .. |
|---|
| 939 | 936 | if (optlen <= 0 || optlen > PAGE_SIZE - 1) |
|---|
| 940 | 937 | return -EINVAL; |
|---|
| 941 | 938 | |
|---|
| 942 | | - description = memdup_user_nul(optval, optlen); |
|---|
| 939 | + description = memdup_sockptr_nul(optval, optlen); |
|---|
| 943 | 940 | if (IS_ERR(description)) |
|---|
| 944 | 941 | return PTR_ERR(description); |
|---|
| 945 | 942 | |
|---|