Re: [PATCH] umh: fix UAF when the process is being killed

From: Schspa Shi
Date: Tue Dec 13 2022 - 22:17:17 EST



Luis Chamberlain <mcgrof@xxxxxxxxxx> writes:

> On Mon, Dec 12, 2022 at 09:38:31PM +0800, Schspa Shi wrote:
>> I'd like to upload a V2 patch with the new solution if you prefer the
>> following way.
>>
>> diff --git a/kernel/umh.c b/kernel/umh.c
>> index 850631518665..8023f11fcfc0 100644
>> --- a/kernel/umh.c
>> +++ b/kernel/umh.c
>> @@ -452,6 +452,11 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
>> /* umh_complete() will see NULL and free sub_info */
>> if (xchg(&sub_info->complete, NULL))
>> goto unlock;
>> + /*
>> + * kthreadd (or new kernel thread) will call complete()
>> + * shortly.
>> + */
>> + wait_for_completion(&done);
>> }
>
> Yes much better. Did you verify it fixes the splat found by the bots?
>

Yes, it will fix it.

> Luis


--
BRs
Schspa Shi