]> git.itanic.dy.fi Git - linux-stable/commit
media: wl128x: prevent two potential buffer overflows
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 26 Mar 2019 05:12:07 +0000 (01:12 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Jun 2019 10:24:04 +0000 (12:24 +0200)
commit348ec7b9a1c1c6f93911cf7b164ec870ee4c027a
tree124fade101f2053e9bbe5b7a382df9bf4c5b9e7a
parent557ae685914b5bfdedc61c3d41b188f0f47d3353
media: wl128x: prevent two potential buffer overflows

[ Upstream commit 9c2ccc324b3a6cbc865ab8b3e1a09e93d3c8ade9 ]

Smatch marks skb->data as untrusted so it warns that "evt_hdr->dlen"
can copy up to 255 bytes and we only have room for two bytes.  Even
if this comes from the firmware and we trust it, the new policy
generally is just to fix it as kernel hardenning.

I can't test this code so I tried to be very conservative.  I considered
not allowing "evt_hdr->dlen == 1" because it doesn't initialize the
whole variable but in the end I decided to allow it and manually
initialized "asic_id" and "asic_ver" to zero.

Fixes: e8454ff7b9a4 ("[media] drivers:media:radio: wl128x: FM Driver Common sources")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/radio/wl128x/fmdrv_common.c