All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] check_spectre: Add a switch to optionally use host data
@ 2022-05-16  8:55 Elena Reshetova
  2022-05-16 12:54 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Elena Reshetova @ 2022-05-16  8:55 UTC (permalink / raw)
  To: smatch; +Cc: dan.carpenter, Elena Reshetova

check_spectre pattern can utilize smatch_kernel_host_data.c
to optionally search for potential spectre v1 gadgets in the
untrusted input provided for the host/VMM <-> VM guest attack
surface. This attack surface is important for confidential
cloud computing technologies where a VM guest does not trust
the host/VMM.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
---
 check_spectre.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/check_spectre.c b/check_spectre.c
index 16301a2e..009c7f0b 100644
--- a/check_spectre.c
+++ b/check_spectre.c
@@ -22,7 +22,13 @@ static int my_id;
 extern int second_half_id;
 extern void set_spectre_first_half(struct expression *expr);
 
+enum kernel_data_types {
+	USER_DATA_TYPE = 0,
+	HOST_DATA_TYPE = 1,
+};
+
 static int suppress_multiple = 1;
+static int analyzed_data_type = USER_DATA_TYPE;
 
 static int is_write(struct expression *expr)
 {
@@ -173,8 +179,19 @@ static void array_check(struct expression *expr)
 	}
 
 	offset = get_array_offset(expr);
-	if (!is_user_rl(offset))
-		return;
+	switch(analyzed_data_type) {
+		case USER_DATA_TYPE:
+			if (!is_user_rl(offset))
+				return;
+			break;
+		case HOST_DATA_TYPE:
+			if (!is_host_rl(offset))
+				return;
+			break;
+		default:
+			return;
+	}
+
 	if (is_nospec(offset))
 		return;
 
@@ -208,6 +225,8 @@ void check_spectre(int id)
 	my_id = id;
 
 	suppress_multiple = getenv("FULL_SPECTRE") == NULL;
+	if (getenv("ANALYZE_HOST_DATA"))
+		analyzed_data_type = HOST_DATA_TYPE;
 
 	if (option_project != PROJ_KERNEL)
 		return;
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] check_spectre: Add a switch to optionally use host data
  2022-05-16  8:55 [PATCH] check_spectre: Add a switch to optionally use host data Elena Reshetova
@ 2022-05-16 12:54 ` Dan Carpenter
  2022-05-16 13:39   ` Reshetova, Elena
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2022-05-16 12:54 UTC (permalink / raw)
  To: Elena Reshetova; +Cc: smatch

Fantastic.  Thanks!  I've applied both.  I'll test them out tonight
and push later.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] check_spectre: Add a switch to optionally use host data
  2022-05-16 12:54 ` Dan Carpenter
@ 2022-05-16 13:39   ` Reshetova, Elena
  2022-05-17 18:40     ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Reshetova, Elena @ 2022-05-16 13:39 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch@vger.kernel.org

> Fantastic.  Thanks!  I've applied both.  I'll test them out tonight
> and push later.
> 
> regards,
> dan carpenter

Thank you very much Dan!
Let me know if any issues: I have run my tests as usual.

Best Regards,
Elena


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] check_spectre: Add a switch to optionally use host data
  2022-05-16 13:39   ` Reshetova, Elena
@ 2022-05-17 18:40     ` Dan Carpenter
  2022-05-17 18:43       ` Reshetova, Elena
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2022-05-17 18:40 UTC (permalink / raw)
  To: Reshetova, Elena; +Cc: smatch@vger.kernel.org

On Mon, May 16, 2022 at 01:39:49PM +0000, Reshetova, Elena wrote:
> > Fantastic.  Thanks!  I've applied both.  I'll test them out tonight
> > and push later.
> > 
> > regards,
> > dan carpenter
> 
> Thank you very much Dan!
> Let me know if any issues: I have run my tests as usual.

Hey Elena,

It looks good.  I pushed this out now.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] check_spectre: Add a switch to optionally use host data
  2022-05-17 18:40     ` Dan Carpenter
@ 2022-05-17 18:43       ` Reshetova, Elena
  0 siblings, 0 replies; 5+ messages in thread
From: Reshetova, Elena @ 2022-05-17 18:43 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch@vger.kernel.org

> On Mon, May 16, 2022 at 01:39:49PM +0000, Reshetova, Elena wrote:
> > > Fantastic.  Thanks!  I've applied both.  I'll test them out tonight
> > > and push later.
> > >
> > > regards,
> > > dan carpenter
> >
> > Thank you very much Dan!
> > Let me know if any issues: I have run my tests as usual.
> 
> Hey Elena,
> 
> It looks good.  I pushed this out now.

Thank you very much Dan!

Best Regards,
Elena

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-17 18:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-16  8:55 [PATCH] check_spectre: Add a switch to optionally use host data Elena Reshetova
2022-05-16 12:54 ` Dan Carpenter
2022-05-16 13:39   ` Reshetova, Elena
2022-05-17 18:40     ` Dan Carpenter
2022-05-17 18:43       ` Reshetova, Elena

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.