From: Hagar Gamal Halim Hemdan <hagarhem@amazon.com>
Cc: Maximilian Heyne <mheyne@amazon.de>,
Norbert Manthey <nmanthey@amazon.de>,
Hagar Gamal Halim Hemdan <hagarhem@amazon.com>,
<stable@vger.kernel.org>, Bryan Tan <bryantan@vmware.com>,
Vishnu Dasa <vdasa@vmware.com>,
"VMware PV-Drivers Reviewers" <pv-drivers@vmware.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dmitry Torokhov <dtor@vmware.com>,
George Zhang <georgezhang@vmware.com>,
Andy king <acking@vmware.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] vmci: prevent speculation leaks by sanitizing event in event_deliver()
Date: Tue, 28 Nov 2023 08:36:58 +0000 [thread overview]
Message-ID: <20231128083658.23960-1-hagarhem@amazon.com> (raw)
Coverity spotted that event_msg is controlled by user-space,
event_msg->event_data.event is passed to event_deliver() and used
as an index without sanitization.
This change ensures that the event index is sanitized to mitigate any
possibility of speculative information leaks.
Fixes: 1d990201f9bb ("VMCI: event handling implementation.")
Signed-off-by: Hagar Gamal Halim Hemdan <hagarhem@amazon.com>
Cc: stable@vger.kernel.org
---
drivers/misc/vmw_vmci/vmci_event.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/vmw_vmci/vmci_event.c b/drivers/misc/vmw_vmci/vmci_event.c
index 5d7ac07623c2..9a41ab65378d 100644
--- a/drivers/misc/vmw_vmci/vmci_event.c
+++ b/drivers/misc/vmw_vmci/vmci_event.c
@@ -9,6 +9,7 @@
#include <linux/vmw_vmci_api.h>
#include <linux/list.h>
#include <linux/module.h>
+#include <linux/nospec.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/rculist.h>
@@ -86,9 +87,12 @@ static void event_deliver(struct vmci_event_msg *event_msg)
{
struct vmci_subscription *cur;
struct list_head *subscriber_list;
+ u32 sanitized_event, max_vmci_event;
rcu_read_lock();
- subscriber_list = &subscriber_array[event_msg->event_data.event];
+ max_vmci_event = ARRAY_SIZE(subscriber_array);
+ sanitized_event = array_index_nospec(event_msg->event_data.event, max_vmci_event);
+ subscriber_list = &subscriber_array[sanitized_event];
list_for_each_entry_rcu(cur, subscriber_list, node) {
cur->callback(cur->id, &event_msg->event_data,
cur->callback_data);
--
2.40.1
WARNING: multiple messages have this Message-ID (diff)
From: Hagar Gamal Halim Hemdan <hagarhem@amazon.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Maximilian Heyne <mheyne@amazon.de>,
Norbert Manthey <nmanthey@amazon.de>,
Hagar Gamal Halim Hemdan <hagarhem@amazon.com>,
<stable@vger.kernel.org>, Bryan Tan <bryantan@vmware.com>,
Vishnu Dasa <vdasa@vmware.com>,
"VMware PV-Drivers Reviewers" <pv-drivers@vmware.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dmitry Torokhov <dtor@vmware.com>,
George Zhang <georgezhang@vmware.com>,
Andy king <acking@vmware.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] vmci: prevent speculation leaks by sanitizing event in event_deliver()
Date: Tue, 28 Nov 2023 08:36:58 +0000 [thread overview]
Message-ID: <20231128083658.23960-1-hagarhem@amazon.com> (raw)
Coverity spotted that event_msg is controlled by user-space,
event_msg->event_data.event is passed to event_deliver() and used
as an index without sanitization.
This change ensures that the event index is sanitized to mitigate any
possibility of speculative information leaks.
Fixes: 1d990201f9bb ("VMCI: event handling implementation.")
Signed-off-by: Hagar Gamal Halim Hemdan <hagarhem@amazon.com>
Cc: stable@vger.kernel.org
---
drivers/misc/vmw_vmci/vmci_event.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/vmw_vmci/vmci_event.c b/drivers/misc/vmw_vmci/vmci_event.c
index 5d7ac07623c2..9a41ab65378d 100644
--- a/drivers/misc/vmw_vmci/vmci_event.c
+++ b/drivers/misc/vmw_vmci/vmci_event.c
@@ -9,6 +9,7 @@
#include <linux/vmw_vmci_api.h>
#include <linux/list.h>
#include <linux/module.h>
+#include <linux/nospec.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/rculist.h>
@@ -86,9 +87,12 @@ static void event_deliver(struct vmci_event_msg *event_msg)
{
struct vmci_subscription *cur;
struct list_head *subscriber_list;
+ u32 sanitized_event, max_vmci_event;
rcu_read_lock();
- subscriber_list = &subscriber_array[event_msg->event_data.event];
+ max_vmci_event = ARRAY_SIZE(subscriber_array);
+ sanitized_event = array_index_nospec(event_msg->event_data.event, max_vmci_event);
+ subscriber_list = &subscriber_array[sanitized_event];
list_for_each_entry_rcu(cur, subscriber_list, node) {
cur->callback(cur->id, &event_msg->event_data,
cur->callback_data);
--
2.40.1
next reply other threads:[~2023-11-28 8:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 8:36 Hagar Gamal Halim Hemdan [this message]
2023-11-28 8:36 ` [PATCH v2] vmci: prevent speculation leaks by sanitizing event in event_deliver() Hagar Gamal Halim Hemdan
2023-11-28 8:45 ` Greg Kroah-Hartman
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=20231128083658.23960-1-hagarhem@amazon.com \
--to=hagarhem@amazon.com \
--cc=acking@vmware.com \
--cc=arnd@arndb.de \
--cc=bryantan@vmware.com \
--cc=dtor@vmware.com \
--cc=georgezhang@vmware.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mheyne@amazon.de \
--cc=nmanthey@amazon.de \
--cc=pv-drivers@vmware.com \
--cc=stable@vger.kernel.org \
--cc=vdasa@vmware.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.