From: Shuah Khan <skhan@linuxfoundation.org>
To: Igor Torrente <igormtorrente@gmail.com>, mchehab@kernel.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
kernel test robot <lkp@intel.com>,
syzbot+b2391895514ed9ef4a8e@syzkaller.appspotmail.com,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH RFC v3] media: em28xx: Fix race condition between open and init function
Date: Fri, 16 Apr 2021 17:03:05 -0600 [thread overview]
Message-ID: <49c44747-1f25-11a1-1132-abfe406955b2@linuxfoundation.org> (raw)
In-Reply-To: <c18180b5-52b9-e787-654c-6967ecb81dce@gmail.com>
On 4/16/21 1:33 PM, Igor Torrente wrote:
>
>
> 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@intel.com>
>>> Reported-and-tested-by:
>>> syzbot+b2391895514ed9ef4a8e@syzkaller.appspotmail.com
>>> Signed-off-by: Igor Matheus Andrade Torrente <igormtorrente@gmail.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.
>
Thank you.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
prev parent reply other threads:[~2021-04-16 23:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-15 14:07 Igor Matheus Andrade Torrente
2021-04-15 17:25 ` Shuah Khan
2021-04-16 19:33 ` Igor Torrente
2021-04-16 23:03 ` Shuah Khan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49c44747-1f25-11a1-1132-abfe406955b2@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=igormtorrente@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mchehab@kernel.org \
--cc=syzbot+b2391895514ed9ef4a8e@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®