* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 9:42 ` Manfred Spraul
@ 2001-08-20 20:03 ` Pavel Machek
0 siblings, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2001-08-20 20:03 UTC (permalink / raw)
To: Manfred Spraul; +Cc: David S. Miller, rusty, linux-kernel
Hi!
> > From: Manfred Spraul <manfred@colorfullife.com>
> > Date: Tue, 06 Aug 2002 11:17:33 +0200
> >
> > > - printk("No.\n");
> > > + printk("No (that's security hole).\n");
> > > #ifdef CONFIG_X86_WP_WORKS_OK
> >
> > Could you explain the hole?
> > WP works for user space apps, only ring0 (or ring 0-2?) code
> > ignores the WP bit on i386.
> >
> >So copy_to_user() could write to user areas that are write-proteced.
> >
> >verify_area() checks aren't enough, consider a threaded application
> >calling mprotect() while the copy is in progress.
> Then we should either fix copy_to_user(), or mark 80386 unsupported, or
> disable multi-threading on 80386. It's a random memory corruption, far
> worse than a security hole.
Fortunately app has to be seriously missbehaving for this to happen. Fixing
copy_to_user would be nicest; I do not think dropping 386 because of *this*
is good idea... [But it might force 386 users to fix copy_to_user ;-)]
Pavel
--
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:36 ` Manfred Spraul
@ 2001-08-20 20:06 ` Pavel Machek
2002-08-19 22:04 ` Alan Cox
2002-08-06 15:11 ` Kasper Dupont
` (2 subsequent siblings)
3 siblings, 1 reply; 16+ messages in thread
From: Pavel Machek @ 2001-08-20 20:06 UTC (permalink / raw)
To: Manfred Spraul; +Cc: Kasper Dupont, David S. Miller, rusty, linux-kernel
Hi!
> >I just get another idea, that might be easier to get right. If
> >the only problem is one process changing the mm while another
> >process is doing a copy_to_user, we should be able to fix it by
> >placing a readlock on the mm while the copy_to_user is in progress.
> >
> >
> Yes, that would work. copy_to_user is never called with the mmap
> semaphore locked, i.e.
>
> #define copy_to_user(...) > down(¤t->mm->mmap_sem); > check_wp_bit(); > real_copy_to_user(); > up(¤t->mm->mmap_sem)
>
> verify_area would just check that the pointer is below TASK_SIZE, and
> the wp bit is checked within copy_to_user().
>
> But how many 80386 Linux systems that run the 2.4 kernel exist?
Many embedded boxes, I beieve, have modern 386 CPUs.
Pavel
--
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [TRIVIAL] Warn users about machines with non-working WP bit
@ 2002-08-06 3:49 Rusty Trivial Russell
0 siblings, 0 replies; 16+ messages in thread
From: Rusty Trivial Russell @ 2002-08-06 3:49 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
[ Truth in advertising? ]
From: Pavel Machek <pavel@ucw.cz>
Hi!
This might be good idea, as those machines are not safe for multiuser
systems.
--- trivial-2.5.30/arch/i386/mm/init.c.orig 2002-08-06 13:18:12.000000000 +1000
+++ trivial-2.5.30/arch/i386/mm/init.c 2002-08-06 13:18:12.000000000 +1000
@@ -397,7 +397,7 @@
local_flush_tlb();
if (!boot_cpu_data.wp_works_ok) {
- printk("No.\n");
+ printk("No (that's security hole).\n");
#ifdef CONFIG_X86_WP_WORKS_OK
panic("This kernel doesn't support CPU's with broken WP. Recompile it for a 386!");
#endif
--
Don't blame me: the Monkey is driving
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
@ 2002-08-06 9:17 Manfred Spraul
2002-08-06 9:28 ` David S. Miller
0 siblings, 1 reply; 16+ messages in thread
From: Manfred Spraul @ 2002-08-06 9:17 UTC (permalink / raw)
To: Rusty Trivial Russell, linux-kernel
> - printk("No.\n");
> + printk("No (that's security hole).\n");
> #ifdef CONFIG_X86_WP_WORKS_OK
Could you explain the hole?
WP works for user space apps, only ring0 (or ring 0-2?) code ignores the WP bit on i386.
--
Manfred
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 9:17 [TRIVIAL] Warn users about machines with non-working WP bit Manfred Spraul
@ 2002-08-06 9:28 ` David S. Miller
2002-08-06 9:42 ` Manfred Spraul
2002-08-06 14:03 ` Kasper Dupont
0 siblings, 2 replies; 16+ messages in thread
From: David S. Miller @ 2002-08-06 9:28 UTC (permalink / raw)
To: manfred; +Cc: rusty, linux-kernel
From: Manfred Spraul <manfred@colorfullife.com>
Date: Tue, 06 Aug 2002 11:17:33 +0200
> - printk("No.\n");
> + printk("No (that's security hole).\n");
> #ifdef CONFIG_X86_WP_WORKS_OK
Could you explain the hole?
WP works for user space apps, only ring0 (or ring 0-2?) code
ignores the WP bit on i386.
So copy_to_user() could write to user areas that are write-proteced.
verify_area() checks aren't enough, consider a threaded application
calling mprotect() while the copy is in progress.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 9:28 ` David S. Miller
@ 2002-08-06 9:42 ` Manfred Spraul
2001-08-20 20:03 ` Pavel Machek
2002-08-06 14:03 ` Kasper Dupont
1 sibling, 1 reply; 16+ messages in thread
From: Manfred Spraul @ 2002-08-06 9:42 UTC (permalink / raw)
To: David S. Miller; +Cc: rusty, linux-kernel
David S. Miller wrote:
> From: Manfred Spraul <manfred@colorfullife.com>
> Date: Tue, 06 Aug 2002 11:17:33 +0200
>
> > - printk("No.\n");
> > + printk("No (that's security hole).\n");
> > #ifdef CONFIG_X86_WP_WORKS_OK
>
> Could you explain the hole?
> WP works for user space apps, only ring0 (or ring 0-2?) code
> ignores the WP bit on i386.
>
>So copy_to_user() could write to user areas that are write-proteced.
>
>verify_area() checks aren't enough, consider a threaded application
>calling mprotect() while the copy is in progress.
>
>
Then we should either fix copy_to_user(), or mark 80386 unsupported, or
disable multi-threading on 80386. It's a random memory corruption, far
worse than a security hole.
--
Manfred
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:03 ` Kasper Dupont
@ 2002-08-06 13:56 ` David S. Miller
2002-08-06 14:16 ` Kasper Dupont
0 siblings, 1 reply; 16+ messages in thread
From: David S. Miller @ 2002-08-06 13:56 UTC (permalink / raw)
To: kasperd; +Cc: manfred, rusty, linux-kernel
From: Kasper Dupont <kasperd@daimi.au.dk>
Date: Tue, 06 Aug 2002 16:03:34 +0200
"David S. Miller" wrote:
> verify_area() checks aren't enough, consider a threaded application
> calling mprotect() while the copy is in progress.
Couldn't we just freeze all other processes with the same mm while
a copy_to_user is in progress?
What if we have to sleep and page in some memory from disk?
Your idea could lead to deadlock in a multi-threaded app.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 9:28 ` David S. Miller
2002-08-06 9:42 ` Manfred Spraul
@ 2002-08-06 14:03 ` Kasper Dupont
2002-08-06 13:56 ` David S. Miller
1 sibling, 1 reply; 16+ messages in thread
From: Kasper Dupont @ 2002-08-06 14:03 UTC (permalink / raw)
To: David S. Miller; +Cc: manfred, rusty, linux-kernel
"David S. Miller" wrote:
>
> verify_area() checks aren't enough, consider a threaded application
> calling mprotect() while the copy is in progress.
Couldn't we just freeze all other processes with the same mm while
a copy_to_user is in progress?
Of course this should only be done if CONFIG_X86_WP_WORKS_OK is
not enabled, so systems with a working wp doesn't have to take a
performance hit.
--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:razrep@daimi.au.dk
or mailto:mcxumhvenwblvtl@skrammel.yaboo.dk
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:16 ` Kasper Dupont
@ 2002-08-06 14:05 ` David S. Miller
2002-08-06 14:27 ` Kasper Dupont
0 siblings, 1 reply; 16+ messages in thread
From: David S. Miller @ 2002-08-06 14:05 UTC (permalink / raw)
To: kasperd; +Cc: manfred, rusty, linux-kernel
From: Kasper Dupont <kasperd@daimi.au.dk>
Date: Tue, 06 Aug 2002 16:16:03 +0200
"David S. Miller" wrote:
> What if we have to sleep and page in some memory from disk?
>
> Your idea could lead to deadlock in a multi-threaded app.
Why? The page should eventually get into memory from the disk,
at this point the process doing the copy can continue, and
when it finishes the other processes gets waked up. While the
copy_to_user is in progress all the processes witht this mm
should be in noninterruptible sleep. The sleeping procces
doesn't need to do anything to get the page into memory, so I
cannot see the problem.
What if the other thread we freeze is holding a lock we
need in order to get the page from disk?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 13:56 ` David S. Miller
@ 2002-08-06 14:16 ` Kasper Dupont
2002-08-06 14:05 ` David S. Miller
0 siblings, 1 reply; 16+ messages in thread
From: Kasper Dupont @ 2002-08-06 14:16 UTC (permalink / raw)
To: David S. Miller; +Cc: manfred, rusty, linux-kernel
"David S. Miller" wrote:
>
> From: Kasper Dupont <kasperd@daimi.au.dk>
> Date: Tue, 06 Aug 2002 16:03:34 +0200
>
> "David S. Miller" wrote:
> > verify_area() checks aren't enough, consider a threaded application
> > calling mprotect() while the copy is in progress.
>
> Couldn't we just freeze all other processes with the same mm while
> a copy_to_user is in progress?
>
> What if we have to sleep and page in some memory from disk?
>
> Your idea could lead to deadlock in a multi-threaded app.
Why? The page should eventually get into memory from the disk,
at this point the process doing the copy can continue, and
when it finishes the other processes gets waked up. While the
copy_to_user is in progress all the processes witht this mm
should be in noninterruptible sleep. The sleeping procces
doesn't need to do anything to get the page into memory, so I
cannot see the problem.
--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:razrep@daimi.au.dk
or mailto:mcxumhvenwblvtl@skrammel.yaboo.dk
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:05 ` David S. Miller
@ 2002-08-06 14:27 ` Kasper Dupont
2002-08-06 14:36 ` Manfred Spraul
0 siblings, 1 reply; 16+ messages in thread
From: Kasper Dupont @ 2002-08-06 14:27 UTC (permalink / raw)
To: David S. Miller; +Cc: manfred, rusty, linux-kernel
"David S. Miller" wrote:
>
> From: Kasper Dupont <kasperd@daimi.au.dk>
> Date: Tue, 06 Aug 2002 16:16:03 +0200
>
> "David S. Miller" wrote:
> > What if we have to sleep and page in some memory from disk?
> >
> > Your idea could lead to deadlock in a multi-threaded app.
>
> Why? The page should eventually get into memory from the disk,
> at this point the process doing the copy can continue, and
> when it finishes the other processes gets waked up. While the
> copy_to_user is in progress all the processes witht this mm
> should be in noninterruptible sleep. The sleeping procces
> doesn't need to do anything to get the page into memory, so I
> cannot see the problem.
>
> What if the other thread we freeze is holding a lock we
> need in order to get the page from disk?
If the other thread is in user mode, that should not be possible.
If the other thread is in kernel mode, things starts getting
complicated. Maybe we could delay the freezing until the other
thread leaves kernel. I don't right away see if the current
thread has to wait for the other process to leave kernel and
get frozen.
I just get another idea, that might be easier to get right. If
the only problem is one process changing the mm while another
process is doing a copy_to_user, we should be able to fix it by
placing a readlock on the mm while the copy_to_user is in progress.
I don't remember if the mm is protected by a spinlock or
semaphore, if it is a spinlock maybe it could be replaced by a
semaphore? Otherwise we could prevent the copy_to_user from
completing if it has to sleep, and just release the lock if it
does go to sleep. In that case when the process gets waked up, it
has to get a special return value, that forces it to repeat the
verification of the area. (Isn't there a way to ensure the pages
are in memory before starting the actual copy, that would make
things simpler?)
--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:razrep@daimi.au.dk
or mailto:mcxumhvenwblvtl@skrammel.yaboo.dk
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:27 ` Kasper Dupont
@ 2002-08-06 14:36 ` Manfred Spraul
2001-08-20 20:06 ` Pavel Machek
` (3 more replies)
0 siblings, 4 replies; 16+ messages in thread
From: Manfred Spraul @ 2002-08-06 14:36 UTC (permalink / raw)
To: Kasper Dupont; +Cc: David S. Miller, rusty, linux-kernel
Kasper Dupont wrote:
>I just get another idea, that might be easier to get right. If
>the only problem is one process changing the mm while another
>process is doing a copy_to_user, we should be able to fix it by
>placing a readlock on the mm while the copy_to_user is in progress.
>
>
Yes, that would work. copy_to_user is never called with the mmap
semaphore locked, i.e.
#define copy_to_user(...) \
down(¤t->mm->mmap_sem); \
check_wp_bit(); \
real_copy_to_user(); \
up(¤t->mm->mmap_sem)
verify_area would just check that the pointer is below TASK_SIZE, and
the wp bit is checked within copy_to_user().
But how many 80386 Linux systems that run the 2.4 kernel exist?
--
Manfred
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:36 ` Manfred Spraul
2001-08-20 20:06 ` Pavel Machek
@ 2002-08-06 15:11 ` Kasper Dupont
2002-08-06 16:38 ` Willy Tarreau
2002-08-06 16:45 ` Zwane Mwaikambo
3 siblings, 0 replies; 16+ messages in thread
From: Kasper Dupont @ 2002-08-06 15:11 UTC (permalink / raw)
To: Manfred Spraul; +Cc: David S. Miller, rusty, linux-kernel
Manfred Spraul wrote:
>
> But how many 80386 Linux systems that run the 2.4 kernel exist?
I don't know. I don't have any myself.
--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:razrep@daimi.au.dk
or mailto:mcxumhvenwblvtl@skrammel.yaboo.dk
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:36 ` Manfred Spraul
2001-08-20 20:06 ` Pavel Machek
2002-08-06 15:11 ` Kasper Dupont
@ 2002-08-06 16:38 ` Willy Tarreau
2002-08-06 16:45 ` Zwane Mwaikambo
3 siblings, 0 replies; 16+ messages in thread
From: Willy Tarreau @ 2002-08-06 16:38 UTC (permalink / raw)
To: Manfred Spraul; +Cc: linux-kernel
On Tue, Aug 06, 2002 at 04:36:35PM +0200, Manfred Spraul wrote:
> But how many 80386 Linux systems that run the 2.4 kernel exist?
at least my ADSL router/firewall here :-)
It has the advantage of running really cool without *ANY* mechanical parts.
And for this exact reason, there may many others around the world.
Regards,
Willy
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2002-08-06 14:36 ` Manfred Spraul
` (2 preceding siblings ...)
2002-08-06 16:38 ` Willy Tarreau
@ 2002-08-06 16:45 ` Zwane Mwaikambo
3 siblings, 0 replies; 16+ messages in thread
From: Zwane Mwaikambo @ 2002-08-06 16:45 UTC (permalink / raw)
To: Manfred Spraul; +Cc: Kasper Dupont, David S. Miller, rusty, linux-kernel
On Tue, 6 Aug 2002, Manfred Spraul wrote:
> But how many 80386 Linux systems that run the 2.4 kernel exist?
http://function.linuxpower.ca/dmesg-386-2.4.txt
8)
--
function.linuxpower.ca
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [TRIVIAL] Warn users about machines with non-working WP bit
2001-08-20 20:06 ` Pavel Machek
@ 2002-08-19 22:04 ` Alan Cox
0 siblings, 0 replies; 16+ messages in thread
From: Alan Cox @ 2002-08-19 22:04 UTC (permalink / raw)
To: Pavel Machek
Cc: Manfred Spraul, Kasper Dupont, David S. Miller, rusty,
linux-kernel
On Mon, 2001-08-20 at 21:06, Pavel Machek wrote:
> > But how many 80386 Linux systems that run the 2.4 kernel exist?
>
> Many embedded boxes, I beieve, have modern 386 CPUs.
The 6117 is one example of that. Its a 386SX PC on a chip
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2002-08-19 22:00 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-06 9:17 [TRIVIAL] Warn users about machines with non-working WP bit Manfred Spraul
2002-08-06 9:28 ` David S. Miller
2002-08-06 9:42 ` Manfred Spraul
2001-08-20 20:03 ` Pavel Machek
2002-08-06 14:03 ` Kasper Dupont
2002-08-06 13:56 ` David S. Miller
2002-08-06 14:16 ` Kasper Dupont
2002-08-06 14:05 ` David S. Miller
2002-08-06 14:27 ` Kasper Dupont
2002-08-06 14:36 ` Manfred Spraul
2001-08-20 20:06 ` Pavel Machek
2002-08-19 22:04 ` Alan Cox
2002-08-06 15:11 ` Kasper Dupont
2002-08-06 16:38 ` Willy Tarreau
2002-08-06 16:45 ` Zwane Mwaikambo
-- strict thread matches above, loose matches on Subject: below --
2002-08-06 3:49 Rusty Trivial Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox