From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>,
Bryan O'Donoghue <bod@kernel.org>,
Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Stefan Schmidt <stefan.schmidt@linaro.org>,
Hans Verkuil <hverkuil@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Hungyu Lin <dennylin0707@gmail.com>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 3/3] media: iris: Fix use-after-free on unbind with open sessions
Date: Mon, 9 Nov 2026 11:22:19 +0000 [thread overview]
Message-ID: <7a2e44a7-41af-461a-96c6-ea91780bf524@linaro.org> (raw)
In-Reply-To: <831090d5-57c6-46dd-559a-bd6abebb982c@oss.qualcomm.com>
On 09/11/2026 05:08, Vishnu Reddy wrote:
>>> +static void iris_core_release(struct v4l2_device *v4l2_dev)
>>> +{
>>> + struct iris_core *core = container_of(v4l2_dev, struct iris_core,
>>> v4l2_dev);
>>> +
>>> + mutex_destroy(&core->lock);
>>> + put_device(core->dev);
>>> + kfree(core);
>>> +}
>>> +
>> What you would have here is an admixture of devm allocated stuff and
>> hand-allocated, refcounted with custom v4l2_release() which might all work
>> but, it's not obvious to me does work i.e. core is hand allocated while
>> reg_base, response_packet etc are devm() managed.
> reg_base and response_packet are safe: after iris_remove() the IRQ is
> freed and the core is in IRIS_CORE_DEINIT, so nothing uses them. Only
> the core structure must outlive remove(), so only that is refcounted.
Right and you can confidently assert that for clocks, regulators, power
domains and ICC ?
TBH I think this is pretty hacky and unlikely to be safe.
Another way I don't think this approach works is an ioctl() waiting on
firmware do do whatever. If the ioctl wakes up after the devres()
removal - then what ?
>> A much simpler solution to your problem is :
>>
>> static struct platform_driver iris_driver = {
>> .driver = {
>> .suppress_bind_attrs = true,
>> ...
>> },
>> };
>>
> This was discussed in [1]. Dmitry noted it is a sign of a badly written driver,
> and I agree: it removes the unbind interface to avoid the problem instead of
> fixing remove().
>
> [1]
> https://lore.kernel.org/all/
> CAO9ioeUvV+3sME9P1bJTpDOSty=uojOKak659XCf337++vPVNg@mail.gmail.com
In which case I think you need to do more poving/reasoning here about
admixture of devm and hand-rolled allocations.
Like what's the use-case you are supporting here with the unbind exactly ?
---
bod
next prev parent reply other threads:[~2026-11-09 11:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 3:16 [PATCH 0/3] media: iris: Fix issues in the driver unbind path Vishnu Reddy
2026-10-17 3:16 ` [PATCH 1/3] media: iris: Fix runtime PM reference imbalance on failed resume Vishnu Reddy
2026-11-02 13:32 ` Vikash Garodia
2026-10-17 3:16 ` [PATCH 2/3] media: iris: Disable the system error work on removal Vishnu Reddy
2026-11-02 13:33 ` Vikash Garodia
2026-10-17 3:16 ` [PATCH 3/3] media: iris: Fix use-after-free on unbind with open sessions Vishnu Reddy
2026-11-03 11:40 ` Bryan O'Donoghue
2026-11-09 5:08 ` Vishnu Reddy
2026-11-09 11:22 ` Bryan O'Donoghue [this message]
2026-11-10 3:09 ` Vishnu Reddy
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=7a2e44a7-41af-461a-96c6-ea91780bf524@linaro.org \
--to=bryan.odonoghue@linaro.org \
--cc=abhinav.kumar@linux.dev \
--cc=bod@kernel.org \
--cc=busanna.reddy@oss.qualcomm.com \
--cc=dennylin0707@gmail.com \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=hverkuil@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefan.schmidt@linaro.org \
--cc=vikash.garodia@oss.qualcomm.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®