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]
Date:   Sun, 10 Nov 2019 21:31:21 +0100 (CET)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Andy Lutomirski <luto@...nel.org>
cc:     LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
        Stephen Hemminger <stephen@...workplumber.org>,
        Willy Tarreau <w@....eu>, Juergen Gross <jgross@...e.com>,
        Sean Christopherson <sean.j.christopherson@...el.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [patch 7/9] x86/iopl: Restrict iopl() permission scope

On Sun, 10 Nov 2019, Andy Lutomirski wrote:
> On 11/6/19 11:35 AM, Thomas Gleixner wrote:
> > +
> > +	if (IS_ENABLED(CONFIG_X86_IOPL_EMULATION)) {
> > +		struct tss_struct *tss;
> > +		unsigned int tss_base;
> > +
> > +		/* Prevent racing against a task switch */
> > +		preempt_disable();
> > +		tss = this_cpu_ptr(&cpu_tss_rw);
> > +		if (level == 3) {
> > +			/* Grant access to all I/O ports */
> > +			set_thread_flag(TIF_IO_BITMAP);
> > +			tss_base = IO_BITMAP_OFFSET_VALID_ALL;
> 
> Where is the actual TSS updated?

Here. It sets the offset to the all zero bitmap. That's all it needs.

> > +		} else if (t->io_bitmap_ptr) {
> > +			/* Thread has a I/O bitmap */
> > +			tss_update_io_bitmap(tss, t);
> > +			set_thread_flag(TIF_IO_BITMAP);
> > +			tss_base = IO_BITMAP_OFFSET_VALID_MAP;
> > +		} else {
> > +			/* Take it out of the context switch work burden */
> > +			clear_thread_flag(TIF_IO_BITMAP);
> > +			tss_base = IO_BITMAP_OFFSET_INVALID;
> 
> Ditto.
> 
> I think what you need to do is have a single function, called by
> exit_thread(), switch_to(), and here, that updates the TSS to match a
> given task's IO bitmap state.  This is probably switch_to_bitmap() or
> similar.

Well, no. exit_thread() and this here actually fiddle with the TIF bit
which is not what the switch to case does. There is some stuff which can be
shared.

> (Maybe it already is, but I swear I checked all the patches in the
> series and I can't find the body of tss_update_io_bitmap().  But you
> should call it in all branches of this if-else thing.)

It's in that very same patch:

> -static void tss_update_io_bitmap(struct tss_struct *tss,
> -                                struct thread_struct *thread)
> +void tss_update_io_bitmap(struct tss_struct *tss, struct thread_struct *thread)
>  {

Let me try to get a bit more reuse. Which still leaves the TIF bit fiddling
in this code path.

Thanks,

	tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ