Commit graph

20899 commits

Author SHA1 Message Date
Arnd Bergmann b2e0de6c5e ir-core: fix gcc-7 warning on bool arithmetic
commit bd7e31bbade02bc1e92aa00d5cf2cee2da66838a upstream.

gcc-7 suggests that an expression using a bitwise not and a bitmask
on a 'bool' variable is better written using boolean logic:

drivers/media/rc/imon.c: In function 'imon_incoming_scancode':
drivers/media/rc/imon.c:1725:22: error: '~' on a boolean expression [-Werror=bool-operation]
    ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1;
                      ^
drivers/media/rc/imon.c:1725:22: note: did you mean to use logical not?

I agree.

Fixes: 21677cfc56 ("V4L/DVB: ir-core: add imon driver")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2019-07-27 21:44:38 +02:00
Mauro Carvalho Chehab 6345ca1a3c siano: make it work again with CONFIG_VMAP_STACK
commit f9c85ee67164b37f9296eab3b754e543e4e96a1c upstream.

Reported as a Kaffeine bug:
	https://bugs.kde.org/show_bug.cgi?id=375811

The USB control messages require DMA to work. We cannot pass
a stack-allocated buffer, as it is not warranted that the
stack would be into a DMA enabled area.

On Kernel 4.9, the default is to not accept DMA on stack anymore
on x86 architecture. On other architectures, this has been a
requirement since Kernel 2.2. So, after this patch, this driver
should likely work fine on all archs.

Tested with USB ID 2040:5510: Hauppauge Windham

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2019-07-27 21:43:54 +02:00
Takashi Iwai 29ae6dcd31 xc2028: Fix use-after-free bug properly
commit 22a1e7783e173ab3d86018eb590107d68df46c11 upstream.

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')
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2019-07-27 21:43:23 +02:00
Dan Carpenter e986a5a049 xc2028: unlock on error in xc2028_set_config()
commit 210bd104c6acd31c3c6b8b075b3f12d4a9f6b60d upstream.

We have to unlock before returning -ENOMEM.

Fixes: 8dfbcc4351a0 ('[media] xc2028: avoid use after free')

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2019-07-27 21:43:22 +02:00
Nicolas Iooss c4149e345d ite-cir: initialize use_demodulator before using it
commit 7ec03e60ef81c19b5d3a46dd070ee966774b860f upstream.

Function ite_set_carrier_params() uses variable use_demodulator after
having initialized it to false in some if branches, but this variable is
never set to true otherwise.

This bug has been found using clang -Wsometimes-uninitialized warning
flag.

Fixes: 620a32bba4 ("[media] rc: New rc-based ite-cir driver for
several ITE CIRs")

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2019-07-27 21:43:01 +02:00
Trishansh Bhardwaj dfd2d6c35b msm: camera: Return -NOTTY on invalid ioctl command.
Check validity of command before processing.

Change-Id: Icc5c57eac999b7c40fbb9505b2b88745167adc66
Signed-off-by: Trishansh Bhardwaj <tbhardwa@codeaurora.org>
2018-05-26 00:39:36 +02:00
Senthil Kumar Rajagopal 76c635edc2 msm: camera: isp: Handle array out of bounds
The pointer qbuf_buf comes from userspace.
qbuf_buf->num_planes is used with no bound check,
which if set to a large value, it will overflow
buf_info->mapped_info and qbuf_buf->planes

CRs-Fixed: 2003798

Change-Id: I332e0424e57bb14b481a740604a09350e6f029a8
Signed-off-by: Senthil Kumar Rajagopal <skrajago@codeaurora.org>
2018-05-26 00:39:36 +02:00
LuK1337 39a771baad Merge tag 'LA.BR.1.3.6-05410-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-05410-8976.0"
2018-02-06 13:11:45 +01:00
VijayaKumar T M a8b1f40acb msm: sensor: actuator: add null pointer check for i2c array
Issue:
i2c_reg_tbl may be null under error condition when set param.
then, other actuator function still may use the i2c_reg_tbl as null.
Fix:
1) the assignment total_steps follow on kmalloc buffer.
2) Add NULL pointer check for i2c tbl.

CRs-Fixed: 2152401
Change-Id: Ieec3d88e6dae0177787da0906f53d59ac4f5a624
Signed-off-by: Haibin Liu <haibinl@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2018-01-28 23:17:43 -08:00
Linux Build Service Account d458e5389e Merge "msm: camera: Prevent buffer overread in write_logsync." 2018-01-22 19:30:05 -08:00
Trishansh Bhardwaj 419cc01311 msm: camera: Prevent buffer overread in write_logsync.
If userspace issues write with string of length 21 or more then
there is a chance that kernel will overread lbuf array.
This change makes sure that lbuf is NULL terminated.

Change-Id: I9ad6d5a607b2ff1f293512be9746ee554b076b10
Signed-off-by: Trishansh Bhardwaj <tbhardwa@codeaurora.org>
2018-01-21 21:33:17 -08:00
Depeng Shao 46607534af msm: camera: sensor: Validate sensor related name length
Variable "slave_info->sensor_name", "slave_info->eeprom_name",
"slave_info->actuator_name" and "slave_info->ois_name" are
from user input, which may be not NULL terminated.
OOB will be possible when accessing these variable.

Add a validation for these name length.

Change-Id: I9a570372707b7f8365a625d6b0662e87d1b4926e
Signed-off-by: Depeng Shao <dshao@codeaurora.org>
2018-01-21 21:12:46 -08:00
Daniel Mentz f514ea6147 v4l2: Refactor, fix security bug in compat ioctl32
The 32-bit compat v4l2 ioctl is implemented based on its 64-bit
equivalent. It converts 32-bit data structures into its 64-bit
equivalents and needs to provide the data to the 64-bit ioctl in user
space memory which is commonly allocated using
compat_alloc_user_space(). However, due to how that function is
implemented, it can only be called a single time for every syscall
invocation.  Supposedly to avoid this limitation, the existing code uses
a mix of memory from the kernel stack and memory allocated through
compat_alloc_user_space(). Under normal circumstances, this would not
work, because the 64-bit ioctl expects all pointers to point to user
space memory. As a workaround, set_fs(KERNEL_DS) is called to
temporarily disable this extra safety check and allow kernel pointers.
However, this might introduce a security vulnerability: The
result of the 32-bit to 64-bit conversion is writeable by user space
because the output buffer has been allocated via
compat_alloc_user_space(). A malicious user space process could then
manipulate pointers inside this output buffer, and due to the previous
set_fs(KERNEL_DS) call, functions like get_user() or put_user() no longer
prevent kernel memory access.

The new approach is to pre-calculate the total amount of user space
memory that is needed, allocate it using compat_alloc_user_space() and
then divide up the allocated memory to accommodate all data structures
that need to be converted.

An alternative approach would have been to retain the union type karg
that they allocated on the kernel stack in do_video_ioctl(), copy all
data from user space into karg and then back to user space. However,
we decided against this approach because it does not align with other
compat syscall implementations. Instead, we tried to replicate the
get_user/put_user pairs as found in other places in the kernel:

if (get_user(clipcount, &up->clipcount) ||
    put_user(clipcount, &kp->clipcount)) return -EFAULT;

BUG: 34624167
Change-Id: Ica92695d8ddf60c0a067ea2f833f22a71710932e
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Reported-by: C0RE Team
2017-12-22 20:26:04 +00:00
LuK1337 b2213f5c42 Merge tag 'LA.BR.1.3.6-05010-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into cm-14.1-merge
"LA.BR.1.3.6-05010-8976.0"
2017-11-22 00:26:48 +01:00
Linux Build Service Account ef3c084e15 Merge "msm: camera: Instead of read_lock use read_lock_irqsave." 2017-11-13 19:27:54 -08:00
VijayaKumar T M 8aa50668f9 msm: camera: Instead of read_lock use read_lock_irqsave.
Prevent deadlock between tasklet and delete_stream by stopping
irq during delete_stream

CRs-Fixed: 2076578
Change-Id: Ibcc9fd44403d24112b01150a7d1f3c6e705ea99a
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-11-13 02:03:12 -08:00
Haibin Liu f411d85a55 msm: sensor: actuator: avoid accessing out of bound memory
Issue:
When total_steps is updated, after that, copy_from_user
fails with an error, then, i2c_reg_tbl is not allocated.
In this case, when calling msm_actuator_parse_i2c_params,
it lead to out-of-bound memory write.

Fix:
1) Assign total_steps to zero when error from copying.
2) Add NULL pointer check for i2c tbl.

CRs-Fixed: 2111672
Change-Id: Ib9dcb182356e2df8078c131edfd0791fa95a35e0
Signed-off-by: Haibin Liu <haibinl@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-11-13 02:02:57 -08:00
Linux Build Service Account 203b28e201 Merge "media: v4l2-compat-ioctl32: memset stack union in compat ioctl" 2017-11-08 23:35:37 -08:00
Surajit Podder 8da68b516b media: v4l2-compat-ioctl32: memset stack union in compat ioctl
memset karg in do_video_ioctl to ensure that stack memory is
not copied to user memory.

Change-Id: Ib892f8cabff1e0076c670496ee6353d00afdf85e
Signed-off-by: Surajit Podder <spodder@codeaurora.org>
Signed-off-by: Sanjay Singh <sisanj@codeaurora.org>
2017-11-08 05:32:19 -08:00
Alok Kediya 9997d8908f msm: camera: Bound check for num_of_stream.
- num of stream comes from userspace and used without
any bound check.It may result to overflow update_info.

CRs-Fixed: 2006829

Change-Id: I8226e8f7081b28108dbed738ea4579e2051a85f2
Signed-off-by: Alok Kediya <kediya@codeaurora.org>
2017-11-08 05:21:29 -08:00
LuK1337 4cce184099 Merge tag 'LA.BR.1.3.6-04910-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04910-8976.0"
2017-10-14 19:29:50 +02:00
annamraj ab92975b2e msm: camera: Make use of mutex lock to avoid race condition
Make use of mutex lock to access IOCTL so that two threads
can avoid race condition.

Change-Id: I00db78a42c86eef8a157b5b3547e4ca0006b0853
Signed-off-by: annamraj <annamraj@codeaurora.org>
2017-10-04 22:48:29 -07:00
Linux Build Service Account 59eb244f5a Merge "drivers: media: broadcast: Fix security vulnerability issue" 2017-10-04 07:40:46 -07:00
Linux Build Service Account 0ce39b9939 Merge "msm: sensor: flash: add conditional check for ioctl" 2017-10-04 07:40:45 -07:00
Udaya Bhaskara Reddy Mallavarapu f606a20aaa drivers: media: broadcast: Fix security vulnerability issue
Information leak issue is reported in mpq_sdmx_log_level_write
function. Added check to validate count is not zero and initialize
the string.

Change-Id: Ieb2ed88c2d7d778c56be2ec3b9875270a9c74dce
Signed-off-by: Udaya Bhaskara Reddy Mallavarapu <udaym@codeaurora.org>
2017-10-03 22:54:29 -07:00
Tanvi Aggarwal f33047f466 msm: sensor: flash: add conditional check for ioctl
Add conditional check when sending VIDIOC_MSM_FLASH_CFG
in 32-bit process.

Change-Id: I73bcce85a212495ce94e6265947c11a6bc0e4040
CRs-Fixed: 2092793
Signed-off-by: Tanvi Aggarwal <tanvia@codeaurora.org>
2017-10-03 22:53:50 -07:00
VijayaKumar T M 31bddbf13b msm: camera: isp: Check null pointer for VFE0 base
Add NULL pointer check for vfe_base of VFE0.
CRs-Fixed: 1032715
Change-Id: I540d9ff831fc9447ecf145f75ea84da3668c4f6f
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-10-03 22:39:49 -07:00
LuK1337 97104ad488 Merge tag 'LA.BR.1.3.6-04710-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04710-8976.0"
2017-09-15 11:27:24 +02:00
Fei Zhang f21717864c msm📷 correct stats query out of boundary
fix one potential out of boundary query of stats info.

Bug: 36264696
Change-Id: I13e4bf8802fcce529f9268c272e4727619d5ad8f
Signed-off-by: Fei Zhang <feizhang@codeaurora.org>
2017-09-08 18:51:15 +00:00
Linux Build Service Account 28135c12f2 Merge "msm: sensor: Fix crash when ioctl VIDIOC_MSM_SENSOR_INIT_CFG" 2017-09-06 10:21:30 -07:00
Haibin Liu a7d1b9c335 msm: sensor: Fix crash when ioctl VIDIOC_MSM_SENSOR_INIT_CFG
Issue:
the invalid slave_info is used by msm_sensor_driver_probe.
This cause crash when ioctl VIDIOC_MSM_SENSOR_INIT_CFG repeatedly.

Fix:
1) avoid the same msm_sd_subdev added into the ordered_sd_list.
2) enlarge the buffer size for i2c addr and data.

Change-Id: Idffcd3b82b9590dbfdcaf14b80668cc894178f54
Signed-off-by: Haibin Liu <haibinl@codeaurora.org>
2017-09-06 13:31:55 +05:30
Manish Poddar 0844892deb msm: camera: fix Information leak
In msm_buf_mngr_sd_shutdown bufs is a pointer defined
in kernel, and it is printed to userspace using %lx.
changed it to %pK.

Change-Id: Ic2cb1a2ff109364ac2da1bbb3253a2253a0c6be9
Signed-off-by: Manish Poddar <mpoddar@codeaurora.org>
2017-09-06 00:14:20 -07:00
Linux Build Service Account d4898a2aba Merge "msm: sensor: Add mutex lock during ois power down operations" 2017-09-04 10:58:31 -07:00
Linux Build Service Account 8d01035ba4 Merge "msm: camera: Fix Use after free bug in msm_vb2.c." 2017-08-30 12:57:20 -07:00
Linux Build Service Account e174684786 Merge "msm: sensor: ois: add conditional check for ioctl" 2017-08-30 12:57:19 -07:00
Tanvi Aggarwal 13b3e7463f msm: sensor: ois: add conditional check for ioctl
Add conditional check when sending VIDIOC_MSM_OIS_CFG.

Change-Id: I128591359d7996fe73e9ac3d8a17c47004a2e04e
CRs-Fixed:2078155
Signed-off-by: Tanvi Aggarwal <tanvia@codeaurora.org>
2017-08-30 00:22:27 -07:00
annamraj faf23960fb msm: camera: Avoid deadlock for vb2 operations using separate lock
Use mutex lock for all VB2 operations, and use separatelock other
than used for stop streaming operation to avoid dead lock.

Change-Id: Idba956e5e3bce48ee57eaa5984786ded218e32d5
Signed-off-by: annamraj <annamraj@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-08-30 00:11:42 -07:00
VijayaKumar T M 6cd3a5d1e8 msm: camera: Fix Use after free bug in msm_vb2.c.
There is no syncronization between msm_vb2_get_buf
and msm_delete_stream which can lead to use after
free.
Fixed it by using read/write lock.

CRs-Fixed: 2013052
Change-Id: I8e80d70ec866253aab8836457a28ae14175f5d61
Signed-off-by: Manish Poddar <mpoddar@codeaurora.org>
Signed-off-by: Trishansh Bhardwaj <tbhardwa@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-08-29 12:02:33 +05:30
Linux Build Service Account a667e7ca2b Merge "msm: camera: fix off-by-one overflow in msm_isp_get_bufq" 2017-08-21 11:52:15 -07:00
VijayaKumar T M 28747fad32 msm: camera: fix off-by-one overflow in msm_isp_get_bufq
In msm_isp_get_bufq, if bufq_index equals buf_mgr->num_buf_q,
it will pass the check, leading to off-by-one overflow
(exceed the length of array by one element).

CRs-Fixed: 2031677
Change-Id: I7ea465897e2c37de6ca0155c3e225f1444b3cf13
Signed-off-by: Gaoxiang Chen <gaochen@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-08-21 03:03:29 -07:00
Fei Zhang 62fc4a69bc msm📷 correct stats query out of boundary
fix one potential out of boundary query of stats info.

Change-Id: I13e4bf8802fcce529f9268c272e4727619d5ad8f
Signed-off-by: Fei Zhang <feizhang@codeaurora.org>
2017-08-21 02:48:07 -07:00
VijayaKumar T M 3a900f06d6 msm: sensor: Add mutex lock during ois power down operations
Protecting operations performed during ois powerdown
from race condition by adding mutex lock.

CRs-Fixed: 2081806
Change-Id: I27a735fd69d3e98fdd2ed48456336c560b6f3adc
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-08-07 18:46:01 +05:30
LuK1337 f77b254b9f Merge tag 'LA.BR.1.3.6-04510-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04510-8976.0"
2017-08-06 13:38:06 +02:00
Linux Build Service Account 9d4be107c7 Merge "msm: camera: sensor:validating the flash initialization parameters" 2017-07-25 23:10:00 -07:00
Haibin Liu 11972e5390 msm: sensor: actuator: add conditional check for ioctl
Add conditional check when operating VIDIOC_MSM_ACTUATOR_CFG32.

CRs-Fixed: 2060371
Change-Id: I9cfaff05b1fff6969a2543c3816d41ed1fabf897
Signed-off-by: Haibin Liu <haibinl@codeaurora.org>
2017-07-25 04:19:38 -07:00
kaiwang 814e714926 msm: camera: sensor:validating the flash initialization parameters
Copying the flash initialization parameters from userspace memory to
kernel memory and in turn checking for the validity of the flash
initialization parameters pointer sent from userspace

CRs-Fixed: 2059812
Change-Id: I957c10959108eb08b263d439a9a449b90338b6db
Signed-off-by: kaiwang <kaiwang@codeaurora.org>
Signed-off-by: Haibin Liu <haibinl@codeaurora.org>
2017-07-25 03:57:22 -07:00
Dennis Cagle 7f5259209b msm: camera: Add regulator enable and disable independent of CSID
Regulator enable and disable of CSIPHY depends on the CSID module.
Make the enable and disable of clk regulator independent of CSIPHY.

Bug: 33299365
CRs-Fixed: 1107702
Change-Id: Iabb5eb28d63b34a4c3201c53be17054a1907f4fe
Signed-off-by: Ravi Kishore Tanuku <rktanuku@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
Signed-off-by: Dennis Cagle <d-cagle@codeaurora.org>
(cherry picked from commit b1bb44c9cca61e48ec6158abad6e7969a8e58abf)
2017-07-10 23:03:58 +00:00
LuK1337 ea03599937 Merge tag 'LA.BR.1.3.6-04110-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04110-8976.0"

Change-Id: Ie9bc105eee4263ab1ec2f91556feca988522808f
2017-07-08 18:34:23 +02:00
VijayaKumar T M 928b1dc832 msm: sensor: Validationg function pointers before using them
Since IOCTLS can come in any order, validating the actuator
function table and methods before accessing them.

CRs-Fixed: 1084177
Change-Id: Ic6fce52fdf4d1420c2b707ec9bc9cba045066a13
Signed-off-by: Sureshnaidu Laveti <lsuresh@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-07-01 12:51:55 +02:00
Rajesh Bondugula a4dc554709 msm: camera: sensor: Add boundary check for cci master
Add boundary check for cci master in i2c_read.
This value is passed from userpsace. If user sends an
invalid number for master there is a possibility of
accessing unintended buffer.

This change addresses the issue.

Crs-Fixed: 1086764
Signed-off-by: Rajesh Bondugula <rajeshb@codeaurora.org>
Change-Id: Ice3bde902aea96382ceb4dfddfd28a5ea89c183d
2017-07-01 12:51:55 +02:00