35be898e | 30-Jun-2023 |
Ilya Leoshkevich <iii@linux.ibm.com> |
linux-user: Add "safe" parameter to do_guest_openat()
gdbstub cannot meaningfully handle QEMU_ERESTARTSYS, and it doesn't need to. Add a parameter to do_guest_openat() that makes it use openat() ins
linux-user: Add "safe" parameter to do_guest_openat()
gdbstub cannot meaningfully handle QEMU_ERESTARTSYS, and it doesn't need to. Add a parameter to do_guest_openat() that makes it use openat() instead of safe_openat(), so that it becomes usable from gdbstub.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230621203627.1808446-3-iii@linux.ibm.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230630180423.558337-33-alex.bennee@linaro.org>
show more ...
|
e9289071 | 27-Mar-2023 |
Andrew Jeffery <andrew@aj.id.au> |
linux-user: elfload: Specify -R is an option for qemu-user binaries
Given several different concepts are suggested for investigation, let's not confuse e.g. ulimit's -R with what was actually intend
linux-user: elfload: Specify -R is an option for qemu-user binaries
Given several different concepts are suggested for investigation, let's not confuse e.g. ulimit's -R with what was actually intended.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
show more ...
|
f101c25c | 27-Mar-2023 |
Andrew Jeffery <andrew@aj.id.au> |
linux-user: elfload: s/min_mmap_addr/mmap_min_addr/
As-is the error message can cause some confusion as the mentioned sysctl attribute name is wrong:
https://www.kernel.org/doc/html/latest/admin-gu
linux-user: elfload: s/min_mmap_addr/mmap_min_addr/
As-is the error message can cause some confusion as the mentioned sysctl attribute name is wrong:
https://www.kernel.org/doc/html/latest/admin-guide/sysctl/vm.html#mmap-min-addr
Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
show more ...
|
8fbf89a9 | 09-Jun-2023 |
Peter Maydell <peter.maydell@linaro.org> |
linux-user: Return EINVAL for getgroups() with negative gidsetsize
Coverity doesn't like the way we might end up calling getgroups() with a NULL grouplist pointer. This is fine for the special case
linux-user: Return EINVAL for getgroups() with negative gidsetsize
Coverity doesn't like the way we might end up calling getgroups() with a NULL grouplist pointer. This is fine for the special case of gidsetsize == 0, but we will also do it if the guest passes us a negative gidsetsize. (CID 1512465)
Explicitly fail the negative gidsetsize with EINVAL, as the kernel does. This means we definitely only call the libc getgroups() with valid parameters. It also brings the getgroups() code in to line with the setgroups() code.
Possibly Coverity may still complain about getgroups(0, NULL), but that would be a false positive.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
show more ...
|
1fb9bdaf | 05-Jun-2023 |
Ilya Leoshkevich <iii@linux.ibm.com> |
linux-user: Emulate /proc/cpuinfo on s390x
Some s390x userspace programs are confused when seeing a foreign /proc/cpuinfo [1]. Add the emulation for s390x; follow the respective kernel code structur
linux-user: Emulate /proc/cpuinfo on s390x
Some s390x userspace programs are confused when seeing a foreign /proc/cpuinfo [1]. Add the emulation for s390x; follow the respective kernel code structure where possible.
Output example:
vendor_id : IBM/S390 # processors : 12 bogomips per cpu: 13370.00 max thread id : 0 features : esan3 zarch stfle msa facilities : 0 1 2 3 4 7 9 16 17 18 19 21 22 24 25 27 30 31 32 33 34 35 37 40 41 45 49 51 52 53 57 58 61 69 71 72 75 76 77 129 130 131 135 138 146 148 processor 0: version = 00, identification = 000000, machine = 8561 processor 1: version = 00, identification = 100000, machine = 8561 [...]
cpu number : 0 version : 00 identification : 000000 machine : 8561
cpu number : 1 version : 00 identification : 100000 machine : 8561 [...]
[1] https://bugzilla.redhat.com/show_bug.cgi?id=2211472
Reported-by: Tulio Magno Quites Machado Filho <tuliom@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20230605113950.1169228-5-iii@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
e19807be | 05-Jun-2023 |
Ilya Leoshkevich <iii@linux.ibm.com> |
linux-user/elfload: Introduce elf_hwcap_str() on s390x
It is required for implementing /proc/cpuinfo emulation.
Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Ilya Leoshkevich <ii
linux-user/elfload: Introduce elf_hwcap_str() on s390x
It is required for implementing /proc/cpuinfo emulation.
Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20230605113950.1169228-4-iii@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
1e35d327 | 09-Apr-2023 |
Michael Tokarev <mjt@tls.msk.ru> |
linux-user: fix getgroups/setgroups allocations
linux-user getgroups(), setgroups(), getgroups32() and setgroups32() used alloca() to allocate grouplist arrays, with unchecked gidsetsize coming from
linux-user: fix getgroups/setgroups allocations
linux-user getgroups(), setgroups(), getgroups32() and setgroups32() used alloca() to allocate grouplist arrays, with unchecked gidsetsize coming from the "guest". With NGROUPS_MAX being 65536 (linux, and it is common for an application to allocate NGROUPS_MAX for getgroups()), this means a typical allocation is half the megabyte on the stack. Which just overflows stack, which leads to immediate SIGSEGV in actual system getgroups() implementation.
An example of such issue is aptitude, eg https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811087#72
Cap gidsetsize to NGROUPS_MAX (return EINVAL if it is larger than that), and use heap allocation for grouplist instead of alloca(). While at it, fix coding style and make all 4 implementations identical.
Try to not impose random limits - for example, allow gidsetsize to be negative for getgroups() - just do not allocate negative-sized grouplist in this case but still do actual getgroups() call. But do not allow negative gidsetsize for setgroups() since its argument is unsigned.
Capping by NGROUPS_MAX seems a bit arbitrary, - we can do more, it is not an error if set size will be NGROUPS_MAX+1. But we should not allow integer overflow for the array being allocated. Maybe it is enough to just call g_try_new() and return ENOMEM if it fails.
Maybe there's also no need to convert setgroups() since this one is usually smaller and known beforehand (KERN_NGROUPS_MAX is actually 63, - this is apparently a kernel-imposed limit for runtime group set).
The patch fixes aptitude segfault mentioned above.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Message-Id: <20230409105327.1273372-1-mjt@msgid.tls.msk.ru> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|
a0f8d270 | 04-Apr-2023 |
Daniil Kovalev <dkovalev@compiler-toolchain-for.me> |
linux-user: Fix mips fp64 executables loading
If a program requires fr1, we should set the FR bit of CP0 control status register and add F64 hardware flag. The corresponding `else if` branch stateme
linux-user: Fix mips fp64 executables loading
If a program requires fr1, we should set the FR bit of CP0 control status register and add F64 hardware flag. The corresponding `else if` branch statement is copied from the linux kernel sources (see `arch_check_elf` function in linux/arch/mips/kernel/elf.c).
Signed-off-by: Daniil Kovalev <dkovalev@compiler-toolchain-for.me> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Message-Id: <20230404052153.16617-1-dkovalev@compiler-toolchain-for.me> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|
f443a26c | 22-Apr-2023 |
Thomas Weißschuh <thomas@t-8ch.de> |
linux-user: Don't require PROT_READ for mincore
The kernel does not require PROT_READ for addresses passed to mincore. For example the fincore(1) tool from util-linux uses PROT_NONE and currently do
linux-user: Don't require PROT_READ for mincore
The kernel does not require PROT_READ for addresses passed to mincore. For example the fincore(1) tool from util-linux uses PROT_NONE and currently does not work under qemu-user.
Example (with fincore(1) from util-linux 2.38):
$ fincore /proc/self/exe RES PAGES SIZE FILE 24K 6 22.1K /proc/self/exe
$ qemu-x86_64 /usr/bin/fincore /proc/self/exe fincore: failed to do mincore: /proc/self/exe: Cannot allocate memory
With this patch:
$ ./build/qemu-x86_64 /usr/bin/fincore /proc/self/exe RES PAGES SIZE FILE 24K 6 22.1K /proc/self/exe
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20230422100314.1650-3-thomas@t-8ch.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|
64d06015 | 22-Apr-2023 |
Thomas Weißschuh <thomas@t-8ch.de> |
linux-user: Add new flag VERIFY_NONE
This can be used to validate that an address range is mapped but without being readable or writable.
It will be used by an updated implementation of mincore().
linux-user: Add new flag VERIFY_NONE
This can be used to validate that an address range is mapped but without being readable or writable.
It will be used by an updated implementation of mincore().
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20230422100314.1650-2-thomas@t-8ch.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|
b67e5cb4 | 24-Apr-2023 |
Thomas Huth <thuth@redhat.com> |
linux-user/main: Use list_cpus() instead of cpu_list()
This way we can get rid of the if'deffery and the XXX comment here (it's repeated in the list_cpus() function anyway).
Signed-off-by: Thomas H
linux-user/main: Use list_cpus() instead of cpu_list()
This way we can get rid of the if'deffery and the XXX comment here (it's repeated in the list_cpus() function anyway).
Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230424122126.236586-1-thuth@redhat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|
7f696cdd | 24-Apr-2023 |
Thomas Weißschuh <thomas@t-8ch.de> |
linux-user: Add open_tree() syscall
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20230424153429.276788-2-thomas@t-8ch.de> [lv: move
linux-user: Add open_tree() syscall
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20230424153429.276788-2-thomas@t-8ch.de> [lv: move declaration at the beginning of the block, define syscall] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|
4b2d2753 | 24-Apr-2023 |
Thomas Weißschuh <thomas@t-8ch.de> |
linux-user: Add move_mount() syscall
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> [lv: define syscall] Message-Id: <20230424153429.276788-1-thoma
linux-user: Add move_mount() syscall
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> [lv: define syscall] Message-Id: <20230424153429.276788-1-thomas@t-8ch.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|
59d11727 | 26-Apr-2023 |
Thomas Weißschuh <thomas@t-8ch.de> |
linux-user: report ENOTTY for unknown ioctls
The correct error number for unknown ioctls is ENOTTY.
ENOSYS would mean that the ioctl() syscall itself is not implemented, which is very improbable an
linux-user: report ENOTTY for unknown ioctls
The correct error number for unknown ioctls is ENOTTY.
ENOSYS would mean that the ioctl() syscall itself is not implemented, which is very improbable and unexpected for userspace.
ENOTTY means "Inappropriate ioctl for device". This is what the kernel returns on unknown ioctls, what qemu is trying to express and what userspace is prepared to handle.
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230426070659.80649-1-thomas@t-8ch.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
show more ...
|