linux-stable/drivers/media
Linus Torvalds 6647e76ab6 v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails
The V4L2_MEMORY_USERPTR interface is long deprecated and shouldn't be
used (and is discouraged for any modern v4l drivers).  And Seth Jenkins
points out that the fallback to VM_PFNMAP/VM_IO is fundamentally racy
and dangerous.

Note that it's not even a case that should trigger, since any normal
user pointer logic ends up just using the pin_user_pages_fast() call
that does the proper page reference counting.  That's not the problem
case, only if you try to use special device mappings do you have any
issues.

Normally I'd just remove this during the merge window, but since Seth
pointed out the problem cases, we really want to know as soon as
possible if there are actually any users of this odd special case of a
legacy interface.  Neither Hans nor Mauro seem to think that such
mis-uses of the old legacy interface should exist.  As Mauro says:

 "See, V4L2 has actually 4 streaming APIs:
        - Kernel-allocated mmap (usually referred simply as just mmap);
        - USERPTR mmap;
        - read();
        - dmabuf;

  The USERPTR is one of the oldest way to use it, coming from V4L
  version 1 times, and by far the least used one"

And Hans chimed in on the USERPTR interface:

 "To be honest, I wouldn't mind if it goes away completely, but that's a
  bit of a pipe dream right now"

but while removing this legacy interface entirely may be a pipe dream we
can at least try to remove the unlikely (and actively broken) case of
using special device mappings for USERPTR accesses.

This replaces it with a WARN_ONCE() that we can remove once we've
hopefully confirmed that no actual users exist.

NOTE! Longer term, this means that a 'struct frame_vector' only ever
contains proper page pointers, and all the games we have with converting
them to pages can go away (grep for 'frame_vector_to_pages()' and the
uses of 'vec->is_pfns').  But this is just the first step, to verify
that this code really is all dead, and do so as quickly as possible.

Reported-by: Seth Jenkins <sethjenkins@google.com>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-12-02 13:33:57 -08:00
..
cec media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
common v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails 2022-12-02 13:33:57 -08:00
dvb-core media: dvb_vb2: fix possible out of bound access 2022-09-27 10:24:44 +02:00
dvb-frontends media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
firewire media: Makefiles: remove extra spaces 2022-03-12 16:59:52 +01:00
i2c media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
mc media: mc: convert pipeline funcs to take media_pad 2022-09-24 09:22:30 +02:00
mmc media: media/*/Kconfig: sort entries 2022-03-18 05:58:35 +01:00
pci media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
platform media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
radio media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
rc media: mceusb: set timeout to at least timeout provided 2022-09-24 07:50:42 +02:00
spi media updates for v5.18-rc1 2022-03-23 14:51:35 -07:00
test-drivers media: vivid: set num_in/outputs to 0 if not supported 2022-10-25 16:43:34 +01:00
tuners media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
usb media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
v4l2-core media: v4l2-dv-timings: add sanity checks for blanking values 2022-10-25 16:39:47 +01:00
Kconfig media: remove reference to CONFIG_EMBEDDED in MEDIA_SUPPORT_FILTER 2022-09-08 18:19:29 +02:00
Makefile media: Makefiles: remove extra spaces 2022-03-12 16:59:52 +01:00