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: <9b4d09cd65804714815698b14c77df9e@AcuMS.aculab.com>
Date: Sat, 9 Nov 2024 09:36:33 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Brian Gerst' <brgerst@...il.com>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "x86@...nel.org" <x86@...nel.org>
CC: Ingo Molnar <mingo@...nel.org>, "H . Peter Anvin" <hpa@...or.com>, "Thomas
 Gleixner" <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>, Ard
 Biesheuvel <ardb@...nel.org>, Uros Bizjak <ubizjak@...il.com>
Subject: RE: [PATCH v5 07/16] x86/module: Deal with GOT based stack cookie
 load on Clang < 17

From: Brian Gerst
> Sent: 05 November 2024 15:58
> 
> From: Ard Biesheuvel <ardb@...nel.org>
> 
> Clang versions before 17 will not honour -fdirect-access-external-data
> for the load of the stack cookie emitted into each function's prologue
> and epilogue.
> 
> This is not an issue for the core kernel, as the linker will relax these
> loads into LEA instructions that take the address of __stack_chk_guard
> directly. For modules, however, we need to work around this, by dealing
> with R_X86_64_REX_GOTPCRELX relocations that refer to __stack_chk_guard.
> 
> In this case, given that this is a GOT load, the reference should not
> refer to __stack_chk_guard directly, but to a memory location that holds
> its address. So take the address of __stack_chk_guard into a static
> variable, and fix up the relocations to refer to that.
> 
...
> +#if defined(CONFIG_STACKPROTECTOR) && \
> +    defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 170000
> +		case R_X86_64_REX_GOTPCRELX: {
> +			static unsigned long __percpu *const addr = &__stack_chk_guard;
> +
> +			if (sym->st_value != (u64)addr) {
> +				pr_err("%s: Unsupported GOTPCREL relocation\n", me->name);
> +				return -ENOEXEC;
> +			}
> +
> +			val = (u64)&addr + rel[i].r_addend;
> +			fallthrough;
> +		}
> +#endif

Doesn't this depend on the compiler used to compile the module not that
used to compile this code?
(In principle external modules should be able to use a different compiler.)

So the CLANG tests should be replaced by a comment.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ