stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Zhang Shurong <zhang_shurong@foxmail.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15 043/110] media: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer
Date: Wed, 20 Sep 2023 13:31:41 +0200	[thread overview]
Message-ID: <20230920112831.979340204@linuxfoundation.org> (raw)
In-Reply-To: <20230920112830.377666128@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zhang Shurong <zhang_shurong@foxmail.com>

[ Upstream commit 7bf744f2de0a848fb1d717f5831b03db96feae89 ]

In af9035_i2c_master_xfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach af9035_i2c_master_xfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
[ moved variable declaration to fix build issues in older kernels - gregkh ]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/media/usb/dvb-usb-v2/af9035.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -270,6 +270,7 @@ static int af9035_i2c_master_xfer(struct
 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
 	struct state *state = d_to_priv(d);
 	int ret;
+	u32 reg;
 
 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
 		return -EAGAIN;
@@ -322,8 +323,10 @@ static int af9035_i2c_master_xfer(struct
 			ret = -EOPNOTSUPP;
 		} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
 			   (msg[0].addr == state->af9033_i2c_addr[1])) {
+			if (msg[0].len < 3 || msg[1].len < 1)
+				return -EOPNOTSUPP;
 			/* demod access via firmware interface */
-			u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
+			reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
 					msg[0].buf[2];
 
 			if (msg[0].addr == state->af9033_i2c_addr[1])
@@ -381,17 +384,16 @@ static int af9035_i2c_master_xfer(struct
 			ret = -EOPNOTSUPP;
 		} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
 			   (msg[0].addr == state->af9033_i2c_addr[1])) {
+			if (msg[0].len < 3)
+				return -EOPNOTSUPP;
 			/* demod access via firmware interface */
-			u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
+			reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
 					msg[0].buf[2];
 
 			if (msg[0].addr == state->af9033_i2c_addr[1])
 				reg |= 0x100000;
 
-			ret = (msg[0].len >= 3) ? af9035_wr_regs(d, reg,
-							         &msg[0].buf[3],
-							         msg[0].len - 3)
-					        : -EOPNOTSUPP;
+			ret = af9035_wr_regs(d, reg, &msg[0].buf[3], msg[0].len - 3);
 		} else {
 			/* I2C write */
 			u8 buf[MAX_XFER_SIZE];



  parent reply	other threads:[~2023-09-20 12:45 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 11:30 [PATCH 5.15 000/110] 5.15.133-rc1 review Greg Kroah-Hartman
2023-09-20 11:30 ` [PATCH 5.15 001/110] autofs: fix memory leak of waitqueues in autofs_catatonic_mode Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 002/110] btrfs: output extra debug info if we failed to find an inline backref Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 003/110] locks: fix KASAN: use-after-free in trace_event_raw_event_filelock_lock Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 004/110] ACPICA: Add AML_NO_OPERAND_RESOLVE flag to Timer Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 005/110] kernel/fork: beware of __put_task_struct() calling context Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 006/110] rcuscale: Move rcu_scale_writer() schedule_timeout_uninterruptible() to _idle() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 007/110] scftorture: Forgive memory-allocation failure if KASAN Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 008/110] ACPI: video: Add backlight=native DMI quirk for Lenovo Ideapad Z470 Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 009/110] perf/smmuv3: Enable HiSilicon Erratum 162001900 quirk for HIP08/09 Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 010/110] perf/imx_ddr: speed up overflow frequency of cycle Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 011/110] hw_breakpoint: fix single-stepping when using bpf_overflow_handler Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 012/110] ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 013/110] devlink: remove reload failed checks in params get/set callbacks Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 014/110] crypto: lrw,xts - Replace strlcpy with strscpy Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 015/110] wifi: ath9k: fix fortify warnings Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 016/110] wifi: ath9k: fix printk specifier Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 017/110] wifi: mwifiex: fix fortify warning Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 018/110] wifi: wil6210: fix fortify warnings Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 019/110] crypto: lib/mpi - avoid null pointer deref in mpi_cmp_ui() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 020/110] tpm_tis: Resend command to recover from data transfer errors Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 021/110] mmc: sdhci-esdhc-imx: improve ESDHC_FLAG_ERR010450 Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 022/110] alx: fix OOB-read compiler warning Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 023/110] wifi: mac80211: check S1G action frame size Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 024/110] netfilter: ebtables: fix fortify warnings in size_entry_mwt() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 025/110] wifi: mac80211_hwsim: drop short frames Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 026/110] libbpf: Free btf_vmlinux when closing bpf_object Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 027/110] drm/bridge: tc358762: Instruct DSI host to generate HSE packets Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 028/110] arm64: dts: qcom: sm6125-pdx201: correct ramoops pmsg-size Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 029/110] arm64: dts: qcom: sm8150-kumano: " Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 030/110] arm64: dts: qcom: sm8250-edo: " Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 031/110] samples/hw_breakpoint: Fix kernel BUG invalid opcode: 0000 Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 032/110] ALSA: hda: intel-dsp-cfg: add LunarLake support Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 033/110] drm/amd/display: Blocking invalid 420 modes on HDMI TMDS for DCN31 Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 034/110] drm/exynos: fix a possible null-pointer dereference due to data race in exynos_drm_crtc_atomic_disable() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 035/110] bus: ti-sysc: Configure uart quirks for k3 SoC Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 036/110] md: raid1: fix potential OOB in raid1_remove_disk() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 037/110] ext2: fix datatype of block number in ext2_xattr_set2() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 038/110] fs/jfs: prevent double-free in dbUnmount() after failed jfs_remount() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 039/110] jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 040/110] ARM: 9317/1: kexec: Make smp stop calls asynchronous Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 041/110] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 042/110] PCI: fu740: Set the number of MSI vectors Greg Kroah-Hartman
2023-09-20 11:31 ` Greg Kroah-Hartman [this message]
2023-09-20 11:31 ` [PATCH 5.15 044/110] media: dw2102: Fix null-ptr-deref in dw2102_i2c_transfer() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 045/110] media: af9005: Fix null-ptr-deref in af9005_i2c_xfer Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 046/110] media: anysee: fix null-ptr-deref in anysee_master_xfer Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 047/110] media: az6007: Fix null-ptr-deref in az6007_i2c_xfer() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 048/110] media: dvb-usb-v2: gl861: Fix null-ptr-deref in gl861_i2c_master_xfer Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 049/110] media: tuners: qt1010: replace BUG_ON with a regular error Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 050/110] media: pci: cx23885: replace BUG with error return Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 051/110] usb: cdns3: Put the cdns set active part outside the spin lock Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 052/110] usb: gadget: fsl_qe_udc: validate endpoint index for ch9 udc Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 053/110] tools: iio: iio_generic_buffer: Fix some integer type and calculation Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 054/110] scsi: target: iscsi: Fix buffer overflow in lio_target_nacl_info_show() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 055/110] serial: cpm_uart: Avoid suspicious locking Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 056/110] usb: ehci: add workaround for chipidea PORTSC.PEC bug Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 057/110] media: pci: ipu3-cio2: Initialise timing struct to avoid a compiler warning Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 058/110] kobject: Add sanity check for kset->kobj.ktype in kset_register() Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 059/110] interconnect: Fix locking for runpm vs reclaim Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 060/110] printk: Consolidate console deferred printing Greg Kroah-Hartman
2023-09-20 11:31 ` [PATCH 5.15 061/110] jbd2: refactor wait logic for transaction updates into a common function Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 062/110] jbd2: fix use-after-free of transaction_t race Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 063/110] jbd2: kill t_handle_lock transaction spinlock Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 064/110] jbd2: rename jbd_debug() to jbd2_debug() Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 065/110] jbd2: correct the end of the journal recovery scan range Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 066/110] mtd: rawnand: brcmnand: Allow SoC to provide I/O operations Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 067/110] mtd: rawnand: brcmnand: Fix ECC level field setting for v7.2 controller Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 068/110] MIPS: Use "grep -E" instead of "egrep" Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 069/110] perf jevents: Switch build to use jevents.py Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 070/110] perf build: Update build rule for generated files Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 071/110] perf test: Remove bash construct from stat_bpf_counters.sh test Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 072/110] perf test shell stat_bpf_counters: Fix test on Intel Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 073/110] btrfs: move btrfs_pinned_by_swapfile prototype into volumes.h Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 074/110] btrfs: add a helper to read the superblock metadata_uuid Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 075/110] btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 076/110] drm: gm12u320: Fix the timeout usage for usb_bulk_msg() Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 077/110] scsi: qla2xxx: Fix NULL vs IS_ERR() bug for debugfs_create_dir() Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 078/110] selftests: tracing: Fix to unmount tracefs for recovering environment Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 079/110] scsi: lpfc: Fix the NULL vs IS_ERR() bug for debugfs_create_file() Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 080/110] x86/boot/compressed: Reserve more memory for page tables Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 081/110] x86/purgatory: Remove LTO flags Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 082/110] netfilter: nf_tables: make validation state per table Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 083/110] netfilter: nf_tables: GC transaction API to avoid race with control plane Greg Kroah-Hartman
2023-09-20 14:02   ` Pablo Neira Ayuso
2023-09-21  9:28     ` Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 084/110] netfilter: nf_tables: adapt set backend to use GC transaction API Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 085/110] netfilter: nft_set_hash: mark set element as dead when deleting from packet path Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 086/110] netfilter: nf_tables: remove busy mark and gc batch API Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 087/110] netfilter: nf_tables: fix kdoc warnings after gc rework Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 088/110] netfilter: nf_tables: fix GC transaction races with netns and netlink event exit path Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 089/110] netfilter: nf_tables: GC transaction race with netns dismantle Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 090/110] samples/hw_breakpoint: fix building without module unloading Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 091/110] md/raid1: fix error: ISO C90 forbids mixed declarations Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 092/110] attr: block mode changes of symlinks Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 093/110] ovl: fix failed copyup of fileattr on a symlink Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 094/110] ovl: fix incorrect fdput() on aio completion Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 095/110] btrfs: fix lockdep splat and potential deadlock after failure running delayed items Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 096/110] btrfs: release path before inode lookup during the ino lookup ioctl Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 097/110] tracing: Have tracing_max_latency inc the trace array ref count Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 098/110] tracing: Have current_trace " Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 099/110] tracing: Have option files " Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 100/110] nfsd: fix change_info in NFSv4 RENAME replies Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 101/110] tracefs: Add missing lockdown check to tracefs_create_dir() Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 102/110] i2c: aspeed: Reset the i2c controller when timeout occurs Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 103/110] ata: libata: disallow dev-initiated LPM transitions to unsupported states Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 104/110] scsi: megaraid_sas: Fix deadlock on firmware crashdump Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 105/110] scsi: pm8001: Setup IRQs on resume Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 106/110] ext4: fix rec_len verify error Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 107/110] drm/amd/display: fix the white screen issue when >= 64GB DRAM Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 108/110] drm/amdgpu: fix amdgpu_cs_p1_user_fence Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 109/110] net/sched: Retire rsvp classifier Greg Kroah-Hartman
2023-09-20 11:32 ` [PATCH 5.15 110/110] drm/amd/display: enable cursor degamma for DCN3+ DRM legacy gamma Greg Kroah-Hartman
2023-09-20 14:21 ` [PATCH 5.15 000/110] 5.15.133-rc1 review SeongJae Park
2023-09-20 18:47 ` Florian Fainelli
2023-09-23  8:21   ` Greg Kroah-Hartman
2023-09-20 21:34 ` Shuah Khan
2023-09-21 12:25 ` Guenter Roeck
2023-09-21 13:55 ` Naresh Kamboju
2023-09-21 16:01 ` Guenter Roeck
2023-09-21 20:38 ` Joel Fernandes
2023-09-21 22:05 ` Ron Economos
2023-09-22  9:19 ` Jon Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230920112831.979340204@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zhang_shurong@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).