mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Christian Brauner <christian.brauner@ubuntu.com>,
	ebiederm@xmission.com, linux-kernel@vger.kernel.org
Cc: serge@hallyn.com, stgraber@ubuntu.com, tycho@tycho.ws
Subject: Re: [PATCH 1/2 v4] user namespace: use union in {g,u}idmap struct
Date: Mon, 23 Oct 2017 09:39:25 +0300	[thread overview]
Message-ID: <bddd4c91-ceba-125e-ec0d-fbee82ed9ef9@suse.com> (raw)
In-Reply-To: <20171019191136.21840-1-christian.brauner@ubuntu.com>



On 19.10.2017 22:11, Christian Brauner wrote:
> - 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>
> ---
> Changelog 2017-10-19:
> * kernel/user.c: Use brackets around anonymous union when using designated
>   initializers to initialize members. This is done to please gcc <= 4.4.
> ---
>  include/linux/user_namespace.h | 18 +++++++++++++-----
>  kernel/user.c                  | 30 ++++++++++++++++++------------
>  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 @@
>  
>  #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
> 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 @@
>  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,

nit: ULONG_MAX ?

> +			},
>  		},
>  	},
>  	.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),
> 

  parent reply	other threads:[~2017-10-23  6:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 19:11 Christian Brauner
2017-10-19 19:11 ` [PATCH 2/2 v4] user namespaces: bump idmap limits to 340 Christian Brauner
2017-10-22 18:18   ` Christian Brauner
2017-10-23  6:39 ` Nikolay Borisov [this message]
2017-10-23  6:45   ` [PATCH 1/2 v4] user namespace: use union in {g,u}idmap struct Nikolay Borisov
2017-10-23 12:31     ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bddd4c91-ceba-125e-ec0d-fbee82ed9ef9@suse.com \
    --to=nborisov@suse.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=stgraber@ubuntu.com \
    --cc=tycho@tycho.ws \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®