3
5
Fork 0
mirror of git://git.savannah.gnu.org/guix.git synced 2023-12-14 03:33:07 +01:00

gnu: qemu: Fix ioctl(…, SIOCGIFCONF, …) for emulated 64 bit architectures.

* gnu/packages/virtualization.scm (qemu): Add a snippet to fix a bug in the
do_ioctl_ifconf() function of qemu to make ioctl(…, SIOCGIFCONF, …) work for
emulated 64 bit architectures.

The sizeof(struct ifreq) is 40 for 64 bit and 32 for 32 bit architectures.
This structure contains a union of other structures, of which struct ifmap
is the biggest for 64 bit architectures. Calling ioctl(…, SIOCGIFCONF, …)
fills a struct sockaddr of that union, and do_ioctl_ifconf() only considered
that struct sockaddr for the size of the union, which has the same size as
struct ifmap on 32 bit architectures. So do_ioctl_ifconf() assumed a wrong
size of 32 for struct ifreq instead of the correct size of 40 on 64 bit
architectures.

The fix makes do_ioctl_ifconf() handle struct ifmap as the biggest part of
the union, treating struct ifreq with the correct size.

This fixes (@ (guix build syscalls) network-interface-names) when used in
emulated 64 bit architectures.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Stefan 2021-01-11 21:32:47 +01:00 committed by Ludovic Courtès
parent 4f38e0e47b
commit 795db9d219
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -137,13 +137,28 @@
(method url-fetch)
(uri (string-append "https://download.qemu.org/qemu-"
version ".tar.xz"))
(sha256
(base32
"1rd41wwlvp0vpialjp2czs6i3lsc338xc72l3zkbb7ixjfslw5y9"))
(patches (search-patches "qemu-build-info-manual.patch"))))
(outputs '("out" "doc")) ;4.7 MiB of HTML docs
(build-system gnu-build-system)
(arguments
(sha256
(base32
"1rd41wwlvp0vpialjp2czs6i3lsc338xc72l3zkbb7ixjfslw5y9"))
(patches (search-patches "qemu-build-info-manual.patch"))
(modules '((guix build utils)))
(snippet
'(begin
;; Fix a bug in the do_ioctl_ifconf() function of qemu to
;; make ioctl(…, SIOCGIFCONF, …) work for emulated 64 bit
;; architectures. The size of struct ifreq is handled
;; incorrectly.
;; https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01545.html
(substitute* '("linux-user/syscall.c")
(("^([[:blank:]]*)const argtype ifreq_arg_type.*$" line indent)
(string-append line indent
"const argtype ifreq_max_type[] = { MK_STRUCT(STRUCT_ifmap_ifreq) };\n"))
(("^([[:blank:]]*)target_ifreq_size[[:blank:]]=.*$" _ indent)
(string-append indent "target_ifreq_size = thunk_type_size(ifreq_max_type, 0);")))
#t))))
(outputs '("out" "doc")) ;4.7 MiB of HTML docs
(build-system gnu-build-system)
(arguments
`(;; FIXME: Disable tests on i686 to work around
;; <https://bugs.gnu.org/40527>.
#:tests? ,(or (%current-target-system)