diff options
| author | Takashi Iwai <tiwai@suse.de> | 2016-11-17 10:49:31 +0100 |
|---|---|---|
| committer | Sasha Levin <alexander.levin@verizon.com> | 2017-06-13 09:29:21 -0400 |
| commit | afeb39160249eed5b585b4e9c8227351725b29fd (patch) | |
| tree | 165dec3333075d55a726beb5d89783b11f372287 /kernel/debug/Makefile | |
| parent | 5eef36af59740aa26f9a39ff8124134ec3e0c4ef (diff) | |
xc2028: Fix use-after-free bug properly
[ Upstream commit 22a1e7783e173ab3d86018eb590107d68df46c11 ]
The commit 8dfbcc4351a0 ("[media] xc2028: avoid use after free") tried
to address the reported use-after-free by clearing the reference.
However, it's clearing the wrong pointer; it sets NULL to
priv->ctrl.fname, but it's anyway overwritten by the next line
memcpy(&priv->ctrl, p, sizeof(priv->ctrl)).
OTOH, the actual code accessing the freed string is the strcmp() call
with priv->fname:
if (!firmware_name[0] && p->fname &&
priv->fname && strcmp(p->fname, priv->fname))
free_firmware(priv);
where priv->fname points to the previous file name, and this was
already freed by kfree().
For fixing the bug properly, this patch does the following:
- Keep the copy of firmware file name in only priv->fname,
priv->ctrl.fname isn't changed;
- The allocation is done only when the firmware gets loaded;
- The kfree() is called in free_firmware() commonly
Fixes: commit 8dfbcc4351a0 ('[media] xc2028: avoid use after free')
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'kernel/debug/Makefile')
0 files changed, 0 insertions, 0 deletions
