From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Ofir Bitton <obitton@habana.ai>, Oded Gabbay <ogabbay@kernel.org>,
Sasha Levin <sashal@kernel.org>,
Arnd@vger.kernel.org, gregkh@linuxfoundation.org,
osharabi@habana.ai, kelbaz@habana.ai, ttayar@habana.ai,
ynudelman@habana.ai, fkassabri@habana.ai, amizrahi@habana.ai,
bjauhari@habana.ai
Subject: [PATCH AUTOSEL 5.14 07/21] habanalabs: add validity check for event ID received from F/W
Date: Thu, 16 Sep 2021 22:33:01 -0400 [thread overview]
Message-ID: <20210917023315.816225-7-sashal@kernel.org> (raw)
In-Reply-To: <20210917023315.816225-1-sashal@kernel.org>
From: Ofir Bitton <obitton@habana.ai>
[ Upstream commit a6c849012b0f51c674f52384bd9a4f3dc0a33c31 ]
Currently there is no validity check for event ID received from F/W,
Thus exposing driver to memory overrun.
Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/misc/habanalabs/gaudi/gaudi.c | 6 ++++++
drivers/misc/habanalabs/goya/goya.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
index aa8a0ca5aca2..409f05c962f2 100644
--- a/drivers/misc/habanalabs/gaudi/gaudi.c
+++ b/drivers/misc/habanalabs/gaudi/gaudi.c
@@ -7809,6 +7809,12 @@ static void gaudi_handle_eqe(struct hl_device *hdev,
u8 cause;
bool reset_required;
+ if (event_type >= GAUDI_EVENT_SIZE) {
+ dev_err(hdev->dev, "Event type %u exceeds maximum of %u",
+ event_type, GAUDI_EVENT_SIZE - 1);
+ return;
+ }
+
gaudi->events_stat[event_type]++;
gaudi->events_stat_aggregate[event_type]++;
diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
index 755e08cf2ecc..bfb22f96c1a3 100644
--- a/drivers/misc/habanalabs/goya/goya.c
+++ b/drivers/misc/habanalabs/goya/goya.c
@@ -4797,6 +4797,12 @@ void goya_handle_eqe(struct hl_device *hdev, struct hl_eq_entry *eq_entry)
>> EQ_CTL_EVENT_TYPE_SHIFT);
struct goya_device *goya = hdev->asic_specific;
+ if (event_type >= GOYA_ASYNC_EVENT_ID_SIZE) {
+ dev_err(hdev->dev, "Event type %u exceeds maximum of %u",
+ event_type, GOYA_ASYNC_EVENT_ID_SIZE - 1);
+ return;
+ }
+
goya->events_stat[event_type]++;
goya->events_stat_aggregate[event_type]++;
--
2.30.2
next prev parent reply other threads:[~2021-09-17 2:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-17 2:32 [PATCH AUTOSEL 5.14 01/21] thermal/drivers/rcar_gen3_thermal: Store TSC id as unsigned int Sasha Levin
2021-09-17 2:32 ` [PATCH AUTOSEL 5.14 02/21] habanalabs: fix nullifying of destroyed mmu pgt pool Sasha Levin
2021-09-17 2:32 ` [PATCH AUTOSEL 5.14 03/21] habanalabs: fix race between soft reset and heartbeat Sasha Levin
2021-09-17 2:32 ` [PATCH AUTOSEL 5.14 04/21] drm/amdgpu: Fixes to returning VBIOS RAS EEPROM address Sasha Levin
2021-09-17 2:32 ` [PATCH AUTOSEL 5.14 05/21] drm/amd/display: Fix memory leak reported by coverity Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 06/21] drm/amdgpu: fix fdinfo race with process exit Sasha Levin
2021-09-17 2:33 ` Sasha Levin [this message]
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 08/21] habanalabs: fix mmu node address resolution in debugfs Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 09/21] habanalabs: add "in device creation" status Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 10/21] habanalabs: cannot sleep while holding spinlock Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 11/21] pwm: img: Don't modify HW state in .remove() callback Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 12/21] pwm: rockchip: " Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 13/21] pwm: stm32-lp: " Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 14/21] nvmet: fixup buffer overrun in nvmet_subsys_attr_serial() Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 15/21] block: genhd: don't call blkdev_show() with major_names_lock held Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 16/21] blk-throttle: fix UAF by deleteing timer in blk_throtl_exit() Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 17/21] blk-mq: allow 4x BLK_MAX_REQUEST_COUNT at blk_plug for multiple_queues Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 18/21] rtc: rx8010: select REGMAP_I2C Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 19/21] sched/idle: Make the idle timer expire in hard interrupt context Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 20/21] cifs: properly invalidate cached root handle when closing it Sasha Levin
2021-09-17 2:33 ` [PATCH AUTOSEL 5.14 21/21] io_uring: fix off-by-one in BUILD_BUG_ON check of __REQ_F_LAST_BIT 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=20210917023315.816225-7-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Arnd@vger.kernel.org \
--cc=amizrahi@habana.ai \
--cc=bjauhari@habana.ai \
--cc=fkassabri@habana.ai \
--cc=gregkh@linuxfoundation.org \
--cc=kelbaz@habana.ai \
--cc=linux-kernel@vger.kernel.org \
--cc=obitton@habana.ai \
--cc=ogabbay@kernel.org \
--cc=osharabi@habana.ai \
--cc=stable@vger.kernel.org \
--cc=ttayar@habana.ai \
--cc=ynudelman@habana.ai \
/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
all inboxes | Powered by JetHome®