media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in...
authorJia-Ju Bai <baijiaju@tsinghua.edu.cn>
Sat, 30 May 2020 14:42:08 +0000 (16:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Sep 2020 09:22:24 +0000 (11:22 +0200)
commit5c043e7826d838ce833cab47c8b2e95ac92dc36a
treedff3d1b55962ce5da12daa3fe63f396ea0ffc9d1
parent3e5b6ab3a4c1859b32bdedf63a446cb18d1c9015
media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq()

[ Upstream commit 6499a0db9b0f1e903d52f8244eacc1d4be00eea2 ]

The value av7110->debi_virt is stored in DMA memory, and it is assigned
to data, and thus data[0] can be modified at any time by malicious
hardware. In this case, "if (data[0] < 2)" can be passed, but then
data[0] can be changed into a large number, which may cause buffer
overflow when the code "av7110->ci_slot[data[0]]" is used.

To fix this possible bug, data[0] is assigned to a local variable, which
replaces the use of data[0].

Signed-off-by: Jia-Ju Bai <baijiaju@tsinghua.edu.cn>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/pci/ttpci/av7110.c