userns: use union in {g,u}idmap struct
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 24 Oct 2017 22:04:40 +0000 (00:04 +0200)
committerEric W. Biederman <ebiederm@xmission.com>
Tue, 31 Oct 2017 22:22:58 +0000 (17:22 -0500)
- Add a struct containing two pointer to extents and wrap both the static extent
  array and the struct into a union. This is done in preparation for bumping the
  {g,u}idmap limits for user namespaces.
- Add brackets around anonymous union when using designated initializers to
  initialize members in order to please gcc <= 4.4.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
include/linux/user_namespace.h
kernel/user.c

index c18e0125234628f4ad6810eb8f6a19cf356a7f46..7c83d7f6289b735c4018776e4a0dcdad14d5a4cf 100644 (file)
 
 #define UID_GID_MAP_MAX_EXTENTS 5
 
+struct uid_gid_extent {
+       u32 first;
+       u32 lower_first;
+       u32 count;
+};
+
 struct uid_gid_map {   /* 64 bytes -- 1 cache line */
        u32 nr_extents;
-       struct uid_gid_extent {
-               u32 first;
-               u32 lower_first;
-               u32 count;
-       } extent[UID_GID_MAP_MAX_EXTENTS];
+       union {
+               struct uid_gid_extent extent[UID_GID_MAP_MAX_EXTENTS];
+               struct {
+                       struct uid_gid_extent *forward;
+                       struct uid_gid_extent *reverse;
+               };
+       };
 };
 
 #define USERNS_SETGROUPS_ALLOWED 1UL
index 00281add65b251d484616264dbba8df8b0ae066d..9a20acce460d53cf23f7057c7dc122b685ae639d 100644 (file)
 struct user_namespace init_user_ns = {
        .uid_map = {
                .nr_extents = 1,
-               .extent[0] = {
-                       .first = 0,
-                       .lower_first = 0,
-                       .count = 4294967295U,
+               {
+                       .extent[0] = {
+                               .first = 0,
+                               .lower_first = 0,
+                               .count = 4294967295U,
+                       },
                },
        },
        .gid_map = {
                .nr_extents = 1,
-               .extent[0] = {
-                       .first = 0,
-                       .lower_first = 0,
-                       .count = 4294967295U,
+               {
+                       .extent[0] = {
+                               .first = 0,
+                               .lower_first = 0,
+                               .count = 4294967295U,
+                       },
                },
        },
        .projid_map = {
                .nr_extents = 1,
-               .extent[0] = {
-                       .first = 0,
-                       .lower_first = 0,
-                       .count = 4294967295U,
+               {
+                       .extent[0] = {
+                               .first = 0,
+                               .lower_first = 0,
+                               .count = 4294967295U,
+                       },
                },
        },
        .count = ATOMIC_INIT(3),