From nobody Wed Nov 19 00:14:31 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1613393953; cv=none; d=zohomail.com; s=zohoarc; b=iWXtKwer8KoM0lun1YE+tQy5RdE3r/X5jDM9QuFhaa+o//EY3Svlw94bim9KegHg7aU9Pz6hn/+lmmJZiTrAlREpRb/3RyoYWg91zNZZJqF3rAW5vv7yOdUzV7lY1CwuTY+ZF1IIAwe8J80/TXHojE0NOuZ2MEYyjKIi3kghQ74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613393953; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Jx4WVQj3lwXRKiI2mt4eVS0IsJN5flJ0g2TYn8y0BFw=; b=dEVE8u1H5hdrocD674Pl2UttACDQvg7QYXk9m53Ac/Rk0NReQsBX/HQECAHMlp/FGiAhkFR7aKq8VluKl+CDpI/TO6fTtg6cg/II7Xdma/oygdyfxt8GJUO3IWHgfXTmRnvpyS2Sb54Cqbd1nevjivLOXQF2LZ9bv8Dfx+ZFAVo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613393952854987.9028714058106; Mon, 15 Feb 2021 04:59:12 -0800 (PST) Received: from localhost ([::1]:53670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdT5-0001lt-Pa for importer@patchew.org; Mon, 15 Feb 2021 07:59:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdFw-00047l-Oy for qemu-devel@nongnu.org; Mon, 15 Feb 2021 07:45:37 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:55601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdFt-0000hZ-Eo for qemu-devel@nongnu.org; Mon, 15 Feb 2021 07:45:36 -0500 Received: from localhost.localdomain ([82.252.134.158]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N2E5Q-1ls0C1003q-013h5C; Mon, 15 Feb 2021 13:45:27 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/13] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit targets. Date: Mon, 15 Feb 2021 13:45:15 +0100 Message-Id: <20210215124519.720265-10-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215124519.720265-1-laurent@vivier.eu> References: <20210215124519.720265-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:s5wCz8lgPDtujfRo8saj+r5HMMpfiynPGa7ljIKaWYUwwC4PMMw YwwxzbekKSHcIIRSrkHbCbHpRXxJg5I9DeVfP6xMQPeXN+lo/xNFUzdFx7jOA7YcQl9jKAX VzyDKAimf9G+a0xGhJJxDzZovzp+W8neyyaHaO4v81Atdy/LN+CaKV2nlkyD9iOV5ox7COm P7W+AdQinD6GxOlTVw+EQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:GpZC7dElTV4=:j6YoJe0oSFPnyAjFW8h3LT +4CrWD/DgDl1mp/sCQWmmvunquMmEK4cohArFGBMtK5Q2KUmdyS1pIkJjIi9J3uZL2z8IWEbS UnLaDk8p3nVSJcXWESNIcOQVhTuQ5A8kSGBwYsO6LzNHRlEulDLOCMKK5MbYTNofKjBCsNIM8 gXXTXkKZkhfwLuZLTq++rN64IeoROfEKeAODuhlbsCM7RQTVyATYd1cJX5aoB2H49I55qYhWL ZWe2CcyvIoCwpqZHpgyCVXPLRYB0NlUxNgL6dm76yxIZEJ3qPQfBhQbt1E+i+4ntoMtwlfAN5 NpeeWDr3k5gTOmrDn90X1BWPbb29w133rQOfw+QGdZPwuwOThUzrhyXAfnePFC0l/Q2RrWRJ1 8Z8X88vf6o3XdXGdGswJuanMQE5B9La03sLb5fkXJA0Rbb33ZPGjPliTlRtelLsOKepZSxRYe pg4GNjJRWg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Stefan 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 ioclt(=E2=80=A6, SIOCGIFCO= NF, =E2=80=A6) 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. Signed-off-by: Stefan Message-Id: <60AA0765-53DD-43D1-A3D2-75F1778526F6@vodafonemail.de> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dcb4009e2f17..6fea00869e6b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4914,6 +4914,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie,= uint8_t *buf_temp, struct ifconf *host_ifconf; uint32_t outbufsz; const argtype ifreq_arg_type[] =3D { MK_STRUCT(STRUCT_sockaddr_ifreq) = }; + const argtype ifreq_max_type[] =3D { MK_STRUCT(STRUCT_ifmap_ifreq) }; int target_ifreq_size; int nb_ifreq; int free_buf =3D 0; @@ -4937,7 +4938,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie,= uint8_t *buf_temp, =20 host_ifconf =3D (struct ifconf *)(unsigned long)buf_temp; target_ifc_buf =3D (abi_long)(unsigned long)host_ifconf->ifc_buf; - target_ifreq_size =3D thunk_type_size(ifreq_arg_type, 0); + target_ifreq_size =3D thunk_type_size(ifreq_max_type, 0); =20 if (target_ifc_buf !=3D 0) { target_ifc_len =3D host_ifconf->ifc_len; --=20 2.29.2