From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Sasha Levin <sashal@kernel.org>,
linux-media@vger.kernel.org, devel@driverdev.osuosl.org
Subject: [PATCH AUTOSEL 4.9 19/26] cec-api: prevent leaking memory through hole in structure
Date: Fri, 21 Aug 2020 12:19:30 -0400 [thread overview]
Message-ID: <20200821161938.349246-19-sashal@kernel.org> (raw)
In-Reply-To: <20200821161938.349246-1-sashal@kernel.org>
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[ Upstream commit 6c42227c3467549ddc65efe99c869021d2f4a570 ]
Fix this smatch warning:
drivers/media/cec/core/cec-api.c:156 cec_adap_g_log_addrs() warn: check that 'log_addrs' doesn't leak information (struct has a hole after
'features')
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/staging/media/cec/cec-api.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/media/cec/cec-api.c b/drivers/staging/media/cec/cec-api.c
index e274e2f223986..264bb7d1efcb8 100644
--- a/drivers/staging/media/cec/cec-api.c
+++ b/drivers/staging/media/cec/cec-api.c
@@ -141,7 +141,13 @@ static long cec_adap_g_log_addrs(struct cec_adapter *adap,
struct cec_log_addrs log_addrs;
mutex_lock(&adap->lock);
- log_addrs = adap->log_addrs;
+ /*
+ * We use memcpy here instead of assignment since there is a
+ * hole at the end of struct cec_log_addrs that an assignment
+ * might ignore. So when we do copy_to_user() we could leak
+ * one byte of memory.
+ */
+ memcpy(&log_addrs, &adap->log_addrs, sizeof(log_addrs));
if (!adap->is_configured)
memset(log_addrs.log_addr, CEC_LOG_ADDR_INVALID,
sizeof(log_addrs.log_addr));
--
2.25.1
next prev parent reply other threads:[~2020-08-21 16:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 16:19 [PATCH AUTOSEL 4.9 01/26] ALSA: pci: delete repeated words in comments Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 02/26] ASoC: tegra: Fix reference count leaks Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 03/26] arm64: dts: qcom: msm8916: Pull down PDM GPIOs during sleep Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 04/26] media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq() Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 05/26] scsi: target: tcmu: Fix crash on ARM during cmd completion Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 06/26] iommu/iova: Don't BUG on invalid PFNs Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 07/26] drm/amdkfd: Fix reference count leaks Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 08/26] drm/radeon: fix multiple reference count leak Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 09/26] drm/amdgpu: fix ref count leak in amdgpu_driver_open_kms Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 10/26] drm/amd/display: fix ref count leak in amdgpu_drm_ioctl Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 11/26] drm/amdgpu: fix ref count leak in amdgpu_display_crtc_set_config Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 12/26] drm/amdgpu/display: fix ref count leak when pm_runtime_get_sync fails Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 13/26] scsi: lpfc: Fix shost refcount mismatch when deleting vport Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 14/26] selftests/powerpc: Purge extra count_pmc() calls of ebb selftests Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 15/26] omapfb: fix multiple reference count leaks due to pm_runtime_get_sync Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 16/26] PCI: Fix pci_create_slot() reference count leak Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 17/26] rtlwifi: rtl8192cu: Prevent leaking urb Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 18/26] mips/vdso: Fix resource leaks in genvdso.c Sasha Levin
2020-08-21 16:19 ` Sasha Levin [this message]
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 20/26] drm/nouveau/drm/noveau: fix reference count leak in nouveau_fbcon_open Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 21/26] drm/nouveau: Fix reference count leak in nouveau_connector_detect Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 22/26] locking/lockdep: Fix overflow in presentation of average lock-time Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 23/26] scsi: iscsi: Do not put host in iscsi_set_flashnode_param() Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 24/26] ceph: fix potential mdsc use-after-free crash Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 25/26] scsi: fcoe: Memory leak fix in fcoe_sysfs_fcf_del() Sasha Levin
2020-08-21 16:19 ` [PATCH AUTOSEL 4.9 26/26] EDAC/ie31200: Fallback if host bridge device is already initialized Sasha Levin
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=20200821161938.349246-19-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=stable@vger.kernel.org \
/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