Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa4bf44d authored by Christian Brauner's avatar Christian Brauner Committed by Eric W. Biederman
Browse files

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: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
parent e19b205b
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -12,13 +12,21 @@

#define UID_GID_MAP_MAX_EXTENTS 5

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];
};

struct uid_gid_map {	/* 64 bytes -- 1 cache line */
	u32 nr_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
+18 −12
Original line number Diff line number Diff line
@@ -26,28 +26,34 @@
struct user_namespace init_user_ns = {
	.uid_map = {
		.nr_extents = 1,
		{
			.extent[0] = {
				.first = 0,
				.lower_first = 0,
				.count = 4294967295U,
			},
		},
	},
	.gid_map = {
		.nr_extents = 1,
		{
			.extent[0] = {
				.first = 0,
				.lower_first = 0,
				.count = 4294967295U,
			},
		},
	},
	.projid_map = {
		.nr_extents = 1,
		{
			.extent[0] = {
				.first = 0,
				.lower_first = 0,
				.count = 4294967295U,
			},
		},
	},
	.count = ATOMIC_INIT(3),
	.owner = GLOBAL_ROOT_UID,
	.group = GLOBAL_ROOT_GID,