From: Oleg Nesterov <oleg@tv-sign.ru>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Chuck Ebbert <76306.1226@compuserve.com>,
Ingo Molnar <mingo@elte.hu>, Roland McGrath <roland@redhat.com>,
linux-kernel@vger.kernel.org, davem@davemloft.net
Subject: Re: Q: a bogus set_fs(USER_DS) in setup_frame/setup_rt_frame ?
Date: Tue, 17 Jul 2007 21:15:35 +0400 [thread overview]
Message-ID: <20070717171535.GA431@tv-sign.ru> (raw)
In-Reply-To: <alpine.LFD.0.999.0707170902570.19166@woody.linux-foundation.org>
On 07/17, Linus Torvalds wrote:
>
> On Tue, 17 Jul 2007, Oleg Nesterov wrote:
> >
> > I am really puzzled by set_fs(USER_DS) in setup_frame/setup_rt_frame.
> >
> > How is it possible that current->addr_limit != USER_DS ? If this _is_
> > possible, how can can we trust the result of access_ok() above?
>
> Heh. I think it's entirely historical.
>
> Please realize that the whole reason that function is called "set_fs()" is
> that it literally used to set the %fs segment register, not
> "->addr_limit".
>
> So I think the "set_fs(USER_DS)" is there _only_ to match the other
>
> regs->xds = __USER_DS;
> regs->xes = __USER_DS;
> regs->xss = __USER_DS;
> regs->xcs = __USER_CS;
>
> things, and never mattered.
Thanks!
> And now it matters even less, and has been
> copied to all other architectures where it is just totally insane.
Yes.
Also, sparc does something strange with do_sigaltstack(). It first copies
stack_t to the local variable, then sets KERNEL_DS to access it from
do_sigaltstack().
IOW, what's wrong with the patch below? Why should we ignore errors other
than -EFAULT?
Oleg.
--- arch/sparc64/kernel/signal.c~ 2007-05-21 13:57:49.000000000 +0400
+++ arch/sparc64/kernel/signal.c 2007-07-17 21:04:32.000000000 +0400
@@ -291,7 +291,6 @@ void do_rt_sigreturn(struct pt_regs *reg
__siginfo_fpu_t __user *fpu_save;
mm_segment_t old_fs;
sigset_t set;
- stack_t st;
int err;
/* Always make any pending restarted system calls return -EINTR */
@@ -327,20 +326,13 @@ void do_rt_sigreturn(struct pt_regs *reg
err |= restore_fpu_state(regs, &sf->fpu_state);
err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
- err |= __copy_from_user(&st, &sf->stack, sizeof(stack_t));
-
+ err |= do_sigaltstack(&st->stack, NULL, (unsigned long)sf);
+
if (err)
goto segv;
-
+
regs->tpc = tpc;
regs->tnpc = tnpc;
-
- /* It is more difficult to avoid calling this function than to
- call it and ignore errors. */
- old_fs = get_fs();
- set_fs(KERNEL_DS);
- do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
- set_fs(old_fs);
sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(¤t->sighand->siglock);
next prev parent reply other threads:[~2007-07-17 17:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-17 15:46 Q: a bogus set_fs(USER_DS) in setup_frame/setup_rt_frame ? Oleg Nesterov
2007-07-17 16:04 ` [patch] i386: remove unnecessary code Ingo Molnar
2007-07-17 16:05 ` Q: a bogus set_fs(USER_DS) in setup_frame/setup_rt_frame ? Linus Torvalds
2007-07-17 17:15 ` Oleg Nesterov [this message]
2007-07-17 19:36 ` David Miller
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=20070717171535.GA431@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=76306.1226@compuserve.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=torvalds@linux-foundation.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 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.