All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan <stefan-guix@vodafonemail.de>
To: Laurent Vivier <laurent@vivier.eu>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [PATCH 1/1] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit targets.
Date: Mon, 18 Jan 2021 21:18:42 +0100	[thread overview]
Message-ID: <5B52EBE5-2490-4997-B7CB-944DE3F3AB6D@vodafonemail.de> (raw)
In-Reply-To: <57408fa3-8201-b8b5-aa8d-50448a010f43@vivier.eu>

Hi Laurent!

Thanks for your response.

> Why don't you simply replace STRUCT_sockaddr_ifreq by STRUCT_ifmap_ifreq rather than introducing a
> new constant?

Because STRUCT_sockaddr_ifreq is the union part to be filled and is needed as an argument to thunk_convert() in this loop below:

            for (i = 0; i < nb_ifreq ; i++) {
                thunk_convert(argptr + i * target_ifreq_size,
                              host_ifc_buf + i * sizeof(struct ifreq),
                              ifreq_arg_type, THUNK_TARGET);
            }

> In the "if (!is_error(ret))", why don't you use the same size with the part that copies back the
> values to the user?

I’m not sure if I understand your question correctly. Well, ioclt(…, SIOCGIFCONF, …) returns an array of struct ifreq, which contains a union, of which only struct sockaddr ifr_addr needs to be filled. But that union element is not the biggest element on 64 bit architectures.

Without the fix the returned data is not an array of struct ifreq but an array of some artificial struct:

struct sockaddr_ifreq {
    char ifr_name[IFNAMSIZ]; /* Interface name */
    struct sockaddr ifr_addr;
}

That artificial struct is too short for 64 bit architectures. On real x86_64 systems the size of the array returned by ioclt(…, SIOCGIFCONF, …) is a multiple of 40 bytes, the sizeof(struct ifreq). And it’s also a multiple of 40 on real aarch64 systems. However, on x86_64 emulating aarch64 with qemu, the returned array size is only a multiple of 32 bytes, which is wrong. It is enough to fill only 32 bytes with thunk_convert() and ifreq_arg_type is also the proper type, but the array element increase has to be 40 bytes.

I hope this clarifies your question.


Bye

Stefan

  reply	other threads:[~2021-01-18 20:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09 18:59 [PATCH 1/1] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit targets Stefan
2021-01-17 13:00 ` Stefan
2021-01-18 14:03 ` Laurent Vivier
2021-01-18 20:18   ` Stefan [this message]
2021-02-06 14:11     ` Stefan
2021-02-13 19:07 ` Laurent Vivier
2021-02-13 19:22 ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5B52EBE5-2490-4997-B7CB-944DE3F3AB6D@vodafonemail.de \
    --to=stefan-guix@vodafonemail.de \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.