public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: BAIN <bainonline@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: set_fs() preemption safety? [was sys_fs() safety oops !]
Date: Sun, 4 Jul 2004 10:36:00 -0400	[thread overview]
Message-ID: <2ff21628040704073632ffa1c9@mail.gmail.com> (raw)

is the following block safe to be used in preemptible kernels?

old_fs = get_fs();
set_fs(KERNEL_DS);

do_your_things here; (usually call sys calls stuff from kernel space)

set_fs(old_fs);

i will explain my doubt further,
in nonpreempt kernels this changes the fs segment only on current cpu
and is restored before other code is run on that cpu, you are strictly
_not_ suppose to call schedule without restoring fs first.

but what about when preempt is enabled

even if i don't call schedule other code might start running on this
current cpu without me restoring the fs first?

this code block appears in many places.. even in 2.6 kernels without
disabling the preemption or holding spinlocks. so i am confused...

ne explanations are welcome, thanks in advance

and if this sound a lot funny please laugh your hearts out, a favour
of explaining the joke to this newbee is always welcome
-- 
BAIN

             reply	other threads:[~2004-07-04 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-04 14:36 BAIN [this message]
2004-07-04 14:53 ` set_fs() preemption safety? [was sys_fs() safety oops !] Arnd Bergmann
2004-07-04 15:14   ` BAIN

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=2ff21628040704073632ffa1c9@mail.gmail.com \
    --to=bainonline@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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