[CRIU] [PATCH 3/4] Bug-fix in size calculation
Pavel Emelyanov
xemul at parallels.com
Wed Aug 13 02:05:47 PDT 2014
On 08/09/2014 09:22 AM, Sophie Blee-Goldman wrote:
> Fixes a bug in how PARASITE_MAX_GROUPS was calculated, and adds a
> compiler check to assert that parasite_dump_creds doesn't exceed
> the page size.
>
> Signed-off-by: Sophie Blee-Goldman <ableegoldman at google.com>
Good catch, Sophie :) Patch applied, thanks.
>
> diff --git a/include/parasite.h b/include/parasite.h
> index eaabc01..af81d85 100644
> --- a/include/parasite.h
> +++ b/include/parasite.h
> @@ -162,7 +162,12 @@ struct parasite_dump_misc {
> int dumpable;
> };
>
> -#define PARASITE_MAX_GROUPS (PAGE_SIZE / sizeof(unsigned int) - 2 * sizeof(unsigned))
> +/*
> + * Calculate how long we can make the groups array in parasite_dump_creds
> + * and still fit the struct in one page
> + */
> +#define PARASITE_MAX_GROUPS \
> + ((PAGE_SIZE - 2 * sizeof(unsigned int)) / sizeof(unsigned int))
>
> struct parasite_dump_creds {
> unsigned int secbits;
> diff --git a/parasite-syscall.c b/parasite-syscall.c
> index f26503a..dad2570 100644
> --- a/parasite-syscall.c
> +++ b/parasite-syscall.c
> @@ -735,6 +735,8 @@ int parasite_dump_creds(struct parasite_ctl *ctl, CredsEntry *ce)
> {
> struct parasite_dump_creds *pc;
>
> + BUILD_BUG_ON(sizeof(*pc) > PAGE_SIZE);
> +
> pc = parasite_args(ctl, struct parasite_dump_creds);
> if (parasite_execute_daemon(PARASITE_CMD_DUMP_CREDS, ctl) < 0)
> return -1;
>
More information about the CRIU
mailing list