Re: [PATCH v4 07/10] x86: narrow out of bounds syscalls to sys_read under speculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 6, 2018 at 12:37 PM, Dan Williams <dan.j.williams@xxxxxxxxx> wrote:
>
> Are there any compilers that would miscompile:
>
>     mask = 0 - (index < size);
>
> That might be a way to improve the assembly.

Sadly, that is *very* easy to miscompile. In fact, I'd be very
surprised indeed if any compiler worth its name wouldn't combine the
comparison with the conditional branch it accompanies, and just turn
that into a constant. IOW, you'd get

        mask = 0 - (index < size);
        if (index <= size) {
                 ... use mask ..

and the compiler would just turn that into

        if (index <= size) {
                mask = -1;

and be done with it.

               Linus



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux