lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150127194030.GA29879@redhat.com>
Date:	Tue, 27 Jan 2015 20:40:30 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Rik van Riel <riel@...hat.com>
Cc:	"H. Peter Anvin" <hpa@...or.com>,
	Suresh Siddha <suresh.b.siddha@...el.com>,
	Andy Lutomirski <luto@...capital.net>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Fenghua Yu <fenghua.yu@...el.com>,
	the arch/x86 maintainers <x86@...nel.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: question about save_xstate_sig() - WHY DOES THIS WORK?

On 01/26, Rik van Riel wrote:
>
> On 01/24/2015 03:20 PM, Oleg Nesterov wrote:
>
> > Now the questions:
> >
> > - This doesn't hurt, but does it really need __thread_fpu_end?
> >
> > Perhaps this is because we do not check the error code returned by
> > __save_init_fpu? although I am not sure I understand the comment
> > above fpu_save_init correctly...
>
> Looking at the code some more, I do not see any call site of
> save_init_fpu() that actually needs or wants __thread_fpu_end(),
> with or without eager fpu mode.

Yes. But probably it is needed if __save_init_fpu() returns 0.
But this is minor, __thread_fpu_end() doesn't hurt correctness-wise
if !eager.

> It looks like we can get rid of that.

Agreed, but probably this needs a separate change.

> > - What about do_bounds() ? Should not it use save_init_fpu()
> > rather than fpu_save_init() ?
>
> I suppose do_bounds() probably should save the fpu context while
> not preemptible,

plus it also needs the __thread_has_fpu() check. Otherwise fpu_save_init()
can save the wrong FPU state afaics.

> but that may also mean moving conditional_sti()
> until after save_init_fpu() or __save_init_fpu() has been called.

Agreed, this can work too.

> > - Why unlazy_fpu() always does __save_init_fpu() even if
> > use_eager_fpu?
> >
> > and note that in this case __thread_fpu_end() is wrong if
> > use_eager_fpu, but fortunately the only possible caller of
> > unlazy_fpu() is coredump. fpu_copy() checks use_eager_fpu().
> >
> > - Is unlazy_fpu()->__save_init_fpu() safe wrt __kernel_fpu_begin()
> > from irq?
> >
> > I mean, is it safe if __save_init_fpu() path is interrupted by
> > another __save_init_fpu() + restore_fpu_checking() from
> > __kernel_fpu_begin/end?
>
> I got lost in the core dump code trying to figure out whether this is
> safe or broken. I'll need some more time to look through that code...

It is called indirectly by regset code, see xstateregs_get()->init_fpu().

The coredumping task can't return to user-mode and use FPU in this case,
so this is not that bad. Still unlazy_fpu()->__thread_fpu_end() is wrong
if eager.

And I forgot to mention, the "else" branch in unlazy_fpu() makes no sense.
And note that save_init_fpu() and unlazy_fpu() is the same thing (if we
fix/cleanup them).

Oh. I'll try to finish my cleanups and send them tomorrow. Unless you
do this ;)

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ