<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/media/dvb-core/dvbdev.c, branch linux-4.19.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-12-05T09:59:28Z</updated>
<entry>
<title>media: dvbdev: fix the logic when DVB_DYNAMIC_MINORS is not set</title>
<updated>2024-12-05T09:59:28Z</updated>
<author>
<name>Mauro Carvalho Chehab</name>
</author>
<published>2024-11-06T20:50:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1b7158b3ea0e67d5da4c31cd4973a937ab15950c'/>
<id>urn:sha1:1b7158b3ea0e67d5da4c31cd4973a937ab15950c</id>
<content type='text'>
commit a4aebaf6e6efff548b01a3dc49b4b9074751c15b upstream.

When CONFIG_DVB_DYNAMIC_MINORS, ret is not initialized, and a
semaphore is left at the wrong state, in case of errors.

Make the code simpler and avoid mistakes by having just one error
check logic used weather DVB_DYNAMIC_MINORS is used or not.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Reported-by: Dan Carpenter &lt;dan.carpenter@linaro.org&gt;
Closes: https://lore.kernel.org/r/202410201717.ULWWdJv8-lkp@intel.com/
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+huawei@kernel.org&gt;
Link: https://lore.kernel.org/r/9e067488d8935b8cf00959764a1fa5de85d65725.1730926254.git.mchehab+huawei@kernel.org
Cc: Nathan Chancellor &lt;nathan@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>media: dvbdev: prevent the risk of out of memory access</title>
<updated>2024-11-17T13:58:06Z</updated>
<author>
<name>Mauro Carvalho Chehab</name>
</author>
<published>2024-10-15T13:23:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fedfde9deb83ac8d2f3d5f36f111023df34b1684'/>
<id>urn:sha1:fedfde9deb83ac8d2f3d5f36f111023df34b1684</id>
<content type='text'>
[ Upstream commit 972e63e895abbe8aa1ccbdbb4e6362abda7cd457 ]

The dvbdev contains a static variable used to store dvb minors.

The behavior of it depends if CONFIG_DVB_DYNAMIC_MINORS is set
or not. When not set, dvb_register_device() won't check for
boundaries, as it will rely that a previous call to
dvb_register_adapter() would already be enforcing it.

On a similar way, dvb_device_open() uses the assumption
that the register functions already did the needed checks.

This can be fragile if some device ends using different
calls. This also generate warnings on static check analysers
like Coverity.

So, add explicit guards to prevent potential risk of OOM issues.

Fixes: 5dd3f3071070 ("V4L/DVB (9361): Dynamic DVB minor allocation")
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+huawei@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dvbdev: Initialize sbuf</title>
<updated>2024-07-05T07:00:32Z</updated>
<author>
<name>Ricardo Ribalda</name>
</author>
<published>2024-03-25T14:50:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1925c902159d686372d897c2fa8ee4ea91b62d14'/>
<id>urn:sha1:1925c902159d686372d897c2fa8ee4ea91b62d14</id>
<content type='text'>
[ Upstream commit 17d1316de0d7dc1bdc5d6e3ad4efd30a9bf1a381 ]

Because the size passed to copy_from_user() cannot be known beforehand,
it needs to be checked during runtime with check_object_size. That makes
gcc believe that the content of sbuf can be used before init.

Fix:
./include/linux/thread_info.h:215:17: warning: ‘sbuf’ may be used uninitialized [-Wmaybe-uninitialized]

Signed-off-by: Ricardo Ribalda &lt;ribalda@chromium.org&gt;
Signed-off-by: Hans Verkuil &lt;hverkuil-cisco@xs4all.nl&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: edia: dvbdev: fix a use-after-free</title>
<updated>2024-03-26T22:22:38Z</updated>
<author>
<name>Zhipeng Lu</name>
</author>
<published>2024-02-03T13:40:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d0f5c28333822f9baa5280d813124920720fd856'/>
<id>urn:sha1:d0f5c28333822f9baa5280d813124920720fd856</id>
<content type='text'>
[ Upstream commit 8c64f4cdf4e6cc5682c52523713af8c39c94e6d5 ]

In dvb_register_device, *pdvbdev is set equal to dvbdev, which is freed
in several error-handling paths. However, *pdvbdev is not set to NULL
after dvbdev's deallocation, causing use-after-frees in many places,
for example, in the following call chain:

budget_register
  |-&gt; dvb_dmxdev_init
        |-&gt; dvb_register_device
  |-&gt; dvb_dmxdev_release
        |-&gt; dvb_unregister_device
              |-&gt; dvb_remove_device
                    |-&gt; dvb_device_put
                          |-&gt; kref_put

When calling dvb_unregister_device, dmxdev-&gt;dvbdev (i.e. *pdvbdev in
dvb_register_device) could point to memory that had been freed in
dvb_register_device. Thereafter, this pointer is transferred to
kref_put and triggering a use-after-free.

Link: https://lore.kernel.org/linux-media/20240203134046.3120099-1-alexious@zju.edu.cn
Fixes: b61901024776 ("V4L/DVB (5244): Dvbdev: fix illegal re-usage of fileoperations struct")
Signed-off-by: Zhipeng Lu &lt;alexious@zju.edu.cn&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dvb-core: Fix use-after-free due to race at dvb_register_device()</title>
<updated>2024-03-26T22:22:38Z</updated>
<author>
<name>Hyunwoo Kim</name>
</author>
<published>2022-11-17T04:59:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dc04ff778b4f8ff4560f1c42993417359e74d36a'/>
<id>urn:sha1:dc04ff778b4f8ff4560f1c42993417359e74d36a</id>
<content type='text'>
[ Upstream commit 627bb528b086b4136315c25d6a447a98ea9448d3 ]

dvb_register_device() dynamically allocates fops with kmemdup()
to set the fops-&gt;owner.
And these fops are registered in 'file-&gt;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: Hyunwoo Kim &lt;imv4bel@gmail.com&gt;
Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Reported-by: Dan Carpenter &lt;error27@gmail.com&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
Stable-dep-of: 8c64f4cdf4e6 ("media: edia: dvbdev: fix a use-after-free")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dvbdev: fix error logic at dvb_register_device()</title>
<updated>2024-03-26T22:22:38Z</updated>
<author>
<name>Mauro Carvalho Chehab</name>
</author>
<published>2021-06-09T12:32:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a30cf94eaf5dd3ffd8d13c3a8c303d04357b01c1'/>
<id>urn:sha1:a30cf94eaf5dd3ffd8d13c3a8c303d04357b01c1</id>
<content type='text'>
[ Upstream commit 1fec2ecc252301110e4149e6183fa70460d29674 ]

As reported by smatch:

	drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:510 dvb_register_device() warn: '&amp;dvbdev-&gt;list_head' not removed from list
	drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:530 dvb_register_device() warn: '&amp;dvbdev-&gt;list_head' not removed from list
	drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:545 dvb_register_device() warn: '&amp;dvbdev-&gt;list_head' not removed from list

The error logic inside dvb_register_device() doesn't remove
devices from the dvb_adapter_list in case of errors.

Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+huawei@kernel.org&gt;
Stable-dep-of: 8c64f4cdf4e6 ("media: edia: dvbdev: fix a use-after-free")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dvbdev: Fix memleak in dvb_register_device</title>
<updated>2024-03-26T22:22:38Z</updated>
<author>
<name>Dinghao Liu</name>
</author>
<published>2020-08-24T12:27:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=085f36c317cba8b8955c5da5f59c7486345d2bbb'/>
<id>urn:sha1:085f36c317cba8b8955c5da5f59c7486345d2bbb</id>
<content type='text'>
[ Upstream commit 167faadfcf9339088910e9e85a1b711fcbbef8e9 ]

When device_create() fails, dvbdev and dvbdevfops should
be freed just like when dvb_register_media_device() fails.

Signed-off-by: Dinghao Liu &lt;dinghao.liu@zju.edu.cn&gt;
Signed-off-by: Sean Young &lt;sean@mess.org&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+huawei@kernel.org&gt;
Stable-dep-of: 8c64f4cdf4e6 ("media: edia: dvbdev: fix a use-after-free")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: media/dvb: Use kmemdup rather than duplicating its implementation</title>
<updated>2024-03-26T22:22:38Z</updated>
<author>
<name>Fuqian Huang</name>
</author>
<published>2019-07-03T16:28:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6e4129f8163460c79bb99887bc6f791196fcbda2'/>
<id>urn:sha1:6e4129f8163460c79bb99887bc6f791196fcbda2</id>
<content type='text'>
[ Upstream commit f6af820ef1be58c2e4b81aa479b9f109eb6344ce ]

kmemdup is introduced to duplicate a region of memory in a neat way.
Rather than kmalloc/kzalloc + memcpy, which the programmer needs to
write the size twice (sometimes lead to mistakes), kmemdup improves
readability, leads to smaller code and also reduce the chances of mistakes.
Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy.

Signed-off-by: Fuqian Huang &lt;huangfq.daxian@gmail.com&gt;
Signed-off-by: Sean Young &lt;sean@mess.org&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+samsung@kernel.org&gt;
Stable-dep-of: 8c64f4cdf4e6 ("media: edia: dvbdev: fix a use-after-free")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dvbdev: remove double-unlock</title>
<updated>2024-03-26T22:22:38Z</updated>
<author>
<name>Mauro Carvalho Chehab</name>
</author>
<published>2019-03-28T18:36:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cfa5ffc57e54fb8b864d23b6992cb37d706f6a87'/>
<id>urn:sha1:cfa5ffc57e54fb8b864d23b6992cb37d706f6a87</id>
<content type='text'>
[ Upstream commit 122d0e8dd050cc5dc3fb9e9b5f2dee3c5276ce35 ]

As warned by smatch:
	drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:529 dvb_register_device() error: double unlock 'sem:&amp;minor_rwsem'

Reported-by: Hans Verkuil &lt;hverkuil@xs4all.nl&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+samsung@kernel.org&gt;
Stable-dep-of: 8c64f4cdf4e6 ("media: edia: dvbdev: fix a use-after-free")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dvbdev: drop refcount on error path in dvb_device_open()</title>
<updated>2024-01-25T22:33:36Z</updated>
<author>
<name>Dan Carpenter</name>
</author>
<published>2023-10-31T09:53:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=782a58a14de9f6551dc0e82c19e0caa6f7cc419c'/>
<id>urn:sha1:782a58a14de9f6551dc0e82c19e0caa6f7cc419c</id>
<content type='text'>
[ Upstream commit a2dd235df435a05d389240be748909ada91201d2 ]

If call to file-&gt;f_op-&gt;open() fails, then call dvb_device_put(dvbdev).

Fixes: 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@linaro.org&gt;
Signed-off-by: Hans Verkuil &lt;hverkuil-cisco@xs4all.nl&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
</feed>
