nfs4idmap.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * Mapping of UID/GIDs to name and vice versa.
  3. *
  4. * Copyright (c) 2002, 2003 The Regents of the University of
  5. * Michigan. All rights reserved.
  6. *
  7. * Marius Aamodt Eriksen <marius@umich.edu>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the University nor the names of its
  19. * contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  23. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  24. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  29. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <linux/module.h>
  35. #include <linux/seq_file.h>
  36. #include <linux/sched.h>
  37. #include <linux/slab.h>
  38. #include <linux/sunrpc/svc_xprt.h>
  39. #include <net/net_namespace.h>
  40. #include "idmap.h"
  41. #include "nfsd.h"
  42. #include "netns.h"
  43. /*
  44. * Turn off idmapping when using AUTH_SYS.
  45. */
  46. static bool nfs4_disable_idmapping = true;
  47. module_param(nfs4_disable_idmapping, bool, 0644);
  48. MODULE_PARM_DESC(nfs4_disable_idmapping,
  49. "Turn off server's NFSv4 idmapping when using 'sec=sys'");
  50. /*
  51. * Cache entry
  52. */
  53. /*
  54. * XXX we know that IDMAP_NAMESZ < PAGE_SIZE, but it's ugly to rely on
  55. * that.
  56. */
  57. #define IDMAP_TYPE_USER 0
  58. #define IDMAP_TYPE_GROUP 1
  59. struct ent {
  60. struct cache_head h;
  61. int type; /* User / Group */
  62. u32 id;
  63. char name[IDMAP_NAMESZ];
  64. char authname[IDMAP_NAMESZ];
  65. };
  66. /* Common entry handling */
  67. #define ENT_HASHBITS 8
  68. #define ENT_HASHMAX (1 << ENT_HASHBITS)
  69. static void
  70. ent_init(struct cache_head *cnew, struct cache_head *citm)
  71. {
  72. struct ent *new = container_of(cnew, struct ent, h);
  73. struct ent *itm = container_of(citm, struct ent, h);
  74. new->id = itm->id;
  75. new->type = itm->type;
  76. strlcpy(new->name, itm->name, sizeof(new->name));
  77. strlcpy(new->authname, itm->authname, sizeof(new->name));
  78. }
  79. static void
  80. ent_put(struct kref *ref)
  81. {
  82. struct ent *map = container_of(ref, struct ent, h.ref);
  83. kfree(map);
  84. }
  85. static struct cache_head *
  86. ent_alloc(void)
  87. {
  88. struct ent *e = kmalloc(sizeof(*e), GFP_KERNEL);
  89. if (e)
  90. return &e->h;
  91. else
  92. return NULL;
  93. }
  94. /*
  95. * ID -> Name cache
  96. */
  97. static uint32_t
  98. idtoname_hash(struct ent *ent)
  99. {
  100. uint32_t hash;
  101. hash = hash_str(ent->authname, ENT_HASHBITS);
  102. hash = hash_long(hash ^ ent->id, ENT_HASHBITS);
  103. /* Flip LSB for user/group */
  104. if (ent->type == IDMAP_TYPE_GROUP)
  105. hash ^= 1;
  106. return hash;
  107. }
  108. static void
  109. idtoname_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
  110. int *blen)
  111. {
  112. struct ent *ent = container_of(ch, struct ent, h);
  113. char idstr[11];
  114. qword_add(bpp, blen, ent->authname);
  115. snprintf(idstr, sizeof(idstr), "%u", ent->id);
  116. qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
  117. qword_add(bpp, blen, idstr);
  118. (*bpp)[-1] = '\n';
  119. }
  120. static int
  121. idtoname_match(struct cache_head *ca, struct cache_head *cb)
  122. {
  123. struct ent *a = container_of(ca, struct ent, h);
  124. struct ent *b = container_of(cb, struct ent, h);
  125. return (a->id == b->id && a->type == b->type &&
  126. strcmp(a->authname, b->authname) == 0);
  127. }
  128. static int
  129. idtoname_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
  130. {
  131. struct ent *ent;
  132. if (h == NULL) {
  133. seq_puts(m, "#domain type id [name]\n");
  134. return 0;
  135. }
  136. ent = container_of(h, struct ent, h);
  137. seq_printf(m, "%s %s %u", ent->authname,
  138. ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
  139. ent->id);
  140. if (test_bit(CACHE_VALID, &h->flags))
  141. seq_printf(m, " %s", ent->name);
  142. seq_printf(m, "\n");
  143. return 0;
  144. }
  145. static void
  146. warn_no_idmapd(struct cache_detail *detail, int has_died)
  147. {
  148. printk("nfsd: nfsv4 idmapping failing: has idmapd %s?\n",
  149. has_died ? "died" : "not been started");
  150. }
  151. static int idtoname_parse(struct cache_detail *, char *, int);
  152. static struct ent *idtoname_lookup(struct cache_detail *, struct ent *);
  153. static struct ent *idtoname_update(struct cache_detail *, struct ent *,
  154. struct ent *);
  155. static struct cache_detail idtoname_cache_template = {
  156. .owner = THIS_MODULE,
  157. .hash_size = ENT_HASHMAX,
  158. .name = "nfs4.idtoname",
  159. .cache_put = ent_put,
  160. .cache_request = idtoname_request,
  161. .cache_parse = idtoname_parse,
  162. .cache_show = idtoname_show,
  163. .warn_no_listener = warn_no_idmapd,
  164. .match = idtoname_match,
  165. .init = ent_init,
  166. .update = ent_init,
  167. .alloc = ent_alloc,
  168. };
  169. static int
  170. idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
  171. {
  172. struct ent ent, *res;
  173. char *buf1, *bp;
  174. int len;
  175. int error = -EINVAL;
  176. if (buf[buflen - 1] != '\n')
  177. return (-EINVAL);
  178. buf[buflen - 1]= '\0';
  179. buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
  180. if (buf1 == NULL)
  181. return (-ENOMEM);
  182. memset(&ent, 0, sizeof(ent));
  183. /* Authentication name */
  184. if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
  185. goto out;
  186. memcpy(ent.authname, buf1, sizeof(ent.authname));
  187. /* Type */
  188. if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
  189. goto out;
  190. ent.type = strcmp(buf1, "user") == 0 ?
  191. IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;
  192. /* ID */
  193. if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
  194. goto out;
  195. ent.id = simple_strtoul(buf1, &bp, 10);
  196. if (bp == buf1)
  197. goto out;
  198. /* expiry */
  199. ent.h.expiry_time = get_expiry(&buf);
  200. if (ent.h.expiry_time == 0)
  201. goto out;
  202. error = -ENOMEM;
  203. res = idtoname_lookup(cd, &ent);
  204. if (!res)
  205. goto out;
  206. /* Name */
  207. error = -EINVAL;
  208. len = qword_get(&buf, buf1, PAGE_SIZE);
  209. if (len < 0)
  210. goto out;
  211. if (len == 0)
  212. set_bit(CACHE_NEGATIVE, &ent.h.flags);
  213. else if (len >= IDMAP_NAMESZ)
  214. goto out;
  215. else
  216. memcpy(ent.name, buf1, sizeof(ent.name));
  217. error = -ENOMEM;
  218. res = idtoname_update(cd, &ent, res);
  219. if (res == NULL)
  220. goto out;
  221. cache_put(&res->h, cd);
  222. error = 0;
  223. out:
  224. kfree(buf1);
  225. return error;
  226. }
  227. static struct ent *
  228. idtoname_lookup(struct cache_detail *cd, struct ent *item)
  229. {
  230. struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
  231. idtoname_hash(item));
  232. if (ch)
  233. return container_of(ch, struct ent, h);
  234. else
  235. return NULL;
  236. }
  237. static struct ent *
  238. idtoname_update(struct cache_detail *cd, struct ent *new, struct ent *old)
  239. {
  240. struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h,
  241. idtoname_hash(new));
  242. if (ch)
  243. return container_of(ch, struct ent, h);
  244. else
  245. return NULL;
  246. }
  247. /*
  248. * Name -> ID cache
  249. */
  250. static inline int
  251. nametoid_hash(struct ent *ent)
  252. {
  253. return hash_str(ent->name, ENT_HASHBITS);
  254. }
  255. static void
  256. nametoid_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
  257. int *blen)
  258. {
  259. struct ent *ent = container_of(ch, struct ent, h);
  260. qword_add(bpp, blen, ent->authname);
  261. qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
  262. qword_add(bpp, blen, ent->name);
  263. (*bpp)[-1] = '\n';
  264. }
  265. static int
  266. nametoid_match(struct cache_head *ca, struct cache_head *cb)
  267. {
  268. struct ent *a = container_of(ca, struct ent, h);
  269. struct ent *b = container_of(cb, struct ent, h);
  270. return (a->type == b->type && strcmp(a->name, b->name) == 0 &&
  271. strcmp(a->authname, b->authname) == 0);
  272. }
  273. static int
  274. nametoid_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
  275. {
  276. struct ent *ent;
  277. if (h == NULL) {
  278. seq_puts(m, "#domain type name [id]\n");
  279. return 0;
  280. }
  281. ent = container_of(h, struct ent, h);
  282. seq_printf(m, "%s %s %s", ent->authname,
  283. ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
  284. ent->name);
  285. if (test_bit(CACHE_VALID, &h->flags))
  286. seq_printf(m, " %u", ent->id);
  287. seq_printf(m, "\n");
  288. return 0;
  289. }
  290. static struct ent *nametoid_lookup(struct cache_detail *, struct ent *);
  291. static struct ent *nametoid_update(struct cache_detail *, struct ent *,
  292. struct ent *);
  293. static int nametoid_parse(struct cache_detail *, char *, int);
  294. static struct cache_detail nametoid_cache_template = {
  295. .owner = THIS_MODULE,
  296. .hash_size = ENT_HASHMAX,
  297. .name = "nfs4.nametoid",
  298. .cache_put = ent_put,
  299. .cache_request = nametoid_request,
  300. .cache_parse = nametoid_parse,
  301. .cache_show = nametoid_show,
  302. .warn_no_listener = warn_no_idmapd,
  303. .match = nametoid_match,
  304. .init = ent_init,
  305. .update = ent_init,
  306. .alloc = ent_alloc,
  307. };
  308. static int
  309. nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
  310. {
  311. struct ent ent, *res;
  312. char *buf1;
  313. int error = -EINVAL;
  314. if (buf[buflen - 1] != '\n')
  315. return (-EINVAL);
  316. buf[buflen - 1]= '\0';
  317. buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
  318. if (buf1 == NULL)
  319. return (-ENOMEM);
  320. memset(&ent, 0, sizeof(ent));
  321. /* Authentication name */
  322. if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
  323. goto out;
  324. memcpy(ent.authname, buf1, sizeof(ent.authname));
  325. /* Type */
  326. if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
  327. goto out;
  328. ent.type = strcmp(buf1, "user") == 0 ?
  329. IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;
  330. /* Name */
  331. error = qword_get(&buf, buf1, PAGE_SIZE);
  332. if (error <= 0 || error >= IDMAP_NAMESZ)
  333. goto out;
  334. memcpy(ent.name, buf1, sizeof(ent.name));
  335. /* expiry */
  336. ent.h.expiry_time = get_expiry(&buf);
  337. if (ent.h.expiry_time == 0)
  338. goto out;
  339. /* ID */
  340. error = get_int(&buf, &ent.id);
  341. if (error == -EINVAL)
  342. goto out;
  343. if (error == -ENOENT)
  344. set_bit(CACHE_NEGATIVE, &ent.h.flags);
  345. error = -ENOMEM;
  346. res = nametoid_lookup(cd, &ent);
  347. if (res == NULL)
  348. goto out;
  349. res = nametoid_update(cd, &ent, res);
  350. if (res == NULL)
  351. goto out;
  352. cache_put(&res->h, cd);
  353. error = 0;
  354. out:
  355. kfree(buf1);
  356. return (error);
  357. }
  358. static struct ent *
  359. nametoid_lookup(struct cache_detail *cd, struct ent *item)
  360. {
  361. struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
  362. nametoid_hash(item));
  363. if (ch)
  364. return container_of(ch, struct ent, h);
  365. else
  366. return NULL;
  367. }
  368. static struct ent *
  369. nametoid_update(struct cache_detail *cd, struct ent *new, struct ent *old)
  370. {
  371. struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h,
  372. nametoid_hash(new));
  373. if (ch)
  374. return container_of(ch, struct ent, h);
  375. else
  376. return NULL;
  377. }
  378. /*
  379. * Exported API
  380. */
  381. int
  382. nfsd_idmap_init(struct net *net)
  383. {
  384. int rv;
  385. struct nfsd_net *nn = net_generic(net, nfsd_net_id);
  386. nn->idtoname_cache = cache_create_net(&idtoname_cache_template, net);
  387. if (IS_ERR(nn->idtoname_cache))
  388. return PTR_ERR(nn->idtoname_cache);
  389. rv = cache_register_net(nn->idtoname_cache, net);
  390. if (rv)
  391. goto destroy_idtoname_cache;
  392. nn->nametoid_cache = cache_create_net(&nametoid_cache_template, net);
  393. if (IS_ERR(nn->nametoid_cache)) {
  394. rv = PTR_ERR(nn->nametoid_cache);
  395. goto unregister_idtoname_cache;
  396. }
  397. rv = cache_register_net(nn->nametoid_cache, net);
  398. if (rv)
  399. goto destroy_nametoid_cache;
  400. return 0;
  401. destroy_nametoid_cache:
  402. cache_destroy_net(nn->nametoid_cache, net);
  403. unregister_idtoname_cache:
  404. cache_unregister_net(nn->idtoname_cache, net);
  405. destroy_idtoname_cache:
  406. cache_destroy_net(nn->idtoname_cache, net);
  407. return rv;
  408. }
  409. void
  410. nfsd_idmap_shutdown(struct net *net)
  411. {
  412. struct nfsd_net *nn = net_generic(net, nfsd_net_id);
  413. cache_unregister_net(nn->idtoname_cache, net);
  414. cache_unregister_net(nn->nametoid_cache, net);
  415. cache_destroy_net(nn->idtoname_cache, net);
  416. cache_destroy_net(nn->nametoid_cache, net);
  417. }
  418. static int
  419. idmap_lookup(struct svc_rqst *rqstp,
  420. struct ent *(*lookup_fn)(struct cache_detail *, struct ent *),
  421. struct ent *key, struct cache_detail *detail, struct ent **item)
  422. {
  423. int ret;
  424. *item = lookup_fn(detail, key);
  425. if (!*item)
  426. return -ENOMEM;
  427. retry:
  428. ret = cache_check(detail, &(*item)->h, &rqstp->rq_chandle);
  429. if (ret == -ETIMEDOUT) {
  430. struct ent *prev_item = *item;
  431. *item = lookup_fn(detail, key);
  432. if (*item != prev_item)
  433. goto retry;
  434. cache_put(&(*item)->h, detail);
  435. }
  436. return ret;
  437. }
  438. static char *
  439. rqst_authname(struct svc_rqst *rqstp)
  440. {
  441. struct auth_domain *clp;
  442. clp = rqstp->rq_gssclient ? rqstp->rq_gssclient : rqstp->rq_client;
  443. return clp->name;
  444. }
  445. static __be32
  446. idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen,
  447. u32 *id)
  448. {
  449. struct ent *item, key = {
  450. .type = type,
  451. };
  452. int ret;
  453. struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
  454. if (namelen + 1 > sizeof(key.name))
  455. return nfserr_badowner;
  456. memcpy(key.name, name, namelen);
  457. key.name[namelen] = '\0';
  458. strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
  459. ret = idmap_lookup(rqstp, nametoid_lookup, &key, nn->nametoid_cache, &item);
  460. if (ret == -ENOENT)
  461. return nfserr_badowner;
  462. if (ret)
  463. return nfserrno(ret);
  464. *id = item->id;
  465. cache_put(&item->h, nn->nametoid_cache);
  466. return 0;
  467. }
  468. static int
  469. idmap_id_to_name(struct svc_rqst *rqstp, int type, u32 id, char *name)
  470. {
  471. struct ent *item, key = {
  472. .id = id,
  473. .type = type,
  474. };
  475. int ret;
  476. struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
  477. strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
  478. ret = idmap_lookup(rqstp, idtoname_lookup, &key, nn->idtoname_cache, &item);
  479. if (ret == -ENOENT)
  480. return sprintf(name, "%u", id);
  481. if (ret)
  482. return ret;
  483. ret = strlen(item->name);
  484. BUG_ON(ret > IDMAP_NAMESZ);
  485. memcpy(name, item->name, ret);
  486. cache_put(&item->h, nn->idtoname_cache);
  487. return ret;
  488. }
  489. static bool
  490. numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u32 *id)
  491. {
  492. int ret;
  493. char buf[11];
  494. if (namelen + 1 > sizeof(buf))
  495. /* too long to represent a 32-bit id: */
  496. return false;
  497. /* Just to make sure it's null-terminated: */
  498. memcpy(buf, name, namelen);
  499. buf[namelen] = '\0';
  500. ret = kstrtouint(buf, 10, id);
  501. return ret == 0;
  502. }
  503. static __be32
  504. do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u32 *id)
  505. {
  506. if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
  507. if (numeric_name_to_id(rqstp, type, name, namelen, id))
  508. return 0;
  509. /*
  510. * otherwise, fall through and try idmapping, for
  511. * backwards compatibility with clients sending names:
  512. */
  513. return idmap_name_to_id(rqstp, type, name, namelen, id);
  514. }
  515. static int
  516. do_id_to_name(struct svc_rqst *rqstp, int type, u32 id, char *name)
  517. {
  518. if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
  519. return sprintf(name, "%u", id);
  520. return idmap_id_to_name(rqstp, type, id, name);
  521. }
  522. __be32
  523. nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen,
  524. kuid_t *uid)
  525. {
  526. __be32 status;
  527. u32 id = -1;
  528. status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id);
  529. *uid = make_kuid(&init_user_ns, id);
  530. if (!uid_valid(*uid))
  531. status = nfserr_badowner;
  532. return status;
  533. }
  534. __be32
  535. nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen,
  536. kgid_t *gid)
  537. {
  538. __be32 status;
  539. u32 id = -1;
  540. status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id);
  541. *gid = make_kgid(&init_user_ns, id);
  542. if (!gid_valid(*gid))
  543. status = nfserr_badowner;
  544. return status;
  545. }
  546. int
  547. nfsd_map_uid_to_name(struct svc_rqst *rqstp, kuid_t uid, char *name)
  548. {
  549. u32 id = from_kuid(&init_user_ns, uid);
  550. return do_id_to_name(rqstp, IDMAP_TYPE_USER, id, name);
  551. }
  552. int
  553. nfsd_map_gid_to_name(struct svc_rqst *rqstp, kgid_t gid, char *name)
  554. {
  555. u32 id = from_kgid(&init_user_ns, gid);
  556. return do_id_to_name(rqstp, IDMAP_TYPE_GROUP, id, name);
  557. }