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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Yenf20Qn9DTvXbbY@zn.tnic>
Date:   Thu, 20 Jan 2022 23:19:07 +0100
From:   Borislav Petkov <bp@...en8.de>
To:     Josh Poimboeuf <jpoimboe@...hat.com>
Cc:     "Kirill A. Shutemov" <kirill@...temov.name>, aarcange@...hat.com,
        ak@...ux.intel.com, dan.j.williams@...el.com,
        dave.hansen@...el.com, david@...hat.com, hpa@...or.com,
        jgross@...e.com, jmattson@...gle.com, joro@...tes.org,
        kirill.shutemov@...ux.intel.com, knsathya@...nel.org,
        linux-kernel@...r.kernel.org, luto@...nel.org, mingo@...hat.com,
        pbonzini@...hat.com, peterz@...radead.org,
        sathyanarayanan.kuppuswamy@...ux.intel.com, sdeep@...are.com,
        seanjc@...gle.com, tglx@...utronix.de, tony.luck@...el.com,
        vkuznets@...hat.com, wanpengli@...cent.com, x86@...nel.org
Subject: Re: [PATCH 2/3] x86/boot: Allow to hook up alternative port I/O
 helpers

On Thu, Jan 20, 2022 at 01:13:47PM -0800, Josh Poimboeuf wrote:
> This one:
> 
> 	pio_ops = (struct port_io_ops){
> 		.inb = inb,
> 		.inw = inw,
> 		.inl = inl,
> 		.outb = outb,
> 		.outw = outw,
> 		.outl = outl,
> 	};
> 
> .. actually allocates an anonymous struct in the .data section, which is
> memcpy'ed at runtime when the assignment occurs.  That anonymous struct
> has .data -> .text relocations which have to be resolved at runtime
> because the distance between .data and .text isn't constant.

Yap, and this is the key point - decompressor kernel is a -pie
executable so it needs to resolve .data section relocations at *runtime*
but we don't have a dynamic linker during early boot.

We could patch at early boot by going through the .data runtime
relocations and patch in the target locations but that would be probably
too much just so that we can do those struct initializers.

And, I'm being told, global .data section things should be avoided, if
possible.

> The working version:
> 
>  	pio_ops.inb = inb;
>  	pio_ops.inw = inw;
>  	pio_ops.inl = inl;
>  	pio_ops.outb = outb;
>  	pio_ops.outw = outw;
>  	pio_ops.outl = outl;
> 
> ... only needs .text -> .text relocations which can be resolved at link
> time.

So yeah, we can simply do this and forget about it.

If someone is bored and wants to fixup such runtime relocations at,
well, runtime, sure. But until then...

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ