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: <20211102040143.GB23420@gondor.apana.org.au>
Date:   Tue, 2 Nov 2021 12:01:43 +0800
From:   Herbert Xu <herbert@...dor.apana.org.au>
To:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Denys Vlasenko <dvlasenk@...hat.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux Crypto Mailing List <linux-crypto@...r.kernel.org>,
        Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>
Subject: Re: [GIT PULL] Crypto Fixes for 5.15

On Fri, Oct 29, 2021 at 10:39:35AM -0700, Linus Torvalds wrote:
>
> Plus, I get the feeling that some people have just copied-and-pasted
> those things, and don't necessarily realize just _how_ subtle 'M'
> sections are.
> 
> How much of a data savings is it to have this complexity? Particularly
> since I suspect most of the time these things end up being individual
> modules, and never actually get linked together at all?

Let me copy Denys Vlasenko who introduced this.

But you're absolutely right that the recent additions are
more likely to be just cut-n-paste rather than deeply thought
through.

FWIW the original change that added this was:

ommit e183914af00e15eb41ae666d44e323bfa154be13
Author: Denys Vlasenko <dvlasenk@...hat.com>
Date:   Thu Jan 19 22:33:04 2017 +0100

    crypto: x86 - make constants readonly, allow linker to merge them

    A lot of asm-optimized routines in arch/x86/crypto/ keep its
    constants in .data. This is wrong, they should be on .rodata.

    Mnay of these constants are the same in different modules.
    For example, 128-bit shuffle mask 0x000102030405060708090A0B0C0D0E0F
    exists in at least half a dozen places.

    There is a way to let linker merge them and use just one copy.
    The rules are as follows: mergeable objects of different sizes
    should not share sections. You can't put them all in one .rodata
    section, they will lose "mergeability".

    GCC puts its mergeable constants in ".rodata.cstSIZE" sections,
    or ".rodata.cstSIZE.<object_name>" if -fdata-sections is used.
    This patch does the same:

            .section .rodata.cst16.SHUF_MASK, "aM", @progbits, 16

    It is important that all data in such section consists of
    16-byte elements, not larger ones, and there are no implicit
    use of one element from another.

    When this is not the case, use non-mergeable section:

            .section .rodata[.VAR_NAME], "a", @progbits

    This reduces .data by ~15 kbytes:

        text    data     bss     dec      hex filename
    11097415 2705840 2630712 16433967  fac32f vmlinux-prev.o
    11112095 2690672 2630712 16433479  fac147 vmlinux.o

    Merged objects are visible in System.map:

    ffffffff81a28810 r POLY
    ffffffff81a28810 r POLY
    ffffffff81a28820 r TWOONE
    ffffffff81a28820 r TWOONE
    ffffffff81a28830 r PSHUFFLE_BYTE_FLIP_MASK <- merged regardless of
    ffffffff81a28830 r SHUF_MASK   <------------- the name difference
    ffffffff81a28830 r SHUF_MASK
    ffffffff81a28830 r SHUF_MASK
    ..
    ffffffff81a28d00 r K512 <- merged three identical 640-byte tables
    ffffffff81a28d00 r K512
    ffffffff81a28d00 r K512

    Use of object names in section name suffixes is not strictly necessary,
    but might help if someday link stage will use garbage collection
    to eliminate unused sections (ld --gc-sections).

    Signed-off-by: Denys Vlasenko <dvlasenk@...hat.com>
    CC: Herbert Xu <herbert@...dor.apana.org.au>
    CC: Josh Poimboeuf <jpoimboe@...hat.com>
    CC: Xiaodong Liu <xiaodong.liu@...el.com>
    CC: Megha Dey <megha.dey@...el.com>
    CC: linux-crypto@...r.kernel.org
    CC: x86@...nel.org
    CC: linux-kernel@...r.kernel.org
    Signed-off-by: Herbert Xu <herbert@...dor.apana.org.au>

Cheers,
-- 
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ