aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/user_namespace.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 4f7e357ac1e2..1d0298870ee3 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -313,45 +313,9 @@ static u32 map_id_range_down(struct uid_gid_map *map, u32 id, u32 count)
313 return id; 313 return id;
314} 314}
315 315
316/**
317 * map_id_down_base - Find idmap via binary search in static extent array.
318 * Can only be called if number of mappings is equal or less than
319 * UID_GID_MAP_MAX_BASE_EXTENTS.
320 */
321static struct uid_gid_extent *
322map_id_down_base(unsigned extents, struct uid_gid_map *map, u32 id)
323{
324 unsigned idx;
325 u32 first, last;
326
327 /* Find the matching extent */
328 for (idx = 0; idx < extents; idx++) {
329 first = map->extent[idx].first;
330 last = first + map->extent[idx].count - 1;
331 if (id >= first && id <= last)
332 return &map->extent[idx];
333 }
334 return NULL;
335}
336
337static u32 map_id_down(struct uid_gid_map *map, u32 id) 316static u32 map_id_down(struct uid_gid_map *map, u32 id)
338{ 317{
339 struct uid_gid_extent *extent; 318 return map_id_range_down(map, id, 1);
340 unsigned extents = map->nr_extents;
341 smp_rmb();
342
343 if (extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
344 extent = map_id_down_base(extents, map, id);
345 else
346 extent = map_id_range_down_max(extents, map, id, 1);
347
348 /* Map the id or note failure */
349 if (extent)
350 id = (id - extent->first) + extent->lower_first;
351 else
352 id = (u32) -1;
353
354 return id;
355} 319}
356 320
357/** 321/**