Commit graph

154 commits

Author SHA1 Message Date
Trishansh Bhardwaj
69a0524941 msm: camera: Allow driver file to be opend only once.
Use proper synchronization to ensure driver file is opened
only once.

CRs-Fixed: 2023513
Change-Id: I71e55e2d487fe561d3f596590b3e8102c5e921b5
Signed-off-by: Trishansh Bhardwaj <tbhardwa@codeaurora.org>
(cherry picked from commit 84f8c42e5d848b1d04f49d253f98296e8c2280b9)
2017-09-14 15:52:36 +02:00
guyang
612813a5e6 msm: camera: sensor: Validate eeprom_name string length
Validate eeprom_name string length before copying into
the userspace buffer.
If more data than required is copied, userspace has the access to
some of kernel data which is not intended.

CRs-Fixed: 1090007
Change-Id: Id40a287e0b1a93cc15d9b02c757fe9f347e285f2
Signed-off-by: Rajesh Bondugula <rajeshb@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
Signed-off-by: Yang Guang <guyang@codeaurora.org>
2017-06-26 21:24:23 +03:00
VijayaKumar T M
189f24aaf2 msm: camera: sensor: Fix use after free condition
Add a check to return value before calling csid config which will
otherwise lead to use after free scenario.

CRs-Fixed: 1040857
Change-Id: I4f4d9e38eeb537875e0d01de0e99913a44dd3f3f
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
2017-06-26 18:28:49 +03:00
Trilokesh Rangam
b3d146e1dd msm-camera: Addressing possible overflow conditions
Changes to address possible integer overflow and incorrect
array indexing conditions.

CAF-Change-Id: Ib134320cd6f7b34d7a10572ec347ec12127049a9
Signed-off-by: Trilokesh Rangam <tranga@codeaurora.org>

CVE-2016-10233

Change-Id: I7bc2a8791bb37dc6cff5f5e36555b7a7b5e99938
(cherry picked from commit d793c6d91ecba2a1fd206ad47a4fd408d290addf)
2017-04-04 14:13:43 -06:00
Suman Mukherjee
a6c6ae09a6 msm: sensor: validate the i2c table index before use
Verifying the i2c table index value before accessing
the i2c table to avoid memory corruption issues.
CRs-Fixed: 1065916

Change-Id: I0e31c22f90006f27a77cd420288334b8355cee95
Signed-off-by: Sureshnaidu Laveti <lsuresh@codeaurora.org>
Signed-off-by: Suman Mukherjee <sumam@codeaurora.org>
2016-12-22 21:39:17 +11:00
Petar Sivenov
3a0f8ec9e2 msm📷isp: fix array index bound checks
This change fixes several incorrect or missing array index bound checks.

Bug: 28814502
Change-Id: Icd96555c01330ec11e94c6173d8df1973fe39c33
Signed-off-by: Petar Sivenov <psiven@codeaurora.org>
2016-06-03 11:55:33 -07:00
Jim Rasche
cebda807e6 msm📷 Fix multiple bounds check
Added bounds check to user input num_streams at several location,
without checking a position outside array could be dereferenced

Bug: 28749629
Change-Id: I6e82d8b51e4ec6772316c7daef243240c029db96
Signed-off-by: Jim Rasche <jrasche@codeaurora.org>
2016-06-02 12:28:59 -07:00
Rajesh Bondugula
7e24523b95 msm: camera: Update CCI WR command buffer size to 11 bytes
I2C command length is of 11 bytes, it includes 10 bytes of data and
1 byte of WR command. Use 11 bytes char array to create command.

Bug: 28770207
Signed-off-by: Rajesh Bondugula <rajeshb@codeaurora.org>
Change-Id: I5292f238d612810a514b6a8bba9e70e07eb2627f
2016-06-02 12:24:55 -07:00
Yueyao (Nathan) Zhu
895a5204ff msm: camera: added zero checks for msm_isp_proc_cmd...
and bound check for msm_isp_set_src_state

Bug: 28749803
Change-Id: Ibc686f64229552160c2f65f672ba8c97ef520443
2016-06-02 12:03:41 -07:00
Petar Sivenov
22591b12e0 msm: camera: isp: Bound check for number stats registers
The index of used stats register is derived from a stream handle least
significant byte and thus can be up to 255. However the stats registers
are up to 8 depending of the target. Thus a bound check is done before
use of the received stats register index value.

Bug: 28749728
Change-Id: I23f1add81eb8e0844103a3a3f59f4e4c2af14ffd
2016-06-02 11:58:27 -07:00
Hariram Purushothaman
7f6fa08202 msm: camera: Check stats index MAX in ISP driver
Add a check for the stats index MAX using
MSM_ISP_STATS_MAX before accessing stream info
using that index to avoid any invalid memory access.

Bug: 28749728
Change-Id: I29d9b62cec045598645fbc0e6e62c500eb74bb97
2016-06-02 11:58:11 -07:00
Lakshmi Narayana Kalavala
5d8657c170 msm: camera: Fix possible out of bound writes in csi driver
The value csi_lane_mask which is uint16_t is controllable from userspace.
The while loop can loop for 2^16 - 1, Hence extract the required
bit combination from the userspace argument, used it for further
processing.

Bug: 28749721
CRs-Fixed: 511976
Change-Id: I80b0fe7ac273352503d9705510f05debe6cbb10a
Signed-off-by: Lakshmi Narayana Kalavala <lkalaval@codeaurora.org>
2016-06-02 11:56:25 -07:00
Hariram Purushothaman
f0b6dc3d82 msm: camera: Bound check num_cid from userspace in csid driver
Upper and lower bound checks are enforced for num_cid
which is passed from userspace with lower as 1 and
max of 16.

Bug: 28747684
Change-Id: Ic5456289cb2f2b4ea17610a7672eb2c5225b7954
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
2016-06-02 11:43:20 -07:00
Vasko Kalanoski
221a82e562 msm: actuator: fix to prevent untrusted pointer to lead DoS
fix to prevent untrusted userspace pointer in actuator kernel
driver to lead DoS

Bug: 28768281
Change-Id: I1b64270deb494530d268539e7b420be5ec79b658
Signed-off-by: Vasko Kalanoski <vaskok@codeaurora.org>
Signed-off-by: Siqi Lin <siqilin@google.com>
2016-05-31 14:34:38 -07:00
Rajesh Bondugula
877f6d8c6f msm: camera: sensor: Validate step_boundary
step_boundary can take values upto the total_steps
Validate the step_boundary before consuming it.
Convert the type of step_index and region_index to uint16_t
step_index and region_index cannot be negative.

Bug: 27890772

CRs-Fixed: 1001092
Change-Id: I1f23fd6f28bb897824a1ef99a8873b9f986eee70
Signed-off-by: Rajesh Bondugula <rajeshb@codeaurora.org>
2016-05-19 17:52:01 -07:00
Vasko Kalanoski
6e653fff37 msm: actuator: fix to prevent kernel heap buffer overflow
fix to prevent kernel heap buffer overflow allows user
controlled data to be written to the heap via the
msm_camera actuator IOCTLs

Bug: 28557260
Change-Id: I4458831e28e0081fb2f5ae55506be866100e1b4f
Signed-off-by: Vasko Kalanoski <vaskok@codeaurora.org>
2016-05-09 17:15:38 -07:00
Nick Desaulniers
8064a62b27 From a7502f4f80 Mon Sep 17 00:00:00 2001 From: Xu Han <hanxu@codeaurora.org> Date: Wed, 25 Sep 2013 15:28:32 -0700 Subject: msm: camera: Checking an enum value greater than zero
An enum value cci_i2c_master is not checked to be greater than 0.
Add the check.

Bug: 28441831
Change-Id: Ibe75ab7155def45d81b8127c5eda3fa2ed570bce
Signed-off-by: Xu Han <hanxu@codeaurora.org>
2016-05-04 11:19:06 -07:00
Nick Desaulniers
2021b895cb msm: camera: Fix various small issues in cci driver
Remove some unused ioctl exposed, Also add
some bound checks for ioctl user params.

Bug: 28441831
Change-Id: Ifdd441fdb25fd20b005c4e4e1ebe4e203f1216ac
CRs-Fixed: 511382
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
2016-05-04 11:19:02 -07:00
Hariram Purushothaman
451ba15d80 msm: camera: Fix various small issues in Actuator driver
Bound check and validate userspace parameters direction,
number of steps and direction sign. Also fix possible
memory leak in certain error cases.

Bug: 28431531
CRs-Fixed: 511349
Change-Id: Icaa324468574494fb40f2de78e522090806744cb
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
2016-05-02 22:48:16 -07:00
Suman Mukherjee
cbd741f1c3 msm: camera: ispif: Validate VFE num input during reset
Userspace supplies the actual number of used VFEs in session to ISPIF.
Validate the userspace input value and if found to be invalid, return
error.

BUG=27600832

Change-Id: I91944434e9a83d34af765c40bf8ad297a09ce2f5
2016-04-13 17:02:36 -07:00
Alok Kediya
18d456d3b2 msm: camera: isp: Validate input parameter for vfe_write and vfe_read
Validate input parameters for read and write operations in vfe to
ensure operations are performed within vfe register boundary and
within structure limits passed by caller.

Bug: 19141655

Conflicts:
	drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
	drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_io_util.c
	drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_io_util.h

Change-Id: If3719de65b32773c2b6ff904da76a951dbfb11eb
Signed-off-by: Alok Kediya <kediya@codeaurora.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>
Signed-off-by: Patrick Tjin <pattjin@google.com>
2015-01-28 07:46:54 -08:00
Alok Kediya
41dda3638b msm: camera: isp: Validate reg_offset and len parameters
Validate reg_offset and len parameters before consuming to
avoid invalid register access.

Bug: 19141654

Conflicts:
	drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c

Change-Id: I07676a6d10a9945fb0b99ebfd147075f896fbfab
Signed-off-by: Alok Kediya <kediya@codeaurora.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>
2015-01-28 07:46:54 -08:00
Suman Mukherjee
8e75fa23b3 msm: camera: ispif: Validate vfe_intf parameter
Validate vfe_intf parameter to avoid invalid register access.

Conflicts:
	drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c

Bug: 19141503
Change-Id: Ie0b57071cc5fca1c48d3a5e2e7819f9af9ff544c
Signed-off-by: Suman Mukherjee <sumam@codeaurora.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>
2015-01-28 07:46:53 -08:00
Suman Mukherjee
89e0fbac4c msm: camera: add check for csid_cid to prevent of overwrite memory
add sanity check for csid cid to ensute that we never read or write
outside csid_dev->mem buffer

Bug: 19134929
Change-Id: Ic8f0d689fa176720ae3a3316f2ad27556ae7bde5
Signed-off-by: Suman Mukherjee <sumam@codeaurora.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>
2015-01-28 07:46:50 -08:00
Mekala Natarajan
8533ea5918 msm: camera: Print out event type when timeout happens
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:42:49 -08:00
Mekala Natarajan
8aa1d84691 msm: camera: Handle ERESTARTSYS properly
Driver needs to propogate ERESTARTSYS return code instead
of changing it to some other value.

Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:42:48 -08:00
Mekala Natarajan
dc67ad4656 msm: camera: Handle -ERESTARTSYS as special case in CCI
When kernel is interrupted with -ERESTARTSYS, don't perform any
more CCI transaction and return error immediately.

Bug: 11005919
Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
Signed-off-by: Mansoor Aftab <maftab@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:42:48 -08:00
Mekala Natarajan
1bd3e73b67 msm: camera: Update UB size for stats
Update UB size for BG stats to avoid overflow.

Change-Id: I88f73887bd5343a44f9911ff9ecfa4dba8449e17
Signed-off-by: Suresh Vankadara <svankada@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:42:47 -08:00
Mekala Natarajan
80c8e829b2 msm: camera_v2: fix unbalanced mutex
Change-Id: Ie636f8b0a5129d35de7a6a6870d370f6f5374f94
Signed-off-by: Jongrak Kwon <jongrak.kwon@lge.com>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:41:57 -08:00
Mekala Natarajan
16a09d7e31 msm: camera_v2: protect cmd_ack_q around mutex.
Insertions and deletions into the session based command
ack queue need to be synchronized since they may be accessed
from more than one context.

CRs-fixed: 516599
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:41:01 -08:00
Mekala Natarajan
cd5b15c8b8 camera: Make stop_session a blocking call
For stop_session, we want to wait for it to complete before return.
Otherwise, we run into race condition when next start_session
happens.

Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:40:28 -08:00
Mekala Natarajan
cfe51cf7a7 msm: camera: Fix memory leak in camera close op
Delete and free residual entry of command ack while closing camera.

Change-Id: Ica0f8934f3faa2079570730723df0d74e10784e8
Signed-off-by: Azam Sadiq Pasha Kapatrala Syed <akapatra@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-13 12:39:08 -08:00
Mekala Natarajan
0f98967daa msm📷 Fix signedness issue in hw_exec_cmds
In hw_exec_cmds()second argument m_cmds should be
of type unsigned interger

Bug:11518040

Signed-off-by: Apurva Rajguru <arajguru@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-08 23:26:13 +00:00
Mekala Natarajan
328ee785f8 msm📷 Fix overflow issue in ioctl_hw_cmds function
'len' is of type signed int 32bit,but the assigned value
may exceed maximum unsigned int32 range.Add overflow check
and graceful exit if 'm'exceeds UINT32_MAX value.

Bug:11518040

Signed-off-by: Apurva Rajguru <arajguru@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-11-08 23:25:30 +00:00
Mekala Natarajan
f878d49d71 msm: camera: Add the missed "break" for CAMERA_FPS_FIX_15 case
Add the missed "break" for CAMERA_FPS_FIX_15 case in
mi1040_sensor_set_fps()

Bug: 11016037
Signed-off-by: Rajaram Gudivada <rajaramg@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-10-11 23:48:46 +00:00
chiayi_wu
0e6fb1528d camera: Quality tuning for yuv sensor
Modify AE, AWB, and LSC.
Bug: 9598039

Change-Id: I9dc7f3bc477faa86dffe4ecd01e9f1a1c31e8755
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
2013-06-27 15:08:58 +00:00
chiayi_wu
4d0f1a4425 camera: Modify the auto fps settings for YUV sensor.
We need to set fine_integ_time_max, frame_length_lines, and
line_length_pck when changing fps to auto.
Bug: 9578220

Change-Id: I52ba353a72c40cff7dc3a3ea5120e9393f55426f
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
2013-06-27 15:37:00 +08:00
chiayi_wu
e30128f620 camera: Don't set fps to auto when changing resolutions.
Remove setting fps in the function of setting resolution.
Modify the command sequence for setting frame rate to auto
Bug: 9578220

Change-Id: Ia3a2cbd0aef8194258d5d334815da7505a975b58
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
2013-06-26 21:34:34 +00:00
Mansoor Aftab
f38fb00c09 msm: camera: Change AF Calibration compensation to 60
Bug: 9429279
Signed-off-by: Mansoor Aftab <maftab@codeaurora.org>
2013-06-24 18:19:33 +00:00
chiayi_wu
50b5d7c960 camera: Support setting MWB and EV for yuv sensor.
MBW: auto, incandescent, daylight, flourescent, and cloudy.
EV: +2, +1, 0, -1, -2

Bug: 9492735

Change-Id: Ic12cfc85741dc9472374eb2073eef31dea654780
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
2013-06-24 10:55:26 -07:00
chiayi_wu
e8622da57d camera: Avoid needless setting fps for yuv sensor
Bug: 9514182

Change-Id: Icda6f0c8f85404d704206e2086b302e9ae7d0d7b
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
2013-06-21 10:52:40 +08:00
chiayi_wu
fdd3956c35 camera: Support setting fix frame rate for front camera
Fix: 30fps, 25fps, 24fps, 20fps, and 15fps
Auto: 30fps to 7.5fps

Change-Id: I285e5b9a6df8a1dd1f483b0d44d17c766cf1979f
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-06-19 15:37:48 -07:00
chiayi_wu
ebb513feb9 camera: Using gpio to detect the vendor of front camera.
There're two sources for front camera, and we use gpios to identify them.

Change-Id: Ib9e9c46c908ca3e204cb81545f65ba023aaf2271
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
2013-06-19 16:37:57 +00:00
Mekala Natarajan
6cb87ec60a msm: Camera: Fix the clock enable logic
ISPIF clock enable/disable code has a bug with hard coded
value to enable the clock always.

Do not disable the ispif clock after reset while init, and thus
do enable it while ispif release.

Bug: 9306231

Signed-off-by: Nagesh Subba Reddy <nageshsreddy@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-06-18 20:12:39 +00:00
Mansoor Aftab
67e6919862 msm: camera: Exit gracefully while camera daemon crashes
- AXI halt support
- Handle subdev releases when qcamera daemon crashes
- Handle sensor shutdown using state machine

Signed-off-by: Nagesh Subba Reddy <nageshsreddy@codeaurora.org>
Signed-off-by: Mansoor Aftab <maftab@codeaurora.org>
2013-06-18 19:29:29 +00:00
Ajay Dudani
449d60889d mm-camera: Changes to remove unused code for security issue reported
Changes to remove MSM_CAM_IOCTL_SET_MEM_MAP_INFO Ioctl support.
This will avoid physical memory mapping to userspace.

Change-Id: If014e6d152786b508c8e7ee6c53631913cd4cfcf
Signed-off-by: Guruprasad Gaonkar <ggaonk@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2013-06-18 12:10:25 -07:00
Ajay Dudani
4feaaa3c74 msm: camera: Added the NULL pointer check
Added the NULL pointer check for isp_config
to avoid the crashes

Change-Id: I2df7eeb5c633b04c3aac5d985cf50c2ece7f1076
CRs-Fixed: 495652
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2013-06-18 12:10:24 -07:00
chiayi_wu
079a6967f5 camera: Read OTP from bank 3 for af calibration data.
OTP will be wriiten from bank 1.
If it's written fail, it will be written bank 2, and so on.
The maximum times is 3.
Vendor suggests us reading OTP from bank 3 to bank 1.

Change-Id: I1108fd7e3ce2b7652964b5995fc51cc488b5d191
Signed-off-by: chiayi_wu <chiayi_wu@asus.com>
2013-06-07 16:10:53 +00:00
Shuzhen Wang
e4f4827966 msm: camera2: Remove verbose logging from msm_sensor
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
2013-06-06 23:37:59 +00:00
Shuzhen Wang
d203de0072 msm: camera: Enable out-of-order write for AXI
This change enables out-of-order on AXI fabric. It addresses
VFE write master overflow error.

Signed-off-by: Nagesh Subba Reddy <nageshsreddy@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
2013-06-04 16:32:34 +00:00