Re: [External] Re: [PATCH] mm/hugetlb: Fix a race between hugetlb sysctl handlers

From: Mike Kravetz
Date: Thu Aug 27 2020 - 17:51:11 EST


On 8/25/20 7:47 PM, Muchun Song wrote:
>
> CPU0: CPU1:
> proc_sys_write
> hugetlb_sysctl_handler proc_sys_call_handler
> hugetlb_sysctl_handler_common hugetlb_sysctl_handler
> table->data = &tmp; hugetlb_sysctl_handler_common
> table->data = &tmp;
> proc_doulongvec_minmax
> do_proc_doulongvec_minmax sysctl_head_finish
> __do_proc_doulongvec_minmax
> i = table->data;
> *i = val; // corrupt CPU1 stack

Thanks Muchun!
Can you please add this to the commit message.

Also, when looking closer at the patch I do not think setting table->maxlen
is necessary in these routines. maxlen is set when the hugetlb ctl_table
entries are defined and initialized. This is not something you introduced.
The unnecessary assignments are in the existing code. However, there is no
need to carry them forward.

--
Mike Kravetz