public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kasper Dupont <kasperd@daimi.au.dk>
To: "David S. Miller" <davem@redhat.com>
Cc: manfred@colorfullife.com, rusty@rustcorp.com.au,
	linux-kernel@vger.kernel.org
Subject: Re: [TRIVIAL] Warn users about machines with non-working WP bit
Date: Tue, 06 Aug 2002 16:27:39 +0200	[thread overview]
Message-ID: <3D4FDCDB.744EE7C9@daimi.au.dk> (raw)
In-Reply-To: 20020806.070535.24871584.davem@redhat.com

"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

  reply	other threads:[~2002-08-06 14:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=3D4FDCDB.744EE7C9@daimi.au.dk \
    --to=kasperd@daimi.au.dk \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=rusty@rustcorp.com.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox