liboqs icon indicating copy to clipboard operation
liboqs copied to clipboard

`test_non_executable_stack` fails on mips* and hppa architectures

Open merkys opened this issue 1 year ago • 5 comments

I attempted building liboqs 0.7.2~rc1-1 on Debian unstable as part of Debian packaging effort. Test test_non_executable_stack is failing on Debian mips64el, mipsel and hppa architectures (full matrix here). Failures look like this:

=================================== FAILURES ===================================
__________________________ test_non_executable_stack ___________________________

    @helpers.filtered_test
    @pytest.mark.skipif(not(sys.platform.startswith("linux")), reason="Only supported on Linux")
    @pytest.mark.skipif(not(os.path.exists(helpers.get_current_build_dir_name()+'/lib/liboqs.so')), reason="Only supported on builds with a shared library")
    def test_non_executable_stack():
        liboqs = helpers.get_current_build_dir_name()+'/lib/liboqs.so'
        out = helpers.run_subprocess(
            ['readelf', '--wide', '--segments', liboqs]
        )
        lines = out.strip().split("\n")
        for line in lines:
            if "GNU_STACK" in line:
                chunks = line.strip().split()
                flags = chunks[6]
>               assert(flags == 'RW')
E               AssertionError: assert 'RWE' == 'RW'
E                 - RW
E                 + RWE
E                 ?   +

merkys avatar Aug 09 '22 06:08 merkys

This is indeed a new test.

Is it possible that the compiler flag "-Wa,--noexecstack" is not properly honored on those platforms? I don't have any of those at my disposal to test. If you could confirm this, would you want to set --ignore=tests/test_binary.py when invoking pytest? Alternatively, can you propose "carve-out" statements that we could add to skip that test on those specific platforms?

baentsch avatar Aug 09 '22 06:08 baentsch

It seems that these architectures ignore CMAKE_ASM_FLAGS as it is only -Wa,--noexecstack which does not make to cc call (all options set via add_compile_options() appear on cc command line call).

Ignoring this test case is surely an option if this cannot be fixed.

merkys avatar Aug 10 '22 08:08 merkys

Is there are a reason that -Wa,--noexecstack is only set when including assembler code? Shouldn't this be enabled globally?

sebastinas avatar Aug 10 '22 08:08 sebastinas

Shouldn't this be enabled globally?

Sounds sensible to me. @dstebila : Can you recall a reason?

baentsch avatar Aug 10 '22 16:08 baentsch

Shouldn't this be enabled globally?

Sounds sensible to me. @dstebila : Can you recall a reason?

I have some vague recollection of some weirdness involving this, but nothing definite. Seems reasonable to try.

dstebila avatar Aug 10 '22 16:08 dstebila

Now I know why it the linker options is missing. I'll iterate on possible solutions in #1294.

sebastinas avatar Aug 22 '22 13:08 sebastinas

I confirm that https://github.com/open-quantum-safe/liboqs/commit/9ee96d803ef8fb822a7d9b32572276b47d9575f4 fixes the issue.

merkys avatar Aug 31 '22 07:08 merkys