* [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver()
@ 2023-11-27 18:37 Hagar Gamal Halim Hemdan
2023-11-27 18:47 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Hagar Gamal Halim Hemdan @ 2023-11-27 18:37 UTC (permalink / raw)
Cc: stable
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>
---
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 2100297c94ad..a1205bce0b7e 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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver()
2023-11-27 18:37 [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver() Hagar Gamal Halim Hemdan
@ 2023-11-27 18:47 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2023-11-27 18:47 UTC (permalink / raw)
To: Hagar Gamal Halim Hemdan; +Cc: stable
On Mon, Nov 27, 2023 at 06:37:45PM +0000, Hagar Gamal Halim Hemdan wrote:
> 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>
> ---
> drivers/misc/vmw_vmci/vmci_event.c | 6 +++++-
: 1 file changed, 5 insertions(+), 1 deletion(-)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver()
@ 2023-11-27 19:35 Hagar Gamal Halim Hemdan
2023-11-27 19:41 ` kernel test robot
0 siblings, 1 reply; 6+ messages in thread
From: Hagar Gamal Halim Hemdan @ 2023-11-27 19:35 UTC (permalink / raw)
Cc: stable, Hagar Gamal Halim Hemdan, Bryan Tan, Vishnu Dasa,
VMware PV-Drivers Reviewers, Arnd Bergmann, Greg Kroah-Hartman,
Dmitry Torokhov, George Zhang, Andy king, linux-kernel
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>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver()
2023-11-27 19:35 Hagar Gamal Halim Hemdan
@ 2023-11-27 19:41 ` kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2023-11-27 19:41 UTC (permalink / raw)
To: Hagar Gamal Halim Hemdan; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver()
Link: https://lore.kernel.org/stable/20231127193533.46174-1-hagarhem%40amazon.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver()
@ 2023-11-27 19:48 Hagar Gamal Halim Hemdan
2023-11-28 8:09 ` Greg Kroah-Hartman
0 siblings, 1 reply; 6+ messages in thread
From: Hagar Gamal Halim Hemdan @ 2023-11-27 19:48 UTC (permalink / raw)
Cc: stable, Hagar Gamal Halim Hemdan, Bryan Tan, Vishnu Dasa,
VMware PV-Drivers Reviewers, Arnd Bergmann, Greg Kroah-Hartman,
Dmitry Torokhov, George Zhang, Andy king, linux-kernel
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver()
2023-11-27 19:48 Hagar Gamal Halim Hemdan
@ 2023-11-28 8:09 ` Greg Kroah-Hartman
0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2023-11-28 8:09 UTC (permalink / raw)
To: Hagar Gamal Halim Hemdan
Cc: stable, Bryan Tan, Vishnu Dasa, VMware PV-Drivers Reviewers,
Arnd Bergmann, Dmitry Torokhov, George Zhang, Andy king,
linux-kernel
On Mon, Nov 27, 2023 at 07:48:17PM +0000, Hagar Gamal Halim Hemdan wrote:
> 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
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/process/submitting-patches.rst for what
needs to be done here to properly describe this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-28 8:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-27 18:37 [PATCH] vmci: prevent speculation leaks by sanitizing event in event_deliver() Hagar Gamal Halim Hemdan
2023-11-27 18:47 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2023-11-27 19:35 Hagar Gamal Halim Hemdan
2023-11-27 19:41 ` kernel test robot
2023-11-27 19:48 Hagar Gamal Halim Hemdan
2023-11-28 8:09 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox