aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Brauner <christian.brauner@ubuntu.com>2017-10-24 18:04:40 -0400
committerEric W. Biederman <ebiederm@xmission.com>2017-10-31 18:22:58 -0400
commitaa4bf44dc851c6bdd4f7b61b5f2c56c84dfe2ff0 (patch)
treeca3bdc2e66ad9585112fa7a08fd8ce9304f509b8
parente19b205be43d11bff638cad4487008c48d21c103 (diff)
userns: use union in {g,u}idmap struct
- 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>
-rw-r--r--include/linux/user_namespace.h18
-rw-r--r--kernel/user.c30
2 files changed, 31 insertions, 17 deletions
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index c18e01252346..7c83d7f6289b 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -12,13 +12,21 @@
12 12
13#define UID_GID_MAP_MAX_EXTENTS 5 13#define UID_GID_MAP_MAX_EXTENTS 5
14 14
15struct uid_gid_extent {
16 u32 first;
17 u32 lower_first;
18 u32 count;
19};
20
15struct uid_gid_map { /* 64 bytes -- 1 cache line */ 21struct uid_gid_map { /* 64 bytes -- 1 cache line */
16 u32 nr_extents; 22 u32 nr_extents;
17 struct uid_gid_extent { 23 union {
18 u32 first; 24 struct uid_gid_extent extent[UID_GID_MAP_MAX_EXTENTS];
19 u32 lower_first; 25 struct {
20 u32 count; 26 struct uid_gid_extent *forward;
21 } extent[UID_GID_MAP_MAX_EXTENTS]; 27 struct uid_gid_extent *reverse;
28 };
29 };
22}; 30};
23 31
24#define USERNS_SETGROUPS_ALLOWED 1UL 32#define USERNS_SETGROUPS_ALLOWED 1UL
diff --git a/kernel/user.c b/kernel/user.c
index 00281add65b2..9a20acce460d 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -26,26 +26,32 @@
26struct user_namespace init_user_ns = { 26struct user_namespace init_user_ns = {
27 .uid_map = { 27 .uid_map = {
28 .nr_extents = 1, 28 .nr_extents = 1,
29 .extent[0] = { 29 {
30 .first = 0, 30 .extent[0] = {
31 .lower_first = 0, 31 .first = 0,
32 .count = 4294967295U, 32 .lower_first = 0,
33 .count = 4294967295U,
34 },
33 }, 35 },
34 }, 36 },
35 .gid_map = { 37 .gid_map = {
36 .nr_extents = 1, 38 .nr_extents = 1,
37 .extent[0] = { 39 {
38 .first = 0, 40 .extent[0] = {
39 .lower_first = 0, 41 .first = 0,
40 .count = 4294967295U, 42 .lower_first = 0,
43 .count = 4294967295U,
44 },
41 }, 45 },
42 }, 46 },
43 .projid_map = { 47 .projid_map = {
44 .nr_extents = 1, 48 .nr_extents = 1,
45 .extent[0] = { 49 {
46 .first = 0, 50 .extent[0] = {
47 .lower_first = 0, 51 .first = 0,
48 .count = 4294967295U, 52 .lower_first = 0,
53 .count = 4294967295U,
54 },
49 }, 55 },
50 }, 56 },
51 .count = ATOMIC_INIT(3), 57 .count = ATOMIC_INIT(3),