[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c18180b5-52b9-e787-654c-6967ecb81dce@gmail.com>
Date: Fri, 16 Apr 2021 16:33:59 -0300
From: Igor Torrente <igormtorrente@...il.com>
To: Shuah Khan <skhan@...uxfoundation.org>, mchehab@...nel.org
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
kernel test robot <lkp@...el.com>,
syzbot+b2391895514ed9ef4a8e@...kaller.appspotmail.com
Subject: Re: [PATCH RFC v3] media: em28xx: Fix race condition between open and
init function
On 4/15/21 2:25 PM, Shuah Khan wrote:
> On 4/15/21 8:07 AM, Igor Matheus Andrade Torrente wrote:
>> Fixes a race condition - for lack of a more precise term - between
>> em28xx_v4l2_open and em28xx_v4l2_init, by detaching the v4l2_dev,
>> media_pad and vdev structs from the em28xx_v4l2, and managing the
>> lifetime of those objects more dynamicaly.
>>
>> The race happens when a thread[1] - containing the em28xx_v4l2_init()
>> code - calls the v4l2_mc_create_media_graph(), and it return a error,
>> if a thread[2] - running v4l2_open() - pass the verification point
>> and reaches the em28xx_v4l2_open() before the thread[1] finishes
>> the deregistration of v4l2 subsystem, the thread[1] will free all
>> resources before the em28xx_v4l2_open() can process their things,
>> because the em28xx_v4l2_init() has the dev->lock. And all this lead
>> the thread[2] to cause a user-after-free.
>>
>> Reported-by: kernel test robot <lkp@...el.com>
>> Reported-and-tested-by:
>> syzbot+b2391895514ed9ef4a8e@...kaller.appspotmail.com
>> Signed-off-by: Igor Matheus Andrade Torrente <igormtorrente@...il.com>
>> ---
>>
>> V2: Add v4l2_i2c_new_subdev null check
>> Deal with v4l2 subdevs dependencies
>>
>> V3: Fix link error when compiled as a module
>>
>> ---
>> drivers/media/usb/em28xx/em28xx-camera.c | 4 +-
>> drivers/media/usb/em28xx/em28xx-video.c | 300 +++++++++++++++--------
>> drivers/media/usb/em28xx/em28xx.h | 6 +-
>> 3 files changed, 209 insertions(+), 101 deletions(-)
>>
>
> The changes looks good to me. Have you tried building as a modules and
> running modprobes and rmmods? You can do that without a device.
>
I tried and everything worked fine.
> thanks,
> -- Shuah
>
Thanks,
---
Igor Matheus Andrade Torrente
Powered by blists - more mailing lists