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

From: Muchun Song
Date: Thu Aug 27 2020 - 22:34:22 EST


On Fri, Aug 28, 2020 at 5:51 AM Mike Kravetz <mike.kravetz@xxxxxxxxxx> wrote:
>
> 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.

OK, I will do that. Thanks.

>
> 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.

Yeah, I agree with you. I will remove the unnecessary assignment of
table->maxlen.

>
> --
> Mike Kravetz



--
Yours,
Muchun