* [PATCH] media: pci: ttpci: av7110: avoid compiler optimization of reading data[0] in debiirq()
@ 2020-08-30 8:20 Jia-Ju Bai
2020-08-30 8:30 ` Sean Young
0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2020-08-30 8:20 UTC (permalink / raw)
To: mchehab, sean, pavel; +Cc: linux-media, linux-kernel, Jia-Ju Bai
In debiirq(), data_0 stores the value of data[0], but it can be dropped
by compiler optimization. Thus, data[0] is read through READ_ONCE().
Fixes: 6499a0db9b0f ("media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq()")
Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jia-Ju Bai <baijiaju@tsinghua.edu.cn>
---
drivers/media/pci/ttpci/av7110.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index bf36b1e22b63..f7d098d5b198 100644
--- a/drivers/media/pci/ttpci/av7110.c
+++ b/drivers/media/pci/ttpci/av7110.c
@@ -406,7 +406,7 @@ static void debiirq(unsigned long cookie)
case DATA_CI_GET:
{
u8 *data = av7110->debi_virt;
- u8 data_0 = data[0];
+ u8 data_0 = READ_ONCE(data[0]);
if (data_0 < 2 && data[2] == 0xff) {
int flags = 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: pci: ttpci: av7110: avoid compiler optimization of reading data[0] in debiirq()
2020-08-30 8:20 [PATCH] media: pci: ttpci: av7110: avoid compiler optimization of reading data[0] in debiirq() Jia-Ju Bai
@ 2020-08-30 8:30 ` Sean Young
2020-09-09 8:55 ` Pavel Machek
0 siblings, 1 reply; 3+ messages in thread
From: Sean Young @ 2020-08-30 8:30 UTC (permalink / raw)
To: Jia-Ju Bai; +Cc: mchehab, pavel, linux-media, linux-kernel
On Sun, Aug 30, 2020 at 04:20:42PM +0800, Jia-Ju Bai wrote:
> In debiirq(), data_0 stores the value of data[0], but it can be dropped
> by compiler optimization. Thus, data[0] is read through READ_ONCE().
>
> Fixes: 6499a0db9b0f ("media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq()")
> Reported-by: Pavel Machek <pavel@ucw.cz>
Pavel reported that your patch was garbage, if you are trying to defend
against a malicious pci device. READ_ONCE() will not help here.
Sean
> Signed-off-by: Jia-Ju Bai <baijiaju@tsinghua.edu.cn>
> ---
> drivers/media/pci/ttpci/av7110.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
> index bf36b1e22b63..f7d098d5b198 100644
> --- a/drivers/media/pci/ttpci/av7110.c
> +++ b/drivers/media/pci/ttpci/av7110.c
> @@ -406,7 +406,7 @@ static void debiirq(unsigned long cookie)
> case DATA_CI_GET:
> {
> u8 *data = av7110->debi_virt;
> - u8 data_0 = data[0];
> + u8 data_0 = READ_ONCE(data[0]);
>
> if (data_0 < 2 && data[2] == 0xff) {
> int flags = 0;
> --
> 2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: pci: ttpci: av7110: avoid compiler optimization of reading data[0] in debiirq()
2020-08-30 8:30 ` Sean Young
@ 2020-09-09 8:55 ` Pavel Machek
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2020-09-09 8:55 UTC (permalink / raw)
To: Sean Young; +Cc: Jia-Ju Bai, mchehab, linux-media, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 908 bytes --]
On Sun 2020-08-30 09:30:36, Sean Young wrote:
> On Sun, Aug 30, 2020 at 04:20:42PM +0800, Jia-Ju Bai wrote:
> > In debiirq(), data_0 stores the value of data[0], but it can be dropped
> > by compiler optimization. Thus, data[0] is read through READ_ONCE().
> >
> > Fixes: 6499a0db9b0f ("media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq()")
> > Reported-by: Pavel Machek <pavel@ucw.cz>
>
> Pavel reported that your patch was garbage, if you are trying to defend
> against a malicious pci device. READ_ONCE() will not help here.
I would not use exactly those words, but agreed; we should have some
explanation that it is feasible to protect against malicious av7110
device, first.
Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-09 8:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 8:20 [PATCH] media: pci: ttpci: av7110: avoid compiler optimization of reading data[0] in debiirq() Jia-Ju Bai
2020-08-30 8:30 ` Sean Young
2020-09-09 8:55 ` Pavel Machek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.