[CRIU] [RFT PATCH] compel/aarch64: fix off-by-one in compel_task_size

Dmitry Safonov 0x7f454c46 at gmail.com
Mon Aug 28 15:10:00 MSK 2017


Hi Mike,

2017-08-24 14:35 GMT+03:00 Mike Rapoport <rppt at linux.vnet.ibm.com>:
> Currently we are checking task sizes that are *less* than TASK_SIZE_MAX and
> we never check with task_size == TASK_SIZE_MAX. Fix it.
>
> Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
> ---
>
> I don't have an aarch64 platform handy and I'll appreciate if someone can
> verify that this patch actually works...

Well, AFAICS the same logic works for arm32, so you need to
patch it also (or edit commit message explaining why it's good
for arm32).

>
>
>  compel/arch/aarch64/src/lib/infect.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/compel/arch/aarch64/src/lib/infect.c b/compel/arch/aarch64/src/lib/infect.c
> index 166ec23..25c60c6 100644
> --- a/compel/arch/aarch64/src/lib/infect.c
> +++ b/compel/arch/aarch64/src/lib/infect.c
> @@ -165,9 +165,8 @@ unsigned long compel_task_size(void)
>  {
>         unsigned long task_size;
>
> -       for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size <<= 1)
> +       for (task_size = TASK_SIZE_MIN; task_size <= TASK_SIZE_MAX; task_size <<= 1)
>                 if (munmap((void *)task_size, page_size()))
>                         break;
>         return task_size;

I'm not sure the change is valid:
address is in kernel space if (>= TASK_SIZE), so trying to
munmap(TASK_SIZE_MAX) will
*always* fail.
So we already test if task has 48-bit VA (TASK_SIZE) by unmapping
(TASK_SIZE_MAX >> 1)
on a previous cycle. If it succeed the task_size will be == TASK_SIZE_MAX.
Maybe it's worth a comment here ;-)

>  }
> -
> --
> 2.7.4
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu



-- 
             Dmitry


More information about the CRIU mailing list