aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
AgeCommit message (Collapse)AuthorFilesLines
2022-11-22aarch64: morello: bump min linux version to 5.18.0Szabolcs Nagy2-2/+2
2022-11-17cheri: Fix pselect signal mask argumentSzabolcs Nagy1-5/+12
The signal mask argument is passed as a struct with a pointer and size in the linux syscall abi, but the types used in glibc were wrong for CHERI due to an x32 specific hack.
2022-10-27cheri: malloc: Capability narrowing using internal lookup tableSzabolcs Nagy2-3/+301
Add more cap_ hooks to implement narrowing without depending on a global capability covering the heap. Either recording every narrowed capability in a lookup table or recording every mapping used for the heap are supported. The morello implmentation uses a lookup table for now. The lookup table adds memory overhead, failure paths and locks. Recording and removing entries from the lookup table must be done carefully in realloc so on failure the old pointer is usable and on success the old pointer is immediately reusable concurrently. The locks require fork hooks so malloc works in multi-threaded fork child.
2022-10-27cheri: malloc: Initial capability narrowing supportSzabolcs Nagy2-0/+100
Public interfaces return pointers with narrow bounds, this internally requires bumping the size and alignment requirement of allocations so the bounds are representible. When pointers with narrow bounds need to be turned back to have wide bounds (free, realloc), the pointer is rederived from DDC. (So this patch relies on DDC to cover all heap memory with RW permission.) Allocations above the mmap threshold waste memory for alignment and realloc often falls back to the inefficient alloc, copy, free sequence instead of mremap or other inplace solution.
2022-10-27cheri: Update libc.abilist for getauxptrCarlos Eduardo Seo36-0/+72
Updates libc.abilist files for getauxptr to version 2.37.
2022-10-27cheri: stdio-common: Add test for %#p printf modifierCarlos Eduardo Seo2-0/+101
Testcase for printing capabilities.
2022-10-27cheri: Fix sigevent ABISzabolcs Nagy1-1/+5
Adjust padding to accommodate pointer size and alignment increase.
2022-10-27cheri: fix posix timersSzabolcs Nagy1-0/+20
We need to distinguish timerids that are small integers returned by the kernel and timerids that are pointers to struct timer. The existing pointer tagging does not work for CHERI because of the pointer shift. Simply use the top bit without shift to tag pointers. This still relies on the top byte ignore of aarch64 (the top byte does not affect the capability representation) and that pointers are not tagged for other reasons (like HWASAN). Note: this is morello specific and does not work for generic cheri.
2022-10-27TODO(uapi): cheri: start: restrict auxv capability permissionsSzabolcs Nagy2-0/+4
TODO: not needed with full pcuabi
2022-10-27aarch64: morello: fix DL_SYMBOL_ADDRESSSzabolcs Nagy6-2/+67
It has to return a pointer that can be dereferenced, so it must be derived correctly from RX and RW capabilities. Try to have tight object bounds and seal function symbols.
2022-10-27aarch64: morello: add D_PTR_RWSzabolcs Nagy2-1/+5
Writable version of D_PTR, required for updating GOT[1] and GOT[2].
2022-10-27aarch64: morello: Return bounded pointer in __tls_get_addrSzabolcs Nagy3-9/+65
There is no traditional TLS support in morello that would explicitly call __tls_get_addr, but the libc uses it internally and the returned pointer escapes to user code. So bound the pointers according to the tls symbol size instead of doing so in each caller. (Affects dlsym and dynamic TLSDESC.)
2022-10-27aarch64: morello: dynamic linking supportSzabolcs Nagy8-2/+856
Add morello specific dl-machine.h. Add morello dynamic relocation processing support for purecap ABI. Only support R_AARCH64_NONE, R_AARCH64_ABS64 and R_AARCH64_RELATIVE dynamic relocs from the lp64 ABI. RELATIVE and IRELATIVE relocs use a helper function from cheri-rel.h to construct a capability. Also fixed the IRELATIVE handling for static linking. Use new machine routines on morello for load address computation so it is a valid capability: void *elf_machine_runtime_dynamic (void) void elf_machine_rtld_base_setup (struct link_map *map, void *args) The ld.so load address and RX, RW capabilities are derived from auxv and the RW ranges are set up based on the ld.so program headers early. __tls_get_addr should return a bounded pointer instead of fixing it in _dl_make_tlsdesc_dynamic, this is done in a separate patch.
2022-10-27aarch64: morello: add lazy binding entry codeSzabolcs Nagy1-0/+136
2022-10-27cheri: elf: fix SYMBOL_ADDRESS to return RX derived pointerSzabolcs Nagy1-2/+5
All symbol addresses can be derived from the RX capability of the module (l_map_start). For RW object symbols pointer will have to be rederived from l_rw_start.
2022-10-27cheri: elf: Use elfptr_t for function symbol fixupSzabolcs Nagy1-1/+1
Propagate capabilities during lazy binding and IFUNC fixup in dlsym.
2022-10-27aarch64: morello: add dl-r_debug.hSzabolcs Nagy1-0/+61
Used internally for r_debug tests, but with the assumption that the return value can be dereferenced, so change the prototype and return a valid capability. Also used in pldd, where we only support purecap abi processes.
2022-10-27aarch64: elf: avoid loading incompatible binariesSzabolcs Nagy1-1/+2
Prevent lp64 ld.so loading purecap binaries.
2022-10-27cheri: elf: use RX, RW capabilities to derive pointersSzabolcs Nagy1-1/+2
Instead of map->l_addr + offset use dl_rx_ptr (map, offset) dl_rw_ptr (map, offset) depending on RX or RW permission requirement.
2022-10-27cheri: elf: change l_entry to be elfptr_tSzabolcs Nagy2-5/+5
It is simpler and more consistent to make l_entry a capability throughout instead of leaving it as an address and converting before use: The AT_ENTRY auxv entry is specified to be a capability and a number if internal l_entry usage is simpler if it is elfptr_t. Functions returning a pointer to the user entry are also changed to use elfptr_t.
2022-10-27aarch64: morello: add purecap ld.so _start codeSzabolcs Nagy1-0/+110
The purecap version of aarch64 dl-start.S. Note: self relocation of ld.so is handled by the rtld bootstrap code. The ldso internal _dl_start still expects continuous argc, argv, envp, auxv, so that's emulated (since the purecap ELF entry passes them in separate registers).
2022-10-27aarch64: morello: rtld: define DL_RO_DYN_SECTIONSzabolcs Nagy1-0/+25
The dynamic section cannot be relocated to hold pointers in place.
2022-10-27aarch64: morello: fix ldconfig for purecap abiSzabolcs Nagy4-1/+20
Add purecap ld cache flag. Add the purecap ld.so name to known names. Handle lib64c system library paths. And set the purecap abi flag on cache entries.
2022-10-27aarch64: morello: disable the vpcs testSzabolcs Nagy1-1/+1
The asm code of the test is for lp64 ABI only.
2022-10-27aarch64: morello: add purecap ucontext supportCarlos Eduardo Seo9-0/+493
Adjust ucontext layout for purecap ABI and add make/get/set/swapcontext implementations accordingly. Note: mcontext layout follows the linux sigcontext struct, in userspace *context functions rely on the c registers stored in the extension area and ignore the mcontext fields for x registers.
2022-10-27aarch64: morello: add purecap setjmp/longjmpCarlos Eduardo Seo3-1/+176
Similar to lp64 setjmp/longjmp, but handles capability registers. Save q regs instead of d regs to simplify the offset computation.
2022-10-27cheri: rseq: remove const to avoid readonly permissionSzabolcs Nagy1-0/+14
Using const on the definition does not work for a pure capability ABI: the capability permissions when accessing the object will be read only. Use a hack to hide the public declaration in the TU where the const objects are initialized. (This should work on non-capability targets too, but to err on the safe side only enable the hack on capability targets.)
2022-10-27cheri: Fix capability permissions of PROT_NONE maps in test codeSzabolcs Nagy1-1/+1
2022-10-27aarch64: morello: nptl: fix thread pointer setupSzabolcs Nagy1-0/+5
2022-10-27aarch64: morello: nptl: fix pthread types for 128 bit pointersSzabolcs Nagy1-1/+11
2022-10-27cheri: nptl: fix pthread_attr_t alignmentSzabolcs Nagy1-0/+1
Alignment of the public definition did not match the internal layout. Ensure that the type is at least pointer aligned.
2022-10-27cheri: nptl: fix thread ID types for capabilitiesSzabolcs Nagy2-0/+8
2022-10-27cheri: Implement 128-bit atomicsSzabolcs Nagy1-0/+21
Arm Morello requires 128-bit atomics.
2022-10-27cheri: Setup RX, RW capabilities for static linkingSzabolcs Nagy1-2/+7
At least tls image access requires RX capability of the main link_map.
2022-10-27cheri: elf: add dl_{rx,rw}_ptr to derive addresses within a mapSzabolcs Nagy1-0/+28
To derive pointers within a module from the per module RX and RW caps.
2022-10-27cheri: fix static linking early allocationSzabolcs Nagy1-1/+1
Store mmap result to intptr_t instead of long.
2022-10-27cheri: don't use dl_random for pointer manglingSzabolcs Nagy1-0/+5
Pointer mangling cannot be supported on capability architectures. And there is not enough bytes in dl_random for 128 bit pointers. Stack guard is still loaded from dl_random: stack protection is unlikely to be useful on a capability architecture, but it works.
2022-10-27aarch64: morello: add purecap start codeSzabolcs Nagy2-0/+215
Written in C so the self relocation code in crt1.o is easier to maintain. The purecap ELF entry is special: passes separate argc, argv, envp, auxv in registers instead of on the stack. For each module there will be separate RW and RX capabilities that cover the writable and all load segments respectively. The relative reloc processing code is prepared for such separate capabilities. The static link detection (for self relocation) is not ideal, it relies on relocations that don't work in PIC, so it is ifdefed out for Scrt1.o. (Currently adrp of undefined weak symbol is not fixed up by the linker to be 0 so we use movz to detect the presence of __rela_dyn_start.)
2022-10-27cheri: change __libc_start_main prototypeSzabolcs Nagy1-0/+32
The prototype of __libc_start_main is changed to void __libc_start_main (int main (int, char **, char **, void *), int argc, char **argv, char **envp, void *auxv, void rtld_fini (void), void *sp); so envp is passed down separately and the unused init, fini args are dropped.
2022-10-27aarch64: morello: purecap crti.S and crtn.SCarlos Eduardo Seo2-0/+141
Purecap ABI versions of crti.S and crtn.S.
2022-10-27cheri: aarch64: Add header for CHERI permissionsCarlos Eduardo Seo1-0/+84
New file containing the capability permission bits. The capability permission bits are defined in the Arm Architecture Reference Manual Suplement- Morello for A-Profile Architecture: https://developer.arm.com/documentation/ddi0606/latest
2022-10-27cheri: elf: use elfptr_t for auxv parsingSzabolcs Nagy1-2/+2
2022-10-27TODO(uapi): narrow capability in mmap and mremapSzabolcs Nagy2-3/+40
This is a temporary workaround. length is rounded up to pagesize and don't use exact bound (bounds will be larger if exact value is not representable). capability permissions are roughly emulated too. TODO: kernel should do this
2022-10-27TODO(uapi): aarch64: morello: add HWCAP2_MORELLOSzabolcs Nagy1-0/+1
TODO: this is the value in the 5.18 kernel, will change later.
2022-10-27TODO(uapi): aarch64: morello: use non-ifunc gettimeofdaySzabolcs Nagy1-1/+3
TODO: Remove this once morello has vdso gettimeofday.
2022-10-27TODO(uapi): aarch64: morello: make brk always failSzabolcs Nagy1-0/+25
TODO: drop this once linux brk always fails.
2022-10-27TODO(uapi): cheri: fix clone_argsSzabolcs Nagy2-0/+27
Current clone_args does not support 128 bit pointers. TODO: the fix is incomplete (missing clone3 abi checks) and has to be aligned with purecap clone3 struct layout.
2022-10-27aarch64: morello: define PROT_MAXSzabolcs Nagy1-0/+3
Specifies the prot flags a mapping may gain via mprotect or MAP_FIXED. On CHERI targets this is used to get capability with more permissions than the original mmap protection would imply.
2022-10-27aarch64: morello: fix missing variadic argument in fcntlSzabolcs Nagy3-2/+12
In fcntl va_arg is currently used even if the caller did not pass any variadic arguments. This is undefined behaviour and does not work with the Morello purecap ABI, so use a helper macro. When the argument is missing, the result of the helper macro is arbitrary as it will be ignored by the kernel, we just have to ensure it does not cause a runtime crash.
2022-10-27aarch64: morello: add prctl with correct vararg handlingSzabolcs Nagy1-0/+44
prctl is a variadic function and on morello args that were not passed cannot be accessed so the generic code does not work.