Commit 7a6521d2 authored by Hyunwoo Kim's avatar Hyunwoo Kim Committed by liwei
Browse files

media: dvb-core: Fix use-after-free due to race at dvb_register_device()

mainline inclusion
from mainline-v6.4-rc4
commit 627bb528
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I635IG
CVE: CVE-2022-45884

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=627bb528b086b4136315c25d6a447a98ea9448d3

--------------------------------

dvb_register_device() dynamically allocates fops with kmemdup()
to set the fops->owner.
And these fops are registered in 'file->f_ops' using replace_fops()
in the dvb_device_open() process, and kfree()d in dvb_free_device().

However, it is not common to use dynamically allocated fops instead
of 'static const' fops as an argument of replace_fops(),
and UAF may occur.
These UAFs can occur on any dvb type using dvb_register_device(),
such as dvb_dvr, dvb_demux, dvb_frontend, dvb_net, etc.

So, instead of kfree() the fops dynamically allocated in
dvb_register_device() in dvb_free_device() called during the
.disconnect() process, kfree() it collectively in exit_dvbdev()
called when the dvbdev.c module is removed.

Link: https://lore.kernel.org/linux-media/20221117045925.14297-4-imv4bel@gmail.com


Signed-off-by: default avatarHyunwoo Kim <imv4bel@gmail.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>

Conflicts:
	drivers/media/dvb-core/dvbdev.c
	include/media/dvbdev.h
Signed-off-by: default avatarliwei <liwei728@huawei.com>
parent d7874ce2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment