.. | .. |
---|
65 | 65 | u32 id; |
---|
66 | 66 | char name[IDMAP_NAMESZ]; |
---|
67 | 67 | char authname[IDMAP_NAMESZ]; |
---|
| 68 | + struct rcu_head rcu_head; |
---|
68 | 69 | }; |
---|
69 | 70 | |
---|
70 | 71 | /* Common entry handling */ |
---|
.. | .. |
---|
82 | 83 | new->type = itm->type; |
---|
83 | 84 | |
---|
84 | 85 | strlcpy(new->name, itm->name, sizeof(new->name)); |
---|
85 | | - strlcpy(new->authname, itm->authname, sizeof(new->name)); |
---|
| 86 | + strlcpy(new->authname, itm->authname, sizeof(new->authname)); |
---|
86 | 87 | } |
---|
87 | 88 | |
---|
88 | 89 | static void |
---|
89 | 90 | ent_put(struct kref *ref) |
---|
90 | 91 | { |
---|
91 | 92 | struct ent *map = container_of(ref, struct ent, h.ref); |
---|
92 | | - kfree(map); |
---|
| 93 | + kfree_rcu(map, rcu_head); |
---|
93 | 94 | } |
---|
94 | 95 | |
---|
95 | 96 | static struct cache_head * |
---|
.. | .. |
---|
119 | 120 | hash ^= 1; |
---|
120 | 121 | |
---|
121 | 122 | return hash; |
---|
| 123 | +} |
---|
| 124 | + |
---|
| 125 | +static int |
---|
| 126 | +idtoname_upcall(struct cache_detail *cd, struct cache_head *h) |
---|
| 127 | +{ |
---|
| 128 | + return sunrpc_cache_pipe_upcall_timeout(cd, h); |
---|
122 | 129 | } |
---|
123 | 130 | |
---|
124 | 131 | static void |
---|
.. | .. |
---|
161 | 168 | ent->id); |
---|
162 | 169 | if (test_bit(CACHE_VALID, &h->flags)) |
---|
163 | 170 | seq_printf(m, " %s", ent->name); |
---|
164 | | - seq_printf(m, "\n"); |
---|
| 171 | + seq_putc(m, '\n'); |
---|
165 | 172 | return 0; |
---|
166 | 173 | } |
---|
167 | 174 | |
---|
.. | .. |
---|
183 | 190 | .hash_size = ENT_HASHMAX, |
---|
184 | 191 | .name = "nfs4.idtoname", |
---|
185 | 192 | .cache_put = ent_put, |
---|
| 193 | + .cache_upcall = idtoname_upcall, |
---|
186 | 194 | .cache_request = idtoname_request, |
---|
187 | 195 | .cache_parse = idtoname_parse, |
---|
188 | 196 | .cache_show = idtoname_show, |
---|
.. | .. |
---|
264 | 272 | static struct ent * |
---|
265 | 273 | idtoname_lookup(struct cache_detail *cd, struct ent *item) |
---|
266 | 274 | { |
---|
267 | | - struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h, |
---|
268 | | - idtoname_hash(item)); |
---|
| 275 | + struct cache_head *ch = sunrpc_cache_lookup_rcu(cd, &item->h, |
---|
| 276 | + idtoname_hash(item)); |
---|
269 | 277 | if (ch) |
---|
270 | 278 | return container_of(ch, struct ent, h); |
---|
271 | 279 | else |
---|
.. | .. |
---|
292 | 300 | nametoid_hash(struct ent *ent) |
---|
293 | 301 | { |
---|
294 | 302 | return hash_str(ent->name, ENT_HASHBITS); |
---|
| 303 | +} |
---|
| 304 | + |
---|
| 305 | +static int |
---|
| 306 | +nametoid_upcall(struct cache_detail *cd, struct cache_head *h) |
---|
| 307 | +{ |
---|
| 308 | + return sunrpc_cache_pipe_upcall_timeout(cd, h); |
---|
295 | 309 | } |
---|
296 | 310 | |
---|
297 | 311 | static void |
---|
.. | .. |
---|
332 | 346 | ent->name); |
---|
333 | 347 | if (test_bit(CACHE_VALID, &h->flags)) |
---|
334 | 348 | seq_printf(m, " %u", ent->id); |
---|
335 | | - seq_printf(m, "\n"); |
---|
| 349 | + seq_putc(m, '\n'); |
---|
336 | 350 | return 0; |
---|
337 | 351 | } |
---|
338 | 352 | |
---|
.. | .. |
---|
346 | 360 | .hash_size = ENT_HASHMAX, |
---|
347 | 361 | .name = "nfs4.nametoid", |
---|
348 | 362 | .cache_put = ent_put, |
---|
| 363 | + .cache_upcall = nametoid_upcall, |
---|
349 | 364 | .cache_request = nametoid_request, |
---|
350 | 365 | .cache_parse = nametoid_parse, |
---|
351 | 366 | .cache_show = nametoid_show, |
---|
.. | .. |
---|
422 | 437 | static struct ent * |
---|
423 | 438 | nametoid_lookup(struct cache_detail *cd, struct ent *item) |
---|
424 | 439 | { |
---|
425 | | - struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h, |
---|
426 | | - nametoid_hash(item)); |
---|
| 440 | + struct cache_head *ch = sunrpc_cache_lookup_rcu(cd, &item->h, |
---|
| 441 | + nametoid_hash(item)); |
---|
427 | 442 | if (ch) |
---|
428 | 443 | return container_of(ch, struct ent, h); |
---|
429 | 444 | else |
---|
.. | .. |
---|
633 | 648 | return nfserr_inval; |
---|
634 | 649 | |
---|
635 | 650 | status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id); |
---|
636 | | - *uid = make_kuid(&init_user_ns, id); |
---|
| 651 | + *uid = make_kuid(nfsd_user_namespace(rqstp), id); |
---|
637 | 652 | if (!uid_valid(*uid)) |
---|
638 | 653 | status = nfserr_badowner; |
---|
639 | 654 | return status; |
---|
.. | .. |
---|
650 | 665 | return nfserr_inval; |
---|
651 | 666 | |
---|
652 | 667 | status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id); |
---|
653 | | - *gid = make_kgid(&init_user_ns, id); |
---|
| 668 | + *gid = make_kgid(nfsd_user_namespace(rqstp), id); |
---|
654 | 669 | if (!gid_valid(*gid)) |
---|
655 | 670 | status = nfserr_badowner; |
---|
656 | 671 | return status; |
---|
.. | .. |
---|
659 | 674 | __be32 nfsd4_encode_user(struct xdr_stream *xdr, struct svc_rqst *rqstp, |
---|
660 | 675 | kuid_t uid) |
---|
661 | 676 | { |
---|
662 | | - u32 id = from_kuid(&init_user_ns, uid); |
---|
| 677 | + u32 id = from_kuid_munged(nfsd_user_namespace(rqstp), uid); |
---|
663 | 678 | return encode_name_from_id(xdr, rqstp, IDMAP_TYPE_USER, id); |
---|
664 | 679 | } |
---|
665 | 680 | |
---|
666 | 681 | __be32 nfsd4_encode_group(struct xdr_stream *xdr, struct svc_rqst *rqstp, |
---|
667 | 682 | kgid_t gid) |
---|
668 | 683 | { |
---|
669 | | - u32 id = from_kgid(&init_user_ns, gid); |
---|
| 684 | + u32 id = from_kgid_munged(nfsd_user_namespace(rqstp), gid); |
---|
670 | 685 | return encode_name_from_id(xdr, rqstp, IDMAP_TYPE_GROUP, id); |
---|
671 | 686 | } |
---|