hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/sunrpc/auth.h
....@@ -10,8 +10,6 @@
1010 #ifndef _LINUX_SUNRPC_AUTH_H
1111 #define _LINUX_SUNRPC_AUTH_H
1212
13
-#ifdef __KERNEL__
14
-
1513 #include <linux/sunrpc/sched.h>
1614 #include <linux/sunrpc/msg_prot.h>
1715 #include <linux/sunrpc/xdr.h>
....@@ -37,21 +35,9 @@
3735
3836 struct rpcsec_gss_info;
3937
40
-/* auth_cred ac_flags bits */
41
-enum {
42
- RPC_CRED_KEY_EXPIRE_SOON = 1, /* underlying cred key will expire soon */
43
- RPC_CRED_NOTIFY_TIMEOUT = 2, /* nofity generic cred when underlying
44
- key will expire soon */
45
-};
46
-
47
-/* Work around the lack of a VFS credential */
4838 struct auth_cred {
49
- kuid_t uid;
50
- kgid_t gid;
51
- struct group_info *group_info;
52
- const char *principal;
53
- unsigned long ac_flags;
54
- unsigned char machine_cred : 1;
39
+ const struct cred *cred;
40
+ const char *principal; /* If present, this is a machine credential */
5541 };
5642
5743 /*
....@@ -67,9 +53,8 @@
6753 const struct rpc_credops *cr_ops;
6854 unsigned long cr_expire; /* when to gc */
6955 unsigned long cr_flags; /* various flags */
70
- atomic_t cr_count; /* ref count */
71
-
72
- kuid_t cr_uid;
56
+ refcount_t cr_count; /* ref count */
57
+ const struct cred *cr_cred;
7358
7459 /* per-flavor data */
7560 };
....@@ -78,8 +63,7 @@
7863 #define RPCAUTH_CRED_HASHED 2
7964 #define RPCAUTH_CRED_NEGATIVE 3
8065
81
-/* rpc_auth au_flags */
82
-#define RPCAUTH_AUTH_NO_CRKEY_TIMEOUT 0x0001 /* underlying cred has no key timeout */
66
+const struct cred *rpc_machine_cred(void);
8367
8468 /*
8569 * Client authentication handle
....@@ -88,26 +72,25 @@
8872 struct rpc_authops;
8973 struct rpc_auth {
9074 unsigned int au_cslack; /* call cred size estimate */
91
- /* guess at number of u32's auth adds before
92
- * reply data; normally the verifier size: */
93
- unsigned int au_rslack;
94
- /* for gss, used to calculate au_rslack: */
95
- unsigned int au_verfsize;
75
+ unsigned int au_rslack; /* reply cred size estimate */
76
+ unsigned int au_verfsize; /* size of reply verifier */
77
+ unsigned int au_ralign; /* words before UL header */
9678
97
- unsigned int au_flags; /* various flags */
98
- const struct rpc_authops *au_ops; /* operations */
79
+ unsigned long au_flags;
80
+ const struct rpc_authops *au_ops;
9981 rpc_authflavor_t au_flavor; /* pseudoflavor (note may
10082 * differ from the flavor in
10183 * au_ops->au_flavor in gss
10284 * case) */
103
- atomic_t au_count; /* Reference counter */
85
+ refcount_t au_count; /* Reference counter */
10486
10587 struct rpc_cred_cache * au_credcache;
10688 /* per-flavor data */
10789 };
10890
10991 /* rpc_auth au_flags */
110
-#define RPCAUTH_AUTH_DATATOUCH 0x00000002
92
+#define RPCAUTH_AUTH_DATATOUCH (1)
93
+#define RPCAUTH_AUTH_UPDATE_SLACK (2)
11194
11295 struct rpc_auth_create_args {
11396 rpc_authflavor_t pseudoflavor;
....@@ -116,7 +99,6 @@
11699
117100 /* Flags for rpcauth_lookupcred() */
118101 #define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */
119
-#define RPCAUTH_LOOKUP_RCU 0x02 /* lock-less lookup */
120102
121103 /*
122104 * Client authentication ops
....@@ -132,7 +114,6 @@
132114 int (*hash_cred)(struct auth_cred *, unsigned int);
133115 struct rpc_cred * (*lookup_cred)(struct rpc_auth *, struct auth_cred *, int);
134116 struct rpc_cred * (*crcreate)(struct rpc_auth*, struct auth_cred *, int, gfp_t);
135
- int (*list_pseudoflavors)(rpc_authflavor_t *, int);
136117 rpc_authflavor_t (*info2flavor)(struct rpcsec_gss_info *);
137118 int (*flavor2info)(rpc_authflavor_t,
138119 struct rpcsec_gss_info *);
....@@ -146,33 +127,28 @@
146127 void (*crdestroy)(struct rpc_cred *);
147128
148129 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
149
- struct rpc_cred * (*crbind)(struct rpc_task *, struct rpc_cred *, int);
150
- __be32 * (*crmarshal)(struct rpc_task *, __be32 *);
130
+ int (*crmarshal)(struct rpc_task *task,
131
+ struct xdr_stream *xdr);
151132 int (*crrefresh)(struct rpc_task *);
152
- __be32 * (*crvalidate)(struct rpc_task *, __be32 *);
153
- int (*crwrap_req)(struct rpc_task *, kxdreproc_t,
154
- void *, __be32 *, void *);
155
- int (*crunwrap_resp)(struct rpc_task *, kxdrdproc_t,
156
- void *, __be32 *, void *);
133
+ int (*crvalidate)(struct rpc_task *task,
134
+ struct xdr_stream *xdr);
135
+ int (*crwrap_req)(struct rpc_task *task,
136
+ struct xdr_stream *xdr);
137
+ int (*crunwrap_resp)(struct rpc_task *task,
138
+ struct xdr_stream *xdr);
157139 int (*crkey_timeout)(struct rpc_cred *);
158
- bool (*crkey_to_expire)(struct rpc_cred *);
159140 char * (*crstringify_acceptor)(struct rpc_cred *);
141
+ bool (*crneed_reencode)(struct rpc_task *);
160142 };
161143
162144 extern const struct rpc_authops authunix_ops;
163145 extern const struct rpc_authops authnull_ops;
164146
165147 int __init rpc_init_authunix(void);
166
-int __init rpc_init_generic_auth(void);
167148 int __init rpcauth_init_module(void);
168149 void rpcauth_remove_module(void);
169
-void rpc_destroy_generic_auth(void);
170150 void rpc_destroy_authunix(void);
171151
172
-struct rpc_cred * rpc_lookup_cred(void);
173
-struct rpc_cred * rpc_lookup_cred_nonblock(void);
174
-struct rpc_cred * rpc_lookup_generic_cred(struct auth_cred *, int, gfp_t);
175
-struct rpc_cred * rpc_lookup_machine_cred(const char *service_name);
176152 int rpcauth_register(const struct rpc_authops *);
177153 int rpcauth_unregister(const struct rpc_authops *);
178154 struct rpc_auth * rpcauth_create(const struct rpc_auth_create_args *,
....@@ -182,52 +158,37 @@
182158 struct rpcsec_gss_info *);
183159 int rpcauth_get_gssinfo(rpc_authflavor_t,
184160 struct rpcsec_gss_info *);
185
-int rpcauth_list_flavors(rpc_authflavor_t *, int);
186161 struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int, gfp_t);
187162 void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *);
188163 struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int);
189
-struct rpc_cred * rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int);
190164 void put_rpccred(struct rpc_cred *);
191
-__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *);
192
-__be32 * rpcauth_checkverf(struct rpc_task *, __be32 *);
193
-int rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, __be32 *data, void *obj);
194
-int rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, __be32 *data, void *obj);
165
+int rpcauth_marshcred(struct rpc_task *task,
166
+ struct xdr_stream *xdr);
167
+int rpcauth_checkverf(struct rpc_task *task,
168
+ struct xdr_stream *xdr);
169
+int rpcauth_wrap_req_encode(struct rpc_task *task,
170
+ struct xdr_stream *xdr);
171
+int rpcauth_wrap_req(struct rpc_task *task,
172
+ struct xdr_stream *xdr);
173
+int rpcauth_unwrap_resp_decode(struct rpc_task *task,
174
+ struct xdr_stream *xdr);
175
+int rpcauth_unwrap_resp(struct rpc_task *task,
176
+ struct xdr_stream *xdr);
177
+bool rpcauth_xmit_need_reencode(struct rpc_task *task);
195178 int rpcauth_refreshcred(struct rpc_task *);
196179 void rpcauth_invalcred(struct rpc_task *);
197180 int rpcauth_uptodatecred(struct rpc_task *);
198181 int rpcauth_init_credcache(struct rpc_auth *);
199182 void rpcauth_destroy_credcache(struct rpc_auth *);
200183 void rpcauth_clear_credcache(struct rpc_cred_cache *);
201
-int rpcauth_key_timeout_notify(struct rpc_auth *,
202
- struct rpc_cred *);
203
-bool rpcauth_cred_key_to_expire(struct rpc_auth *, struct rpc_cred *);
204184 char * rpcauth_stringify_acceptor(struct rpc_cred *);
205185
206186 static inline
207
-struct rpc_cred * get_rpccred(struct rpc_cred *cred)
187
+struct rpc_cred *get_rpccred(struct rpc_cred *cred)
208188 {
209
- if (cred != NULL)
210
- atomic_inc(&cred->cr_count);
211
- return cred;
212
-}
213
-
214
-/**
215
- * get_rpccred_rcu - get a reference to a cred using rcu-protected pointer
216
- * @cred: cred of which to take a reference
217
- *
218
- * In some cases, we may have a pointer to a credential to which we
219
- * want to take a reference, but don't already have one. Because these
220
- * objects are freed using RCU, we can access the cr_count while its
221
- * on its way to destruction and only take a reference if it's not already
222
- * zero.
223
- */
224
-static inline struct rpc_cred *
225
-get_rpccred_rcu(struct rpc_cred *cred)
226
-{
227
- if (atomic_inc_not_zero(&cred->cr_count))
189
+ if (cred != NULL && refcount_inc_not_zero(&cred->cr_count))
228190 return cred;
229191 return NULL;
230192 }
231193
232
-#endif /* __KERNEL__ */
233194 #endif /* _LINUX_SUNRPC_AUTH_H */