hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/net/rxrpc/key.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* RxRPC key management
23 *
34 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
45 * 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.
106 *
117 * RxRPC keys should have a description of describing their purpose:
128 * "afs@CAMBRIDGE.REDHAT.COM>
....@@ -43,6 +39,7 @@
4339 */
4440 struct key_type key_type_rxrpc = {
4541 .name = "rxrpc",
42
+ .flags = KEY_TYPE_NET_DOMAIN,
4643 .preparse = rxrpc_preparse,
4744 .free_preparse = rxrpc_free_preparse,
4845 .instantiate = generic_key_instantiate,
....@@ -58,6 +55,7 @@
5855 */
5956 struct key_type key_type_rxrpc_s = {
6057 .name = "rxrpc_s",
58
+ .flags = KEY_TYPE_NET_DOMAIN,
6159 .vet_description = rxrpc_vet_description_s,
6260 .preparse = rxrpc_preparse_s,
6361 .free_preparse = rxrpc_free_preparse_s,
....@@ -898,7 +896,7 @@
898896 /*
899897 * grab the security key for a socket
900898 */
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)
902900 {
903901 struct key *key;
904902 char *description;
....@@ -908,11 +906,11 @@
908906 if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities)
909907 return -EINVAL;
910908
911
- description = memdup_user_nul(optval, optlen);
909
+ description = memdup_sockptr_nul(optval, optlen);
912910 if (IS_ERR(description))
913911 return PTR_ERR(description);
914912
915
- key = request_key(&key_type_rxrpc, description, NULL);
913
+ key = request_key_net(&key_type_rxrpc, description, sock_net(&rx->sk), NULL);
916914 if (IS_ERR(key)) {
917915 kfree(description);
918916 _leave(" = %ld", PTR_ERR(key));
....@@ -928,8 +926,7 @@
928926 /*
929927 * grab the security keyring for a server socket
930928 */
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)
933930 {
934931 struct key *key;
935932 char *description;
....@@ -939,7 +936,7 @@
939936 if (optlen <= 0 || optlen > PAGE_SIZE - 1)
940937 return -EINVAL;
941938
942
- description = memdup_user_nul(optval, optlen);
939
+ description = memdup_sockptr_nul(optval, optlen);
943940 if (IS_ERR(description))
944941 return PTR_ERR(description);
945942