.. | .. |
---|
10 | 10 | #ifndef _LINUX_SUNRPC_AUTH_H |
---|
11 | 11 | #define _LINUX_SUNRPC_AUTH_H |
---|
12 | 12 | |
---|
13 | | -#ifdef __KERNEL__ |
---|
14 | | - |
---|
15 | 13 | #include <linux/sunrpc/sched.h> |
---|
16 | 14 | #include <linux/sunrpc/msg_prot.h> |
---|
17 | 15 | #include <linux/sunrpc/xdr.h> |
---|
.. | .. |
---|
37 | 35 | |
---|
38 | 36 | struct rpcsec_gss_info; |
---|
39 | 37 | |
---|
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 */ |
---|
48 | 38 | 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 */ |
---|
55 | 41 | }; |
---|
56 | 42 | |
---|
57 | 43 | /* |
---|
.. | .. |
---|
67 | 53 | const struct rpc_credops *cr_ops; |
---|
68 | 54 | unsigned long cr_expire; /* when to gc */ |
---|
69 | 55 | 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; |
---|
73 | 58 | |
---|
74 | 59 | /* per-flavor data */ |
---|
75 | 60 | }; |
---|
.. | .. |
---|
78 | 63 | #define RPCAUTH_CRED_HASHED 2 |
---|
79 | 64 | #define RPCAUTH_CRED_NEGATIVE 3 |
---|
80 | 65 | |
---|
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); |
---|
83 | 67 | |
---|
84 | 68 | /* |
---|
85 | 69 | * Client authentication handle |
---|
.. | .. |
---|
88 | 72 | struct rpc_authops; |
---|
89 | 73 | struct rpc_auth { |
---|
90 | 74 | 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 */ |
---|
96 | 78 | |
---|
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; |
---|
99 | 81 | rpc_authflavor_t au_flavor; /* pseudoflavor (note may |
---|
100 | 82 | * differ from the flavor in |
---|
101 | 83 | * au_ops->au_flavor in gss |
---|
102 | 84 | * case) */ |
---|
103 | | - atomic_t au_count; /* Reference counter */ |
---|
| 85 | + refcount_t au_count; /* Reference counter */ |
---|
104 | 86 | |
---|
105 | 87 | struct rpc_cred_cache * au_credcache; |
---|
106 | 88 | /* per-flavor data */ |
---|
107 | 89 | }; |
---|
108 | 90 | |
---|
109 | 91 | /* rpc_auth au_flags */ |
---|
110 | | -#define RPCAUTH_AUTH_DATATOUCH 0x00000002 |
---|
| 92 | +#define RPCAUTH_AUTH_DATATOUCH (1) |
---|
| 93 | +#define RPCAUTH_AUTH_UPDATE_SLACK (2) |
---|
111 | 94 | |
---|
112 | 95 | struct rpc_auth_create_args { |
---|
113 | 96 | rpc_authflavor_t pseudoflavor; |
---|
.. | .. |
---|
116 | 99 | |
---|
117 | 100 | /* Flags for rpcauth_lookupcred() */ |
---|
118 | 101 | #define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */ |
---|
119 | | -#define RPCAUTH_LOOKUP_RCU 0x02 /* lock-less lookup */ |
---|
120 | 102 | |
---|
121 | 103 | /* |
---|
122 | 104 | * Client authentication ops |
---|
.. | .. |
---|
132 | 114 | int (*hash_cred)(struct auth_cred *, unsigned int); |
---|
133 | 115 | struct rpc_cred * (*lookup_cred)(struct rpc_auth *, struct auth_cred *, int); |
---|
134 | 116 | struct rpc_cred * (*crcreate)(struct rpc_auth*, struct auth_cred *, int, gfp_t); |
---|
135 | | - int (*list_pseudoflavors)(rpc_authflavor_t *, int); |
---|
136 | 117 | rpc_authflavor_t (*info2flavor)(struct rpcsec_gss_info *); |
---|
137 | 118 | int (*flavor2info)(rpc_authflavor_t, |
---|
138 | 119 | struct rpcsec_gss_info *); |
---|
.. | .. |
---|
146 | 127 | void (*crdestroy)(struct rpc_cred *); |
---|
147 | 128 | |
---|
148 | 129 | 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); |
---|
151 | 132 | 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); |
---|
157 | 139 | int (*crkey_timeout)(struct rpc_cred *); |
---|
158 | | - bool (*crkey_to_expire)(struct rpc_cred *); |
---|
159 | 140 | char * (*crstringify_acceptor)(struct rpc_cred *); |
---|
| 141 | + bool (*crneed_reencode)(struct rpc_task *); |
---|
160 | 142 | }; |
---|
161 | 143 | |
---|
162 | 144 | extern const struct rpc_authops authunix_ops; |
---|
163 | 145 | extern const struct rpc_authops authnull_ops; |
---|
164 | 146 | |
---|
165 | 147 | int __init rpc_init_authunix(void); |
---|
166 | | -int __init rpc_init_generic_auth(void); |
---|
167 | 148 | int __init rpcauth_init_module(void); |
---|
168 | 149 | void rpcauth_remove_module(void); |
---|
169 | | -void rpc_destroy_generic_auth(void); |
---|
170 | 150 | void rpc_destroy_authunix(void); |
---|
171 | 151 | |
---|
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); |
---|
176 | 152 | int rpcauth_register(const struct rpc_authops *); |
---|
177 | 153 | int rpcauth_unregister(const struct rpc_authops *); |
---|
178 | 154 | struct rpc_auth * rpcauth_create(const struct rpc_auth_create_args *, |
---|
.. | .. |
---|
182 | 158 | struct rpcsec_gss_info *); |
---|
183 | 159 | int rpcauth_get_gssinfo(rpc_authflavor_t, |
---|
184 | 160 | struct rpcsec_gss_info *); |
---|
185 | | -int rpcauth_list_flavors(rpc_authflavor_t *, int); |
---|
186 | 161 | struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int, gfp_t); |
---|
187 | 162 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); |
---|
188 | 163 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
---|
189 | | -struct rpc_cred * rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int); |
---|
190 | 164 | 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); |
---|
195 | 178 | int rpcauth_refreshcred(struct rpc_task *); |
---|
196 | 179 | void rpcauth_invalcred(struct rpc_task *); |
---|
197 | 180 | int rpcauth_uptodatecred(struct rpc_task *); |
---|
198 | 181 | int rpcauth_init_credcache(struct rpc_auth *); |
---|
199 | 182 | void rpcauth_destroy_credcache(struct rpc_auth *); |
---|
200 | 183 | 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 *); |
---|
204 | 184 | char * rpcauth_stringify_acceptor(struct rpc_cred *); |
---|
205 | 185 | |
---|
206 | 186 | static inline |
---|
207 | | -struct rpc_cred * get_rpccred(struct rpc_cred *cred) |
---|
| 187 | +struct rpc_cred *get_rpccred(struct rpc_cred *cred) |
---|
208 | 188 | { |
---|
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)) |
---|
228 | 190 | return cred; |
---|
229 | 191 | return NULL; |
---|
230 | 192 | } |
---|
231 | 193 | |
---|
232 | | -#endif /* __KERNEL__ */ |
---|
233 | 194 | #endif /* _LINUX_SUNRPC_AUTH_H */ |
---|