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:	Mon, 27 Jul 2015 14:04:45 -0700
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Andy Lutomirski <luto@...nel.org>,
	Uros Bizjak <uros_bizjak1@....net>,
	linux-kernel@...r.kernel.org
CC:	x86@...nel.org, Uros Bizjak <ubizjak@...il.com>,
	Ingo Molnar <mingo@...nel.org>
Subject: Re: ASM flags in general

On 07/27/2015 01:38 PM, Andy Lutomirski wrote:
> 
> As long as we're thinking about this stuff, there are bunch of places
> where we use exception fixups and do awful things involving translating
> them to error codes.  Ideally they'd use as goto instead, but last time
> I checked, GCC was quite picky and didn't like output constraints and
> asm goto at the same time.  Maybe GCC could fix this at some point, but
> using condition code outputs might be reasonable, too.
> 
> Doing this would make put_user_ex and similar completely unnecessary, I
> think.
> 

No, I think this is wrong.  Exceptions and flags are almost each others
opposites.  Since C doesn't have native exception handling (except
setjmp/longjmp) we pretty much hack it.

asm goto() would indeed be the better way to do this, but again, would
in most cases require asm goto to support outputs.

However, get_user_ex and put_user_ex we really don't want to go away.
They produce extremely efficient code -- just a bunch of mov operations
-- for the common path, and that's the way we like it.

That being said, there probably are a couple of patterns where we could
do, say "stc" in the exception path, and emit CF as an output:

bool err;
int errno;

asm volatile("xor %1,%1\n"	/* Clears CF */
	     "1: something %3,%0\n"/* Leaves CF unchanged, or clears */
	     "2:\n"
             ".section .fixup.\"ax\"\n"
	     "3: mov %4,%1\n"
	     "   stc\n"
	     "   jmp 2b"
	     _ASM_EXTABLE(1b,3b)
            : "=X" (output), "=r" (errno), "=@ccc" (err)
	    : "Y" (input), "i" (-EIO));

This would make "err" immediately testable.  However, it also might make
gcc generate extra code to save and restore err, since it wouldn't
understand the invariant that err = !!errno.

	-hpa

--
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