public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.9 01/23] media: af9035: prevent buffer overflow on write
@ 2018-10-08 15:26 Sasha Levin
  2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 02/23] batman-adv: Fix segfault when writing to throughput_override Sasha Levin
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: Sasha Levin @ 2018-10-08 15:26 UTC (permalink / raw)
  To: stable, linux-kernel; +Cc: Jozef Balga, Mauro Carvalho Chehab, Sasha Levin

From: Jozef Balga <jozef.balga@gmail.com>

[ Upstream commit 312f73b648626a0526a3aceebb0a3192aaba05ce ]

When less than 3 bytes are written to the device, memcpy is called with
negative array size which leads to buffer overflow and kernel panic. This
patch adds a condition and returns -EOPNOTSUPP instead.
Fixes bugzilla issue 64871

[mchehab+samsung@kernel.org: fix a merge conflict and changed the
 condition to match the patch's comment, e. g. len == 3 could
 also be valid]
Signed-off-by: Jozef Balga <jozef.balga@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 8961dd732522..64be30d53847 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -406,8 +406,10 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
 			    msg[0].addr == (state->af9033_i2c_addr[1] >> 1))
 				reg |= 0x100000;
 
-			ret = af9035_wr_regs(d, reg, &msg[0].buf[3],
-					msg[0].len - 3);
+			ret = (msg[0].len >= 3) ? af9035_wr_regs(d, reg,
+							         &msg[0].buf[3],
+							         msg[0].len - 3)
+					        : -EOPNOTSUPP;
 		} else {
 			/* I2C write */
 			u8 buf[MAX_XFER_SIZE];
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2018-10-08 15:30 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-08 15:26 [PATCH AUTOSEL 4.9 01/23] media: af9035: prevent buffer overflow on write Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 02/23] batman-adv: Fix segfault when writing to throughput_override Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 03/23] batman-adv: Fix segfault when writing to sysfs elp_interval Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 04/23] batman-adv: Prevent duplicated nc_node entry Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 05/23] batman-adv: Prevent duplicated softif_vlan entry Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 06/23] batman-adv: Prevent duplicated global TT entry Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 07/23] batman-adv: Prevent duplicated tvlv handler Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 08/23] batman-adv: fix backbone_gw refcount on queue_work() failure Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 09/23] batman-adv: fix hardif_neigh " Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 10/23] clocksource/drivers/ti-32k: Add CLOCK_SOURCE_SUSPEND_NONSTOP flag for non-am43 SoCs Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 11/23] ucma: fix a use-after-free in ucma_resolve_ip() Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 12/23] scsi: ibmvscsis: Fix a stringop-overflow warning Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 13/23] scsi: ibmvscsis: Ensure partition name is properly NUL terminated Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 14/23] Input: atakbd - fix Atari keymap Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 15/23] Input: atakbd - fix Atari CapsLock behaviour Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 16/23] ravb: do not write 1 to reserved bits Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 17/23] drm: mali-dp: Call drm_crtc_vblank_reset on device init Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 18/23] scsi: sd: don't crash the host on invalid commands Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.9 19/23] net/mlx4: Use cpumask_available for eq->affinity_mask Sasha Levin
2018-10-08 15:27 ` [PATCH AUTOSEL 4.9 20/23] RISC-V: include linux/ftrace.h in asm-prototypes.h Sasha Levin
2018-10-08 15:27 ` [PATCH AUTOSEL 4.9 21/23] powerpc/tm: Fix userspace r13 corruption Sasha Levin
2018-10-08 15:27 ` [PATCH AUTOSEL 4.9 22/23] powerpc/tm: Avoid possible userspace r1 corruption on reclaim Sasha Levin
2018-10-08 15:27 ` [PATCH AUTOSEL 4.9 23/23] iommu/amd: Return devid as alias for ACPI HID devices Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox