Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc 1.66.0 requires execstack to load libLLVM.so #105783

Closed
cgzones opened this issue Dec 16, 2022 · 15 comments · Fixed by #109945
Closed

rustc 1.66.0 requires execstack to load libLLVM.so #105783

cgzones opened this issue Dec 16, 2022 · 15 comments · Fixed by #109945
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cgzones
Copy link

cgzones commented Dec 16, 2022

rustc 1.66.0 requires an executable stack, which is frowned upon for security reasons and for example generally forbidden by SELinux.

System: Debian sid (amd64)

Execstack allowed:

~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc -vV
rustc 1.66.0 (69f9c33d7 2022-12-12)
binary: rustc
commit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943
commit-date: 2022-12-12
host: x86_64-unknown-linux-gnu
release: 1.66.0
LLVM version: 15.0.2

Execstack forbidden:

~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc -vV
/home/christian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc: error while loading shared libraries: libLLVM-15-rust-1.66.0-stable.so: cannot enable executable stack as shared object requires: Permission denied

Maybe this is related to PGO or BOLT being enabled?

Stack trace:

#0  0x00007ffff7febab7 in __GI_mprotect () at ../sysdeps/unix/syscall-template.S:117
No locals.
#1  0x00007ffff7fce754 in make_main_stack_executable (stack_endp=0x7fffffffc830) at ../sysdeps/unix/sysv/linux/dl-execstack.c:40
        page = <optimized out>
        result = 0
        page = <optimized out>
        result = <optimized out>
        return_success = <optimized out>
        out = <optimized out>
#2  _dl_make_stacks_executable (stack_endp=stack_endp@entry=0x7fffffffc830) at ../sysdeps/unix/sysv/linux/dl-execstack.c:65
        err = <optimized out>
        runp = <optimized out>
#3  0x00007ffff7fd2b69 in _dl_map_object_from_fd (name=name@entry=0x7ffff4042d93 "libLLVM-15-rust-1.66.0-stable.so", origname=origname@entry=0x0, fd=<optimized out>, fbp=fbp@entry=0x7fffffffc840, realname=<optimized out>, loader=loader@entry=0x7ffff7fc3330, 
    l_type=<optimized out>, mode=<optimized out>, stack_endp=<optimized out>, nsid=<optimized out>) at ./elf/dl-load.c:1358
        l = 0x7ffff7f9b710
        header = 0x7fffffffc848
        phdr = <optimized out>
        ph = <optimized out>
        maplength = <optimized out>
        type = <optimized out>
        errstring = 0x0
        errval = 0
        r = <optimized out>
        make_consistent = false
        id = {dev = 65027, ino = 3017896}
        __PRETTY_FUNCTION__ = "_dl_map_object_from_fd"
        fail_new = <optimized out>
        stack_flags = <optimized out>
#4  0x00007ffff7fd3165 in _dl_map_object (loader=<optimized out>, name=0x7ffff4042d93 "libLLVM-15-rust-1.66.0-stable.so", type=1, trace_mode=<optimized out>, mode=0, nsid=<optimized out>) at ./elf/dl-load.c:2272
        fd = <optimized out>
        origname = <optimized out>
        realname = 0x7ffff7f9b690 "/home/christian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-15-rust-1.66.0-stable.so"
        name_copy = <optimized out>
        l = <optimized out>
        fb = {len = 832, 
          buf = "\177ELF\002\001\001\000\000\000\000\000\000\000\000\000\003\000>\000\001", '\000' <repeats 11 times>, "@\000\000\000\000\000\000\000\300\234f\b\000\000\000\000\000\000\000\000@\000\070\000\n\000@\000.\000 \000\006\000\000\000\004\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000\060\002\000\000\000\000\000\000\060\002\000\000\000\000\000\000\b\000\000\000\000\000\000\000\001\000\000\000\004", '\000' <repeats 27 times>, ",\b>\002\000\000\000\000,\b>\002\000\000\000\000\000\020\000\000\000\000\000\000\001\000\000\000\005\000\000\000,\b>\002\000\000\000\000,\030>\002\000\000\000\000"...}
        __PRETTY_FUNCTION__ = "_dl_map_object"
        found_other_class = false
        stack_end = 0x7fffffffd6c0
#5  0x00007ffff7fcd281 in openaux (a=a@entry=0x7fffffffce90) at ./elf/dl-deps.c:64
        args = 0x7fffffffce90
#6  0x00007ffff7fe3261 in _dl_catch_exception (exception=exception@entry=0x7fffffffce70, operate=operate@entry=0x7ffff7fcd250 <openaux>, args=args@entry=0x7fffffffce90) at ./elf/dl-error-skeleton.c:208
        errcode = 0
        c = {exception = 0x7fffffffce70, errcode = 0x7fffffffcc0c, env = {{__jmpbuf = {140737353067168, -1509949440, 1, 0, 140737353888560, 140737287302547, -1749024768, -17607677575168}, __mask_was_saved = -134225184, __saved_mask = {__val = {93824992235626, 
                  18446744071964721152, 18446726466031976448, 140737354130144, 93824992235587, 18446744071968915456, 18446726466031976448, 140737354130144, 93824992235576, 18446744071973109760, 18446726466031976448, 140737354130144, 140737353943588, 140737353067168, 
                  140737488343808, 1}}}}}
        old = 0x0
#7  0x00007ffff7fcd5ea in _dl_map_object_deps (map=map@entry=0x7ffff7ffe2e0, preloads=preloads@entry=0x0, npreloads=<optimized out>, trace_mode=<optimized out>, open_mode=open_mode@entry=0) at ./elf/dl-deps.c:232
        dep = <optimized out>
        err = <optimized out>
        strtab = 0x7ffff3e8cde0 ""
        args = {map = 0x7ffff7fc3330, trace_mode = 0, open_mode = 0, strtab = 0x7ffff3e8cde0 "", name = 0x7ffff4042d93 "libLLVM-15-rust-1.66.0-stable.so", aux = 0x7ffff7fc3910}
        orig = 0x7fffffffcda0
        d = 0x7ffff7efaaa0
        l = <optimized out>
        needed = 0x7fffffffced0
        nneeded = 1
        known = <optimized out>
        runp = 0x7fffffffcda0
        tail = 0x7fffffffcd00
        nlist = 7
        i = <optimized out>
        name = <optimized out>
        errno_saved = <optimized out>
        errno_reason = 0
        exception = {objname = 0x0, errstring = 0x0, message_buffer = 0x0}
        needed_space = {data = 0x7fffffffced0, length = 1024, __space = {__align = {__max_align_ll = 140737353890064, __max_align_ld = 0}, __c = "\020\071\374\367\377\177", '\000' <repeats 530 times>...}}
        __PRETTY_FUNCTION__ = "_dl_map_object_deps"
        old_l_initfini = <optimized out>
        l_initfini = <optimized out>
        map_index = <optimized out>
        l_reldeps = <optimized out>
#8  0x00007ffff7fe88ea in dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at ./elf/rtld.c:1982
        start = 9860954108152
        main_map = <optimized out>
        file_size = 140737353912872
        file = <optimized out>
        i = <optimized out>
        rtld_is_main = <optimized out>
        tcbp = 0x0
        state = {audit_list = {audit_strings = {0x0 <repeats 13 times>, 0x555555554040 "\006", 0x38 <error: Cannot access memory at address 0x38>, 0xc <error: Cannot access memory at address 0xc>}, length = 0, current_index = 0, current_tail = 0x0, fname = "u\351VUUU\000\000\000\000\000\000\000\000\000\000\350\003\000\000\000\000\000\000\350\003\000\000\000\000\000\000\350\003\000\000\000\000\000\000\377\265\360", '\000' <repeats 13 times>, "\305\000\000\000\000\000\000\000\f\000\376\367\377\177\000\000\177\003\000\000\000\000\000\000\000\000\303\000\001", '\000' <repeats 14 times>, "\001\003\000\000\000=\000\000\000\024\000\000\000\000\000\004\000\000\000\000\000\210\325\377\377\377\177\000\000\000\200\000\000\000\000\000\000\200\325\377\377\377\177\000\000\000\000@\000\000\000\000\000@\000\000\000\000\000\000\000\323\t\376\367\377\177", '\000' <repeats 11 times>, "\b\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\020\000\000\000\000\000\000"...}, library_path = 0x0, library_path_source = 0x0, preloadlist = 0x0, preloadarg = 0x0, glibc_hwcaps_prepend = 0x0, glibc_hwcaps_mask = 0x0, mode = rtld_mode_normal, mode_trace_program = false, any_debug = false, version_info = false}
        ld_so_name = <optimized out>
        __PRETTY_FUNCTION__ = "dl_main"
        has_interp = <optimized out>
        first_preload = <optimized out>
        r = <optimized out>
        rtld_ehdr = <optimized out>
        rtld_phdr = <optimized out>
        cnt = <optimized out>
        need_security_init = true
        count_modids = 1
        preloads = 0x0
        npreloads = <optimized out>
        preload_file = "/etc/ld.so.preload"
        rtld_multiple_ref = <optimized out>
        was_tls_init_tp_called = <optimized out>
        consider_profiling = <optimized out>
        start = <optimized out>
#9  0x00007ffff7fe519f in _dl_sysdep_start (start_argptr=start_argptr@entry=0x7fffffffd6c0, dl_main=dl_main@entry=0x7ffff7fe6e10 <dl_main>) at ../sysdeps/unix/sysv/linux/dl-sysdep.c:140
        dl_main_args = {phdr = 0x555555554040, phnum = 12, user_entry = 93824992340341}
#10 0x00007ffff7fe6b1c in _dl_start_final (arg=0x7fffffffd6c0) at ./elf/rtld.c:497
        start_addr = <optimized out>
        start_addr = <optimized out>
        rtld_total_time = <optimized out>
#11 _dl_start (arg=<optimized out>) at ./elf/rtld.c:584
No locals.
#12 0x00007ffff7fe59c8 in _start () from /lib64/ld-linux-x86-64.so.2
        TD_SLEEP = TD_SLEEP
        TD_CREATE = TD_CREATE
        _URC_FATAL_PHASE1_ERROR = _URC_FATAL_PHASE1_ERROR
        TD_CATCHSIG = TD_CATCHSIG
        cet_permissive = cet_permissive
        TD_LOCK_TRY = TD_LOCK_TRY
        RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT = RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT
        PREFERRED_FEATURE_INDEX_1 = PREFERRED_FEATURE_INDEX_1
        PREFERRED_FEATURE_INDEX_MAX = PREFERRED_FEATURE_INDEX_MAX
        arch_kind_unknown = arch_kind_unknown
        TD_SWITCHFROM = TD_SWITCHFROM
        cache_extension_tag_generator = cache_extension_tag_generator
        cache_extension_tag_glibc_hwcaps = cache_extension_tag_glibc_hwcaps
        _URC_INSTALL_CONTEXT = _URC_INSTALL_CONTEXT
        TD_DEATH = TD_DEATH
        RT_CONSISTENT = RT_CONSISTENT
        LA_ACT_CONSISTENT = LA_ACT_CONSISTENT
        rtld_mode_verify = rtld_mode_verify
        TD_MAX_EVENT_NUM = TD_TIMEOUT
        RT_DELETE = RT_DELETE
        RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT = RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT
        relocate_time = 0
        DL_LOOKUP_ADD_DEPENDENCY = DL_LOOKUP_ADD_DEPENDENCY
        TD_READY = TD_READY
        _bitindex_arch_Slow_SSE4_2 = _bitindex_arch_Slow_SSE4_2
        rtld_mode_help = rtld_mode_help
        cpuid_register_index_eax = cpuid_register_index_eax
        CPUID_INDEX_1 = CPUID_INDEX_1
        CPUID_INDEX_7 = CPUID_INDEX_7
        CPUID_INDEX_80000001 = CPUID_INDEX_80000001
        CPUID_INDEX_D_ECX_1 = CPUID_INDEX_D_ECX_1
        CPUID_INDEX_80000007 = CPUID_INDEX_80000007
        CPUID_INDEX_80000008 = CPUID_INDEX_80000008
        CPUID_INDEX_7_ECX_1 = CPUID_INDEX_7_ECX_1
        CPUID_INDEX_19 = CPUID_INDEX_19
        CPUID_INDEX_14_ECX_0 = CPUID_INDEX_14_ECX_0
        CPUID_INDEX_MAX = CPUID_INDEX_MAX
        dso_sort_algorithm_original = dso_sort_algorithm_original
        TD_CONCURRENCY = TD_CONCURRENCY
        lt_executable = lt_executable
        cpuid_register_index_ebx = cpuid_register_index_ebx
        _bitindex_arch_I686 = _bitindex_arch_I686
        cache_extension_count = cache_extension_count
        PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_TIMED_NP
        PTHREAD_MUTEX_RECURSIVE_NP = PTHREAD_MUTEX_RECURSIVE_NP
        PTHREAD_MUTEX_ERRORCHECK_NP = PTHREAD_MUTEX_ERRORCHECK_NP
        PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_ADAPTIVE_NP
        PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP
        PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP
        PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP
        PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_TIMED_NP
        PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
        TD_REAP = TD_REAP
        DL_LOOKUP_RETURN_NEWEST = DL_LOOKUP_RETURN_NEWEST
        _URC_HANDLER_FOUND = _URC_HANDLER_FOUND
        cpuid_register_index_ecx = cpuid_register_index_ecx
        _bitindex_arch_Avoid_Short_Distance_REP_MOVSB = _bitindex_arch_Avoid_Short_Distance_REP_MOVSB
        _bitindex_arch_Prefer_FSRM = _bitindex_arch_Prefer_FSRM
        lc_property_unknown = lc_property_unknown
        _bitindex_arch_Fast_Unaligned_Load = _bitindex_arch_Fast_Unaligned_Load
        lt_library = lt_library
        cpuid_register_index_edx = cpuid_register_index_edx
        rtld_mode_list_diagnostics = rtld_mode_list_diagnostics
        start_time = 9860951681620
        _URC_NO_REASON = _URC_NO_REASON
        _bitindex_arch_Prefer_PMINUB_for_stringop = _bitindex_arch_Prefer_PMINUB_for_stringop
        arch_kind_other = arch_kind_other
        rtld_mode_list = rtld_mode_list
        _dl_rtld_libname = {name = 0x5555555542e0 "/lib64/ld-linux-x86-64.so.2", next = 0x7ffff7ffe230 <newname>, dont_free = 0}
        TD_IDLE = TD_IDLE
        unknown = unknown
        _URC_FATAL_PHASE2_ERROR = _URC_FATAL_PHASE2_ERROR
        cet_elf_property = cet_elf_property
        RT_ADD = RT_ADD
        _bitindex_arch_Fast_Rep_String = _bitindex_arch_Fast_Rep_String
        _bitindex_arch_MathVec_Prefer_No_AVX512 = _bitindex_arch_MathVec_Prefer_No_AVX512
        _bitindex_arch_Fast_Copy_Backward = _bitindex_arch_Fast_Copy_Backward
        _bitindex_arch_AVX_Fast_Unaligned_Load = _bitindex_arch_AVX_Fast_Unaligned_Load
        existing = existing
        _URC_NORMAL_STOP = _URC_NORMAL_STOP
        lc_property_none = lc_property_none
        nonexisting = nonexisting
        load_time = 0
        TD_PREEMPT = TD_PREEMPT
        TD_TIMEOUT = TD_TIMEOUT
        TD_ALL_EVENTS = TD_ALL_EVENTS
        _URC_END_OF_STACK = _URC_END_OF_STACK
        _bitindex_arch_Prefer_No_AVX512 = _bitindex_arch_Prefer_No_AVX512
        arch_kind_intel = arch_kind_intel
        rtld_mode_trace = rtld_mode_trace
        rtld_mode_list_tunables = rtld_mode_list_tunables
        _bitindex_arch_Prefer_ERMS = _bitindex_arch_Prefer_ERMS
        cet_always_on = cet_always_on
        dso_sort_algorithm_dfs = dso_sort_algorithm_dfs
        LA_ACT_DELETE = LA_ACT_DELETE
        TD_SWITCHTO = TD_SWITCHTO
        _bitindex_arch_Slow_BSF = _bitindex_arch_Slow_BSF
        arch_kind_zhaoxin = arch_kind_zhaoxin
        cet_always_off = cet_always_off
        arch_kind_amd = arch_kind_amd
        _URC_FOREIGN_EXCEPTION_CAUGHT = _URC_FOREIGN_EXCEPTION_CAUGHT
        _bitindex_arch_Prefer_No_VZEROUPPER = _bitindex_arch_Prefer_No_VZEROUPPER
        TD_EVENT_NONE = TD_ALL_EVENTS
        TD_EVENTS_ENABLE = TD_EVENTS_ENABLE
        rtld_mode_normal = rtld_mode_normal
        TD_MIN_EVENT_NUM = TD_READY
        lc_property_valid = lc_property_valid
        LA_ACT_ADD = LA_ACT_ADD
        TD_PRI_INHERIT = TD_PRI_INHERIT
        _bitindex_arch_Fast_Unaligned_Copy = _bitindex_arch_Fast_Unaligned_Copy
        _URC_CONTINUE_UNWIND = _URC_CONTINUE_UNWIND
        DL_LOOKUP_FOR_RELOCATE = DL_LOOKUP_FOR_RELOCATE
        lt_loaded = lt_loaded
        DL_LOOKUP_GSCOPE_LOCK = DL_LOOKUP_GSCOPE_LOCK
        _dl_rtld_libname2 = {name = 0x0, next = 0x0, dont_free = 0}
        RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT = RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT
        _bitindex_arch_I586 = _bitindex_arch_I586
        tls_init_tp_called = false
        __GI__dl_argv = 0x7fffffffd6c8
        _rtld_global_ro = {_dl_debug_mask = 0, _dl_platform = 0x7ffff7ff317c "haswell", _dl_platformlen = 7, _dl_pagesize = 4096, _dl_minsigstacksize = 1776, _dl_inhibit_cache = 0, _dl_initial_searchlist = {r_list = 0x0, r_nlist = 0}, _dl_clktck = 100, _dl_verbose = 0, _dl_debug_fd = 2, _dl_lazy = 1, _dl_bind_not = 0, _dl_dynamic_weak = 0, _dl_fpu_control = 895, _dl_hwcap = 2, _dl_auxv = 0x7fffffffd930, _dl_x86_cpu_features = {basic = {kind = arch_kind_intel, max_cpuid = 20, family = 6, model = 61, stepping = 4}, features = {{{cpuid_array = {198356, 51382272, 2147154879, 3219913727}, cpuid = {eax = 198356, ebx = 51382272, ecx = 2147154879, edx = 3219913727}}, {active_array = {0, 0, 2128097795, 394821904}, active = {eax = 0, ebx = 0, ecx = 2128097795, edx = 394821904}}}, {{cpuid_array = {0, 35399595, 0, 2617247232}, cpuid = {eax = 0, ebx = 35399595, ecx = 0, edx = 2617247232}}, {active_array = {0, 787240, 0, 0}, active = {eax = 0, ebx = 787240, ecx = 0, edx = 0}}}, {{cpuid_array = {0, 0, 289, 739248128}, cpuid = {eax = 0, ebx = 0, ecx = 289, edx = 739248128}}, {active_array = {0, 0, 289, 134217728}, active = {eax = 0, ebx = 0, ecx = 289, edx = 134217728}}}, {{cpuid_array = {1, 0, 0, 0}, cpuid = {eax = 1, ebx = 0, ecx = 0, edx = 0}}, {active_array = {1, 0, 0, 0}, active = {eax = 1, ebx = 0, ecx = 0, edx = 0}}}, {{cpuid_array = {0, 0, 0, 256}, cpuid = {eax = 0, ebx = 0, ecx = 0, edx = 256}}, {active_array = {0, 0, 0, 0}, active = {eax = 0, ebx = 0, ecx = 0, edx = 0}}}, {{cpuid_array = {12327, 0, 0, 0}, cpuid = {eax = 12327, ebx = 0, ecx = 0, edx = 0}}, {active_array = {0, 0, 0, 0}, active = {eax = 0, ebx = 0, ecx = 0, edx = 0}}}, {{cpuid_array = {0, 0, 0, 0}, cpuid = {eax = 0, ebx = 0, ecx = 0, edx = 0}}, {active_array = {0, 0, 0, 0}, active = {eax = 0, ebx = 0, ecx = 0, edx = 0}}}, {{cpuid_array = {0, 0, 0, 0}, cpuid = {eax = 0, ebx = 0, ecx = 0, edx = 0}}, {active_array = {0, 0, 0, 0}, active = {eax = 0, ebx = 0, ecx = 0, edx = 0}}}, {{cpuid_array = {0, 1, 1, 0}, cpuid = {eax = 0, ebx = 1, ecx = 1, edx = 0}}, {active_array = {0, 0, 0, 0}, active = {eax = 0, ebx = 0, ecx = 0, edx = 0}}}}, preferred = {4857}, isa_1 = 7, xsave_state_size = 896, xsave_state_full_size = 896, data_cache_size = 32768, shared_cache_size = 1048576, non_temporal_threshold = 786432, rep_movsb_threshold = 8192, rep_movsb_stop_threshold = 786432, rep_stosb_threshold = 2048, level1_icache_size = 32768, level1_icache_linesize = 64, level1_dcache_size = 32768, level1_dcache_assoc = 8, level1_dcache_linesize = 64, level2_cache_size = 262144, level2_cache_assoc = 8, level2_cache_linesize = 64, level3_cache_size = 4194304, level3_cache_assoc = 16, level3_cache_linesize = 64, level4_cache_size = 0}, _dl_x86_hwcap_flags = {"sse2\000\000\000\000", "x86_64\000\000", "avx512_1"}, _dl_x86_platforms = {"i586\000\000\000\000", "i686\000\000\000\000", "haswell\000", "xeon_phi"}, _dl_inhibit_rpath = 0x0, _dl_origin_path = 0x0, _dl_tls_static_size = 0, _dl_tls_static_align = 0, _dl_tls_static_surplus = 0, _dl_profile = 0x0, _dl_profile_output = 0x7ffff7ff1de0 "/var/tmp", _dl_init_all_dirs = 0x0, _dl_sysinfo_dso = 0x7ffff7fc9500, _dl_sysinfo_map = 0x7ffff7ffe8b0, _dl_vdso_clock_gettime64 = 0x7ffff7fc9960 <clock_gettime>, _dl_vdso_gettimeofday = 0x7ffff7fc9780 <gettimeofday>, _dl_vdso_time = 0x7ffff7fc9930 <time>, _dl_vdso_getcpu = 0x7ffff7fc9c20 <getcpu>, _dl_vdso_clock_getres_time64 = 0x7ffff7fc9bc0 <clock_getres>, _dl_hwcap2 = 2, _dl_dso_sort_algo = dso_sort_algorithm_dfs, _dl_debug_printf = 0x7ffff7fd7cc0 <_dl_debug_printf>, _dl_mcount = 0x7ffff7fd87f0 <__GI__dl_mcount>, _dl_lookup_symbol_x = 0x7ffff7fd4a10 <_dl_lookup_symbol_x>, _dl_open = 0x7ffff7fd6600 <_dl_open>, _dl_close = 0x7ffff7fcd010 <_dl_close>, _dl_catch_error = 0x7ffff7fe3370 <_rtld_catch_error>, _dl_error_free = 0x7ffff7fce1b0 <_dl_error_free>, _dl_tls_get_addr_soft = 0x7ffff7fdcaa0 <_dl_tls_get_addr_soft>, _dl_libc_freeres = 0x7ffff7fe3fc0 <__rtld_libc_freeres>, _dl_find_object = 0x7ffff7fceae0 <__GI__dl_find_object>, _dl_dlfcn_hook = 0x0, _dl_audit = 0x0, _dl_naudit = 0}
        _dl_argc = 2
        __pointer_chk_guard_local = 0
        _rtld_global = {_dl_ns = {{_ns_loaded = 0x7ffff7ffe2e0, _ns_nloaded = 9, _ns_main_searchlist = 0x0, _ns_global_scope_alloc = 0, _ns_global_scope_pending_adds = 0, libc_map = 0x7ffff7f9b000, _ns_unique_sym_table = {lock = {mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 1, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 16 times>, "\001", '\000' <repeats 22 times>, __align = 0}}, entries = 0x0, size = 0, n_elements = 0, free = 0x0}, _ns_debug = {base = {r_version = 0, r_map = 0x0, r_brk = 0, r_state = RT_CONSISTENT, r_ldbase = 0}, r_next = 0x0}}, {_ns_loaded = 0x0, _ns_nloaded = 0, _ns_main_searchlist = 0x0, _ns_global_scope_alloc = 0, _ns_global_scope_pending_adds = 0, libc_map = 0x0, _ns_unique_sym_table = {lock = {mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, entries = 0x0, size = 0, n_elements = 0, free = 0x0}, _ns_debug = {base = {r_version = 0, r_map = 0x0, r_brk = 0, r_state = RT_CONSISTENT, r_ldbase = 0}, r_next = 0x0}} <repeats 15 times>}, _dl_nns = 1, _dl_load_lock = {mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 1, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 16 times>, "\001", '\000' <repeats 22 times>, __align = 0}}, _dl_load_write_lock = {mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 1, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 16 times>, "\001", '\000' <repeats 22 times>, __align = 0}}, _dl_load_tls_lock = {mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 1, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 16 times>, "\001", '\000' <repeats 22 times>, __align = 0}}, _dl_load_adds = 9, _dl_initfirst = 0x0, _dl_profile_map = 0x0, _dl_num_relocations = 5, _dl_num_cache_relocations = 0, _dl_all_dirs = 0x7ffff7f9b570, _dl_rtld_map = {l_addr = 140737353920512, l_name = 0x5555555542e0 "/lib64/ld-linux-x86-64.so.2", l_ld = 0x7ffff7ffce20, l_next = 0x7ffff7ffe8b0, l_prev = 0x7ffff7ffe2e0, l_real = 0x7ffff7ffdad0 <_rtld_global 2736>, l_ns = 0, l_libname = 0x7ffff7ffe280 <_dl_rtld_libname>, l_info = {0x0, 0x0, 0x7ffff7ffcea0, 0x7ffff7ffce90, 0x7ffff7ffce30, 0x7ffff7ffce50, 0x7ffff7ffce60, 0x7ffff7ffced0, 0x7ffff7ffcee0, 0x7ffff7ffcef0, 0x7ffff7ffce70, 0x7ffff7ffce80, 0x0, 0x0, 0x7ffff7ffce20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7ffff7ffceb0, 0x0, 0x0, 0x7ffff7ffcec0, 0x0 <repeats 11 times>, 0x7ffff7ffcf40, 0x7ffff7ffcf30, 0x7ffff7ffcf50, 0x0, 0x0, 0x7ffff7ffcf10, 0x7ffff7ffcf00, 0x0 <repeats 11 times>, 0x7ffff7ffcf20, 0x0 <repeats 25 times>, 0x7ffff7ffce40}, l_phdr = 0x7ffff7fcb040, l_entry = 0, l_phnum = 9, l_ldnum = 0, l_searchlist = {r_list = 0x0, r_nlist = 0}, l_symbolic_searchlist = {r_list = 0x0, r_nlist = 0}, l_loader = 0x0, l_versions = 0x0, l_nversions = 0, l_nbuckets = 37, l_gnu_bitmask_idxbits = 3, l_gnu_shift = 8, l_gnu_bitmask = 0x7ffff7fcb3b0, {l_gnu_buckets = 0x7ffff7fcb3d0, l_chain = 0x7ffff7fcb3d0}, {l_gnu_chain_zero = 0x7ffff7fcb460, l_buckets = 0x7ffff7fcb460}, l_direct_opencount = 0, l_type = lt_library, l_dt_relr_ref = 0, l_relocated = 1, l_init_called = 0, l_global = 0, l_reserved = 0, l_main_map = 0, l_visited = 0, l_map_used = 0, l_map_done = 0, l_phdr_allocated = 0, l_soname_added = 0, l_faked = 0, l_need_tls_init = 0, l_auditing = 0, l_audit_any_plt = 0, l_removed = 0, l_contiguous = 0, l_free_initfini = 0, l_ld_readonly = 0, l_find_object_processed = 0, l_nodelete_active = false, l_nodelete_pending = false, l_property = lc_property_unknown, l_x86_feature_1_and = 0, l_x86_isa_1_needed = 0, l_1_needed = 0, l_rpath_dirs = {dirs = 0x0, malloced = 0}, l_reloc_result = 0x0, l_versyms = 0x0, l_origin = 0x0, l_map_start = 140737353920512, l_map_end = 140737354130136, l_text_end = 140737354075857, l_scope_mem = {0x0, 0x0, 0x0, 0x0}, l_scope_max = 0, l_scope = 0x0, l_local_scope = {0x0, 0x0}, l_file_id = {dev = 0, ino = 0}, l_runpath_dirs = {dirs = 0x0, malloced = 0}, l_initfini = 0x0, l_reldeps = 0x0, l_reldepsmax = 0, l_used = 0, l_feature_1 = 0, l_flags_1 = 0, l_flags = 0, l_idx = 0, l_mach = {plt = 0, gotplt = 0, tlsdesc_table = 0x0}, l_lookup_cache = {sym = 0x0, type_class = 0, value = 0x0, ret = 0x0}, l_tls_initimage = 0x0, l_tls_initimage_size = 0, l_tls_blocksize = 0, l_tls_align = 0, l_tls_firstbyte_offset = 0, l_tls_offset = 0, l_tls_modid = 0, l_tls_dtor_count = 0, l_relro_addr = 199136, l_relro_size = 5664, l_serial = 0}, _dl_rtld_auditstate = {{cookie = 0, bindflags = 0} <repeats 16 times>}, _dl_x86_feature_1 = 0, _dl_x86_feature_control = {ibt = cet_elf_property, shstk = cet_elf_property}, _dl_stack_flags = 6, _dl_tls_dtv_gaps = false, _dl_tls_max_dtv_idx = 4, _dl_tls_dtv_slotinfo_list = 0x0, _dl_tls_static_nelem = 0, _dl_tls_static_used = 0, _dl_tls_static_optional = 0, _dl_initial_dtv = 0x0, _dl_tls_generation = 0, _dl_scope_free_list = 0x0, _dl_stack_used = {next = 0x7ffff7ffe0c0 <_rtld_global 4256>, prev = 0x7ffff7ffe0c0 <_rtld_global 4256>}, _dl_stack_user = {next = 0x7ffff7ffe0d0 <_rtld_global 4272>, prev = 0x7ffff7ffe0d0 <_rtld_global 4272>}, _dl_stack_cache = {next = 0x7ffff7ffe0e0 <_rtld_global 4288>, prev = 0x7ffff7ffe0e0 <_rtld_global 4288>}, _dl_stack_cache_actsize = 0, _dl_in_flight_stack = 0, _dl_stack_cache_lock = 0}
#13 0x0000000000000002 in ?? ()
No symbol table info available.
#14 0x00007fffffffdaa2 in ?? ()
No symbol table info available.
#15 0x00007fffffffdaef in ?? ()
No symbol table info available.
#16 0x0000000000000000 in ?? ()
No symbol table info available.
@cgzones cgzones added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Dec 16, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 16, 2022
@Noratrieb Noratrieb added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Dec 16, 2022
@jyn514 jyn514 changed the title rustc 1.66.0 requires execstack rustc 1.66.0 requires execstack to load libLLVM.so Dec 16, 2022
@Noratrieb
Copy link
Member

Can you bisect this using https://github.com/rust-lang/cargo-bisect-rustc?

@apiraino apiraino added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 21, 2022
@teohhanhui
Copy link

Clearing the executable stack flag:

execstack -c libLLVM-15-rust-1.66.0-stable.so

seems to work (at least cargo build is working correctly as before for the project I'm working on...)

@draeath
Copy link

draeath commented Jan 1, 2023

Ran into this today on OpenSuse MicroOS.

@teohhanhui that workaround works, though I don't understand the ramifications of it.

@cgzones
Copy link
Author

cgzones commented Jan 2, 2023

Probably the library was build on a non-GNU platform (Windows?), so the linker did not add a GNU_STACK program header. (The absence of that header is treated the same as explicitly specifying an executable stack.)

@apiraino apiraino added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jan 6, 2023
@teohhanhui

This comment was marked as off-topic.

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 25, 2023
@cgzones
Copy link
Author

cgzones commented Jan 25, 2023

There is no need for reproducing, one can analyze the shared library:

readelf -lW $(find ~/.rustup/ -name libLLVM-*-rust-*-stable.so) | grep GNU_STACK

should return

  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x8

@Noratrieb
Copy link
Member

The presence of GNU_STACK tells the loader to not set the stack as executable on legacy systems, so this is an indication of the absence of this bug.

@dangowrt
Copy link

dangowrt commented Apr 3, 2023

Still seeing this on gentoo/SELinux

rustc: error while loading shared libraries: libLLVM-15-rust-1.68.1-stable.so: cannot enable executable stack as shared object requires: Permission denied

And no, I don't want to switch off SELinux or enable executable stack system wide. Any ideas? This is a regression as things used to work just fine with older versions of the rust-bin package...

@Noratrieb
Copy link
Member

@dangowrt
Since you're on such a system, are you able to use cargo-bisect-rustc to bisect the change? That would be hugely valuable and help actually figuring out what's going on.

@dangowrt
Copy link

dangowrt commented Apr 3, 2023

Unfortunately no as the system is too resource constraint and I don't have enough RAM to build LLVM from source, hence I'm using the rust-bin package, and I've tried all currently available versions of it starting from 1.66.1-stable rustc breaks...

@Noratrieb
Copy link
Member

You don't need to build anything from source if you have access to rustup. https://github.com/rust-lang/cargo-bisect-rustc downloads CI artifacts (so it does need internet access). If you can't use it, then it would at least be nice if you could bisect nightlies instead of stables, which are a lot more coarse.

@cgzones
Copy link
Author

cgzones commented Apr 3, 2023

Fedora reproducer:

test.sh:

#!/bin/sh

rustc --version

Procedure:

# rustup installation

cargo install cargo-bisect-rustc

sudo setsebool selinuxuser_execstack off

cargo bisect-rustc --start=1.65.0 --end=1.68.2 --script ./test.sh

Result:

searched toolchains nightly-2022-09-17 through nightly-2023-01-22


********************************************************************************
Regression in nightly-2022-10-11
********************************************************************************

fetching https://static.rust-lang.org/dist/2022-10-10/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-10-10: 40 B / 40 B [=================================================================================================================] 100.00 % 448.77 KB/s converted 2022-10-10 to 81f391930301afbc121b7c468138069daa354bf8
fetching https://static.rust-lang.org/dist/2022-10-11/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-10-11: 40 B / 40 B [=================================================================================================================] 100.00 % 507.02 KB/s converted 2022-10-11 to a6b7274a462829f8ef08a1ddcdcec7ac80dbf3e1
looking for regression commit between 2022-10-10 and 2022-10-11
opening existing repository at "rust.git"
Found origin remote under name `origin`
refreshing repository at "rust.git"
fetching (via local git) commits from 81f391930301afbc121b7c468138069daa354bf8 to a6b7274a462829f8ef08a1ddcdcec7ac80dbf3e1
opening existing repository at "rust.git"
Found origin remote under name `origin`
refreshing repository at "rust.git"
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 7 bors merge commits in the specified range
  commit[0] 2022-10-09: Auto merge of #102850 - JohnTitor:rollup-lze1w03, r=JohnTitor
  commit[1] 2022-10-09: Auto merge of #89123 - the8472:push_in_capacity, r=amanieu
  commit[2] 2022-10-10: Auto merge of #102867 - JohnTitor:rollup-qnwsajt, r=JohnTitor
  commit[3] 2022-10-10: Auto merge of #94381 - Kobzol:llvm-bolt, r=Mark-Simulacrum
  commit[4] 2022-10-10: Auto merge of #102875 - Dylan-DPC:rollup-zwcq8h9, r=Dylan-DPC
  commit[5] 2022-10-10: Auto merge of #96711 - emilio:inline-slice-clone, r=nikic
  commit[6] 2022-10-10: Auto merge of #102596 - scottmcm:option-bool-calloc, r=Mark-Simulacrum
ERROR: no CI builds available between 81f391930301afbc121b7c468138069daa354bf8 and a6b7274a462829f8ef08a1ddcdcec7ac80dbf3e1 within last 167 days

Probably cause: #94381

Maybe ldflags in

fn run(self, builder: &Builder<'_>) -> LlvmResult {
should include -Wl,-z,noexecstack.

@lqd
Copy link
Member

lqd commented Apr 3, 2023

cc @Kobzol for that last comment

@Kobzol
Copy link
Contributor

Kobzol commented Apr 4, 2023

I don't think that this is caused by missing LLVM linker flags, rather it is caused by BOLT. I used execstack on a BOLT optimized library. When I used the -use-gnu-stack option when optimizing the binary with BOLT, the state of the binary changed from - (doesn't require executable stack) to ? (unknown whether it requires executable stack). Maybe the GNU_STACK attribute confuses SELinux somehow?

Perhaps counterintuitively, when -use-gnu-stack is used, the GNU_STACK attribute disappears from the executable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants