Re: [PATCH hurd] rumpdisk: Include complete USB stack to enable mass storage driver

2023-06-25 Thread Damien Zammit
Hi Samuel, On 26/6/23 02:41, Samuel Thibault wrote: >> This simple change allows hurd to be bootable off usb! > > Well, yes and no :) > > We also need /dev entries. It happens that this re-uses /dev/sd* > names, so we need to care about compatibility. We probably want > rumpdisk_device_open to f

[PATCH 5/5] hurd: Implement MAP_EXCL

2023-06-25 Thread Sergey Bugaev
MAP_FIXED is defined to silently replace any existing mappings at the address range being mapped over. This, however, is a dangerous, and only rarely desired behavior. Various Unix systems provide replacements or additions to MAP_FIXED: * SerenityOS and Linux provide MAP_FIXED_NOREPLACE. If the a

[PATCH 2/5] hurd: Map brk non-executable

2023-06-25 Thread Sergey Bugaev
The rest of the heap (backed by individual pages) is already mapped RW. Mapping these pages RWX presents a security hazard. Also, in another branch memory gets allocated using vm_allocate, which sets memory protection to VM_PROT_DEFAULT (which is RW). The mismatch between protections prevents Mach

[PATCH 3/5] hurd: Fix calling vm_deallocate (NULL)

2023-06-25 Thread Sergey Bugaev
Only call vm_deallocate when we do have the old buffer, and check for unexpected errors. Spotted while debugging a msgids/readdir issue on x86_64-gnu. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/readdir64.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sy

[PATCH 4/5] hurd: Fix mapping at address 0 with MAP_FIXED

2023-06-25 Thread Sergey Bugaev
Zero address passed to mmap () typically means the caller doesn't have any specific preferred address. Not so if MAP_FIXED is passed: in this case 0 means literal 0. Fix this case to pass anywhere = 0 into vm_map. Also add some documentation. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/m

[PATCH 1/5] htl: Let Mach place thread stacks

2023-06-25 Thread Sergey Bugaev
Instead of trying to allocate a thread stack at a specific address, looping over the address space, just set the ANYWHERE flag in vm_allocate (). The previous behavior: - defeats ASLR (for Mach versions that support ASLR), - is particularly slow if the lower 4 GB of the address space are mapped

[PATCH 2/4] Allow the process owner to perform all privileged operations

2023-06-25 Thread Sergey Bugaev
The user already has full access to our task, and the same kind of access to the file system image (if any) as our task does, we're not buying any additional security by disallowing them access. In practice, this allows creating and arbitrarily modifying ext2 filesystem images owned by an otherwis

[PATCH 3/4] exec: On 64-bit, map lower 4 GB inaccessible for PIEs

2023-06-25 Thread Sergey Bugaev
We want to map the whole lower 4 GB of address space inaccessible to catch accidental pointer truncation. We can only do this when the executable (as well as the interpreter, if any) is compiled as PIC/PIE, since otherwise we would violate the ABI requirement. Fortunately most distributions have al

[PATCH 4/4] exec: Properly preallocate address space

2023-06-25 Thread Sergey Bugaev
The existing code mapped the first PT_LOAD segment using anywhere=1, letting Mach pick an arbitrary location, and then uses anywhere=0 for all the remaining segments to place them next to the first one, as expected by the program. This, however, runs into many issues, primarily because of conflict

[PATCH 1/4] libdiskfs: Don't warn if requesting shutdown notification fails with EPERM

2023-06-25 Thread Sergey Bugaev
The code already ignores proc_mark_important failing with EPERM; do the same for opening /servers/startup and startup_request_notification. All of these calls will fail for unprivileged mounts. Also plug a port leak: we want to deallocate the "init" port whether the RPC succeeds or not. --- libdi

Re: [PATCH hurd] rumpdisk: Include complete USB stack to enable mass storage driver

2023-06-25 Thread Samuel Thibault
Damien Zammit, le dim. 25 juin 2023 12:35:51 +, a ecrit: > This simple change allows hurd to be bootable off usb! Well, yes and no :) We also need /dev entries. It happens that this re-uses /dev/sd* names, so we need to care about compatibility. We probably want rumpdisk_device_open to forwar

Re: [PATCH libacpica] Allow read/write to pci config

2023-06-25 Thread Samuel Thibault
Damien Zammit, le dim. 25 juin 2023 01:36:34 +, a ecrit: > @@ -405,16 +408,16 @@ Add acgnu.h and acgnuex.h > +acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, > + u64 *value, u32 width) > +{ > -+ acpi_os_printf("ACPI: Tried to read pci config\n"); > -+ retur

Re: [PATCH hurd] rumpdisk: Include complete USB stack to enable mass storage driver

2023-06-25 Thread Guy-Fleury Iteriteka
On June 25, 2023 2:35:51 PM GMT+02:00, Damien Zammit wrote: >This simple change allows hurd to be bootable off usb! A running hurd can then recognize a usb storage > >It is not ideal to have entire usb stack with the mass storage driver >and combined with SATA, but there is no easy way to separa

[PATCH hurd] rumpdisk: Include complete USB stack to enable mass storage driver

2023-06-25 Thread Damien Zammit
This simple change allows hurd to be bootable off usb! It is not ideal to have entire usb stack with the mass storage driver and combined with SATA, but there is no easy way to separate the usb stack into host/device yet. This centralises all the disk support, (and unfortunately also all the usb