public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Sample fix for hyperthread exploit
@ 2005-06-01 11:58 Con Kolivas
  2005-06-01 12:06 ` Arjan van de Ven
  0 siblings, 1 reply; 8+ messages in thread
From: Con Kolivas @ 2005-06-01 11:58 UTC (permalink / raw)
  To: linux kernel mailing list, Ingo Molnar; +Cc: ck list

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

With respect to the recently publicised theoretical exploit for tasks running 
on hyperthread siblings, we already have in our hyperthreading code the 
ability to suspend running of tasks on siblings based on their behaviour. We 
could extend that if so desired as a plug for this theoretical exploit. We 
could suspend tasks that run on siblings based on their uid to prevent 
another user from being able to instrument cache misses from another user's 
task. Attached is a sample patch to do just that. It is my understanding that 
this exploit is not deemed significant risk anyway, and the attached solution 
would cost us in throughput if multiple users' tasks are running 
concurrently, but would still be better than disabling hyperthreading. This 
patch is more for discussion than inclusion, and is otherwise untested.

Comments?

Signed-off-by: Con Kolivas <kernel@kolivas.org>


[-- Attachment #2: dependent_sleep_on_uid.diff --]
[-- Type: text/x-diff, Size: 1012 bytes --]

Index: linux-2.6.12-rc5-uiddep/kernel/sched.c
===================================================================
--- linux-2.6.12-rc5-uiddep.orig/kernel/sched.c	2005-05-29 19:54:30.000000000 +1000
+++ linux-2.6.12-rc5-uiddep/kernel/sched.c	2005-06-01 21:46:54.000000000 +1000
@@ -2530,6 +2530,21 @@ static inline int dependent_sleeper(int 
 		task_t *smt_curr = smt_rq->curr;
 
 		/*
+		 * Don't let tasks from different users run on siblings that
+		 * share caches to avoid the security risk of cache misses.
+		 * If an equal priority task is already running let that one
+		 * continue, otherwise let only the better priority task run.
+		 */
+		if (p->uid != smt_curr->uid && p->mm && smt_curr->mm) {
+			if (smt_curr->prio <= p->prio) {
+				ret = 1;
+				continue;
+			}
+			resched_task(smt_curr);
+			continue;
+		}
+
+		/*
 		 * If a user task with lower static priority than the
 		 * running task on the SMT sibling is trying to schedule,
 		 * delay it till there is proportionately less timeslice

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

* Re: [PATCH] Sample fix for hyperthread exploit
  2005-06-01 11:58 [PATCH] Sample fix for hyperthread exploit Con Kolivas
@ 2005-06-01 12:06 ` Arjan van de Ven
  2005-06-01 12:13   ` Con Kolivas
  0 siblings, 1 reply; 8+ messages in thread
From: Arjan van de Ven @ 2005-06-01 12:06 UTC (permalink / raw)
  To: Con Kolivas; +Cc: linux kernel mailing list, Ingo Molnar, ck list


> Comments?

I don't think it's really worth it, but if you go this way I'd rather do
this via a prctl() so that apps can tell the kernel "I'd like to run
exclusive on a core". That'd be much better than blindly isolating all
applications.



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

* Re: [PATCH] Sample fix for hyperthread exploit
  2005-06-01 12:06 ` Arjan van de Ven
@ 2005-06-01 12:13   ` Con Kolivas
  2005-06-01 17:25     ` Chris Wright
  0 siblings, 1 reply; 8+ messages in thread
From: Con Kolivas @ 2005-06-01 12:13 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: linux kernel mailing list, Ingo Molnar, ck list

On Wed, 1 Jun 2005 22:06, Arjan van de Ven wrote:
> > Comments?
>
> I don't think it's really worth it, but if you go this way I'd rather do
> this via a prctl() so that apps can tell the kernel "I'd like to run
> exclusive on a core". That'd be much better than blindly isolating all
> applications.

I agree, and this is where we (could) implement the core isolation. I'm still 
under the impression (as you appear to be) that this theoretical exploit is 
not worth trying to work around.

Cheers,
Con

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

* Re: [PATCH] Sample fix for hyperthread exploit
  2005-06-01 12:13   ` Con Kolivas
@ 2005-06-01 17:25     ` Chris Wright
  2005-06-01 19:29       ` Arjan van de Ven
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Wright @ 2005-06-01 17:25 UTC (permalink / raw)
  To: Con Kolivas
  Cc: Arjan van de Ven, linux kernel mailing list, Ingo Molnar, ck list

* Con Kolivas (kernel@kolivas.org) wrote:
> On Wed, 1 Jun 2005 22:06, Arjan van de Ven wrote:
> > > Comments?
> >
> > I don't think it's really worth it, but if you go this way I'd rather do
> > this via a prctl() so that apps can tell the kernel "I'd like to run
> > exclusive on a core". That'd be much better than blindly isolating all
> > applications.
> 
> I agree, and this is where we (could) implement the core isolation. I'm still 
> under the impression (as you appear to be) that this theoretical exploit is 
> not worth trying to work around.

Also, uid is not sufficient.  Something more comprehensive (like ability
to ptrace) would be appropriate.

thanks,
-chris

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

* Re: [PATCH] Sample fix for hyperthread exploit
  2005-06-01 17:25     ` Chris Wright
@ 2005-06-01 19:29       ` Arjan van de Ven
  2005-06-02  2:49         ` Ingo Molnar
  0 siblings, 1 reply; 8+ messages in thread
From: Arjan van de Ven @ 2005-06-01 19:29 UTC (permalink / raw)
  To: Chris Wright; +Cc: Con Kolivas, linux kernel mailing list, Ingo Molnar, ck list

On Wed, 2005-06-01 at 10:25 -0700, Chris Wright wrote:
> * Con Kolivas (kernel@kolivas.org) wrote:
> > On Wed, 1 Jun 2005 22:06, Arjan van de Ven wrote:
> > > > Comments?
> > >
> > > I don't think it's really worth it, but if you go this way I'd rather do
> > > this via a prctl() so that apps can tell the kernel "I'd like to run
> > > exclusive on a core". That'd be much better than blindly isolating all
> > > applications.
> > 
> > I agree, and this is where we (could) implement the core isolation. I'm still 
> > under the impression (as you appear to be) that this theoretical exploit is 
> > not worth trying to work around.
> 
> Also, uid is not sufficient.  Something more comprehensive (like ability
> to ptrace) would be appropriate.

I would go a lot simpler. App says "I want exclusivity" via pctl and
NOTHING runs on the other half. Well maybe with exceptions of processes
that share the mm with the exclusive one (in practice "threads") since
those could just read the memory anyway.

ptrace-ability goes wonky the moment the "secret bearing" thread revokes
something that would make ptrace be denied consequently ... means we'd
have to find all those cases and make all of them bump the other app of
the cpu. smells too complex to me for such a rare event -> hard to get
fail proof.


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

* Re: [PATCH] Sample fix for hyperthread exploit
  2005-06-01 19:29       ` Arjan van de Ven
@ 2005-06-02  2:49         ` Ingo Molnar
  2005-06-02  2:57           ` Con Kolivas
  2005-06-02  6:28           ` Amit Shah
  0 siblings, 2 replies; 8+ messages in thread
From: Ingo Molnar @ 2005-06-02  2:49 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Chris Wright, Con Kolivas, linux kernel mailing list, ck list


* Arjan van de Ven <arjan@infradead.org> wrote:

> > Also, uid is not sufficient.  Something more comprehensive (like ability
> > to ptrace) would be appropriate.
> 
> I would go a lot simpler. App says "I want exclusivity" via pctl and 
> NOTHING runs on the other half. Well maybe with exceptions of 
> processes that share the mm with the exclusive one (in practice 
> "threads") since those could just read the memory anyway.

this has the disadvantage of needing changes in the security apps.  
Basing this off the uid (or the ability to ptrace) makes it at least 
automatic - but introduces a permanent penalty not only on multiuser 
boxes, but on basically any server box that runs multiple services.

	Ingo

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

* Re: [PATCH] Sample fix for hyperthread exploit
  2005-06-02  2:49         ` Ingo Molnar
@ 2005-06-02  2:57           ` Con Kolivas
  2005-06-02  6:28           ` Amit Shah
  1 sibling, 0 replies; 8+ messages in thread
From: Con Kolivas @ 2005-06-02  2:57 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Arjan van de Ven, Chris Wright, linux kernel mailing list,
	ck list

On Thu, 2 Jun 2005 12:49 pm, Ingo Molnar wrote:
> * Arjan van de Ven <arjan@infradead.org> wrote:
> > > Also, uid is not sufficient.  Something more comprehensive (like
> > > ability to ptrace) would be appropriate.
> >
> > I would go a lot simpler. App says "I want exclusivity" via pctl and
> > NOTHING runs on the other half. Well maybe with exceptions of
> > processes that share the mm with the exclusive one (in practice
> > "threads") since those could just read the memory anyway.
>
> this has the disadvantage of needing changes in the security apps.
> Basing this off the uid (or the ability to ptrace) makes it at least
> automatic - but introduces a permanent penalty not only on multiuser
> boxes, but on basically any server box that runs multiple services.

The performance penalty of the sample patch without extra communication or 
code would be substantial and I should make it clear to any onlookers that it 
is not recommended you use it in any real environment.

Cheers,
Con

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

* Re: [PATCH] Sample fix for hyperthread exploit
  2005-06-02  2:49         ` Ingo Molnar
  2005-06-02  2:57           ` Con Kolivas
@ 2005-06-02  6:28           ` Amit Shah
  1 sibling, 0 replies; 8+ messages in thread
From: Amit Shah @ 2005-06-02  6:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: ck

Ingo Molnar wrote:

> 
> * Arjan van de Ven <arjan@infradead.org> wrote:
> 
>> > Also, uid is not sufficient.  Something more comprehensive (like
>> > ability to ptrace) would be appropriate.
>> 
>> I would go a lot simpler. App says "I want exclusivity" via pctl and
>> NOTHING runs on the other half. Well maybe with exceptions of
>> processes that share the mm with the exclusive one (in practice
>> "threads") since those could just read the memory anyway.
> 
> this has the disadvantage of needing changes in the security apps.
> Basing this off the uid (or the ability to ptrace) makes it at least
> automatic - but introduces a permanent penalty not only on multiuser
> boxes, but on basically any server box that runs multiple services.

Can this be not limited to just not running any other process on the same
(SMT-enabled) processor (precondition being ability to ptrace)?

Amit.
-- 
Amit Shah
http://amitshah.net/


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

end of thread, other threads:[~2005-06-02  6:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-01 11:58 [PATCH] Sample fix for hyperthread exploit Con Kolivas
2005-06-01 12:06 ` Arjan van de Ven
2005-06-01 12:13   ` Con Kolivas
2005-06-01 17:25     ` Chris Wright
2005-06-01 19:29       ` Arjan van de Ven
2005-06-02  2:49         ` Ingo Molnar
2005-06-02  2:57           ` Con Kolivas
2005-06-02  6:28           ` Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox